使用匹配的ID更改标记图标 [英] Change marker icon with matching id
本文介绍了使用匹配的ID更改标记图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图改变现有引脚的颜色。我有5个引脚,其ID值从1-5开始。如果它等于3,我可以更改该引脚吗?我尝试了类似下面的代码,但无法获得我正在寻找的内容。任何帮助都会很棒。
I'm trying to change the color of an existing pin. I have 5 pins with id values running from 1-5. can I change the pin if it's say equal to 3. I tried something like the code below but can't quite get what I'm looking for. any help would be great.
if(marker.id == 3){
this.marker.setIcon(myPin2);
}
推荐答案
类型(餐厅,酒店)
或设置验证的默认值
you can create 1 array of type (restaurants,hotels) or set default value of validate
并尝试以下代码:
and try this code:
var marker_new = new Array();
var url = "";
switch (marker.id){
case 1: break;
case 2: break;
case 3:url = "http://exampl.com/yellow.png";
case 4: break;
case 5: break;
}
marker_new[i] = google.maps.Marker({
icon: url;
position: place.geometry.location,
map: map
});
或阅读更多:如何修改标记?
这篇关于使用匹配的ID更改标记图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文