0

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

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

1

编辑:抛出我之前的整个答案。看起来您的 echo 语法错误:

var latitudine='<?echo php $_POST['lat']; ?>';
var longitudine='<?echo php $_POST['lon']; ?>';

应该

var latitudine='<?php echo $_POST['lat']; ?>';
var longitudine='<?php echo $_POST['lon']; ?>';
于 2013-06-14T09:44:27.040 回答