简体   繁体   English

无法在弹出窗口上将Latlong放置在地图中心

[英]Cannot place the Latlong at the center of map on popup

I tried alot to place the latlong at the center of the map on popup but still unable to place it at center.here is my code and latlong is coming dynamically from database. 我试图在弹出窗口上将latlong放置在地图的中心,但是仍然无法将其放置在center.here是我的代码,而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>

您不应该使用"包装坐标,因为它们将被视为字符串。请尝试不使用双反号逗号。如果全部失败,请在回显的纬度和经度上使用parseFloat()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM