0

我有这段代码应该在谷歌地图中显示 mea Marker:

enter code here

 var latitudine='<?echo php $_POST['lat']; ?>';
    var longitudine='<?echo php $_POST['lon']; ?>';
    var myCenter=new google.maps.LatLng(latitudine,longitudine);
   function initialize()
   {
    var mapProp = {
    center: myCenter,
    zoom:5,
    mapTypeId: google.maps.MapTypeId.ROADMAP
   };

 var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);

  var marker = new google.maps.Marker({
  position: myCenter,
  title:'Click to zoom'
  });

 marker.setMap(map);

 // Zoom to 9 when clicking on marker
  google.maps.event.addListener(marker,'click',function() {
  map.setZoom(15);
  map.setCenter(marker.getPosition());
  });
}
google.maps.event.addDomListener(window, 'load', initialize);
    </script>

但是当我可视化地图时,我没有标记。我可以通过哪种方式提供值“纬度”和“经度”?

4

1 回答 1

0

我认为您需要在此处传递地图对象:-

var marker = new google.maps.Marker({
  map: map,
  position: myCenter,
  title:'Click to zoom'
  });
于 2013-06-17T12:24:12.930 回答