different markers on google maps v3

主宰稳场 提交于 2019-12-24 09:07:32

问题


How can I add different markers to google map v3?

Here is example for my marker:

var latlng = new google.maps.LatLng(lat,lng); 
var image = "../img/hotel_icon.png";
var locationDescription = this.locationDescription;
var marker = new google.maps.Marker({
  map: map,
  position: latlng,
  title:'pk:'+name,
  icon: image
});

bounds.extend(latlng);
setMarkes(map, marker, name, locationDescription);

});//close each
map.fitBounds(bounds);
});//close getjson

}//close initialize
function setMarkes(map, marker, name, locationDescription){
  google.maps.event.addListener(marker, 'mouseover', function() {
      infowindow.close();
      infowindow.setContent('<h3>'+name+'</h3><em>'+locationDescription+'</em>');
      infowindow.open(map, marker);
  });

}

回答1:


Here is one example that may help: http://www.geocodezip.com/v3_markers_normal_colored_infowindows.html




回答2:


i have resolved a problem was easy just i have put this

var currentplace = $("#currentplace").text();
  if(name == currentplace ){image = "../img/hotel_icon.png";}else{ image = "../img/home_icon.png";}


来源:https://stackoverflow.com/questions/11067065/different-markers-on-google-maps-v3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!