我使用Google Maps API创建了一个网络地图,并根据以下代码将我的标记图标定义为自定义:
var customIcons = {
Biotechnology: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
Health: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
}
}
但是如果我使用>我找不到定义自定义标记图标的方法。或者<符号。并取代"生物技术"或者"健康"像
这样的东西var customIcons = {
Budget > 150000: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
Budget < 150000: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
}
}
非常感谢
答案 0 :(得分:0)
var image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
var image2 = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
for (var i = 0; i < ... ; i++)
{
var myLatLng = new google.maps.LatLng(..., ...);
var marker = new google.maps.Marker(
{
position: myLatLng,
map: map,
if ( Budget > 150000) {
icon: image;
} else {
icon: image2;
}
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
});
}