我正在尝试使用各种形状和颜色的自定义标记图标创建地图。我的代码工作正常,我可以为所有位置使用任何单个标记,但不能为不同位置使用不同的标记。我目前正在将其编程为FileMaker Pro解决方案,但我正在用Javascript编写代码。我是Javascript的新手,我正在接受我的工作,但下面是我到目前为止的代码:
var concus = 'Dropbox/FileMaker Pro Files/FileMaker Pro Contract Bid Files/Images/red_customer.png';
var rencus = 'Dropbox/FileMaker Pro Files/FileMaker Pro Contract Bid Files/Images/purple_customer.png';
var sercus = 'Dropbox/FileMaker Pro Files/FileMaker Pro Contract Bid Files/Images/green_customer.png';
var connon = 'Dropbox/FileMaker Pro Files/FileMaker Pro Contract Bid Files/Images/red_noncustomer.png';
var rennon = 'Dropbox/FileMaker Pro Files/FileMaker Pro Contract Bid Files/Images/purple_noncustomer.png';
var sernon = 'Dropbox/FileMaker Pro Files/FileMaker Pro Contract Bid Files/Images/green_noncustomer.png';
var imagenum;
var markers = [];
for (var i = 0; i < data.length; ++i) {
var latlng = new google.maps.LatLng(data[i].latitude, data[i].longitude);
var marker = new google.maps.Marker({position: latlng, map: map, icon: markerimage[i], title:data[i].label, info:data[i].info});
markers.push(marker);
}
非常感谢任何帮助!
扎克
答案 0 :(得分:0)
试试这个:
var iconBase = 'Dropbox/FileMaker Pro Files/FileMaker Pro Contract Bid Files/Images/';
var icons = {
concus: {
icon: iconBase + 'red_customer.png'
},
rencus: {
icon: iconBase + 'purple_customer.png'
},
sercus: {
icon: iconBase + 'green_customer.png'
},
connon: {
icon: iconBase + 'red_noncustomer.png'
},
rennon: {
icon: iconBase + 'purple_noncustomer.png'
},
sernon: {
icon: iconBase + 'green_noncustomer.png'
}
};
function addMarker(feature) {
var marker = new google.maps.Marker({
position: feature.position,
icon: icons[feature.type].icon,
map: map
});
}