谷歌地图v3上的不同标记

时间:2012-06-16 21:11:21

标签: json google-maps google-maps-markers

如何向Google地图v3添加不同的标记?

以下是我的标记示例:

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);
  });

}

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

我已经解决了一个问题很简单,我已经把这个

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