0

我尝试了很多将 latlong 放置在弹出窗口的地图中心,但仍然无法将其放置在中心。这是我的代码,latlong 来自数据库动态。

<script>
   var amsterdam = new google.maps.LatLng("<?php echo $lats; ?>","<?php echo $lons;?>");

function initialize()
{
var mapProp = {
  center:amsterdam,
  zoom:8,
  mapTypeId:google.maps.MapTypeId.ROADMAP
  };
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
var myCity = new google.maps.Circle({
  center:amsterdam,
  radius:<?php echo $rad;?>,
  strokeColor:"#0000FF",
  strokeOpacity:0.8,
  strokeWeight:2,
  fillColor:"#0000FF",
  fillOpacity:0.4
  });
var marker=new google.maps.Marker({
  position:amsterdam,
  animation:google.maps.Animation.BOUNCE
  });

marker.setMap(map);
myCity.setMap(map);
//google.maps.event.trigger(map, 'resize');
  } google.maps.event.addDomListener(window, 'load', initialize);

</script>
<div id="googleMap" style="width:100%;height:340px;margin-left: 4px;margin-top: 15px;"></div>
</div>
4

1 回答 1

1

You shouldn't wrap the coordinates with " because they will be treated as strings. Try without the double inverted commas. If all fail, use parseFloat() on the echoed latitude and longitude.

于 2013-03-24T15:27:02.077 回答