【问题标题】:InvalidValueError: setCenter: not a LatLng or LatLngLiteral: in property lat: not a numberInvalidValueError: setCenter: not a LatLng or LatLngLiteral: in property lat: not a number
【发布时间】:2015-11-09 19:24:58
【问题描述】:

我想从数据库中挑选我的地理数据。我声明了数据类型 decimal(12,8)。我想从数据库中选择值,这是因为几次点击会显示几个 maps.lat 和 lng 值会动态变化

但它显示了

InvalidValueError: setCenter: not a LatLng or LatLngLiteral: in property lat: not a number. [

<?php
if ($result!=NULL) {
	foreach ($result as $value) {
		$latitude=$value->latitude;
		$longitude=$value->longitude;
	?>
<script type="text/javascript">
  function intimap(){
var mapOptions={
 center: {lat:<?php echo json_encode($latitude);?>,lng:<?php echo json_encode($longitude);?>},
 zoom: 12,
 mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById(<?php echo json_encode($value->map_name);?>),mapOptions);
var marker=new google.maps.Marker({
  position:{lat:<?php echo json_encode($latitude);?>,lng:<?php echo json_encode($longitude);?>},
  map: map,
  title:<?php echo json_encode($value->place_title);?>,
  animation:google.maps.Animation.BOUNCE
});
}
</script>

【问题讨论】:

  • 欢迎来到 SO!请发布您的相关代码。没有它,我们就是在黑暗中拍摄。
  • @BrianKeller-Heikkila 我添加了您要求的代码。

标签: php google-maps


【解决方案1】:

我认为您的问题是您在设置标记变量时使用 json_encode 输出值。只需在没有 json_encode 的情况下回显那里的值,这应该可以解决它。

【讨论】:

    猜你喜欢
    • 2020-01-30
    • 1970-01-01
    • 2014-01-02
    • 2019-08-29
    • 1970-01-01
    • 2020-03-03
    • 2021-04-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多