如何更改谷歌地图中的标记图像?

时间:2012-10-01 23:19:12

标签: javascript google-maps

我想通过以下代码更改Google地图中的标记图像,但它不起作用

remap.gMap(
{ 
  markers: [<?php echo $markers;?>],
  latitude:document.getElementById('searchlatitude').value,
  longitude:document.getElementById('searchlongitude').value,
  zoom:10 ,
  panControl:true,
  icon: "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png"
}
);

1 个答案:

答案 0 :(得分:0)

function initialize() {
  var myLatlng = new google.maps.LatLng(document.getElementById('searchlatitude').value,document.getElementById('searchlongitude').value);
  var mapOptions = {
    zoom: 10,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

  var image = 'http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png';
  var myLatLng = new google.maps.LatLng(-33.890542, 151.274856);
  var beachMarker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      icon: image
  });
}

https://developers.google.com/maps/documentation/javascript/overlays?hl=en-US#SimpleIcons