当mysql提供十进制纬度和经度时,谷歌地图显示错误的地图

时间:2020-12-22 16:33:14

I noticed that google maps does not show the correct map, when values from a mysql database having field type decimel or float are provided. varchar is accepted.

我注意到,当提供来自具有字段类型decimel或float的mysql数据库的值时,谷歌地图不会显示正确的地图。 varchar被接受。

source the the browser show the correct lat and long values and no blank spaces or other issues. what ever i tried Decimal does not sohw the correct map

源浏览器显示正确的lat和long值,没有空格或其他问题。什么我试过Decimal不会sohw正确的地图

           $lat= $row['latitude']; (decimel from mysql, does not work)
        $long=$row['longitude'];



    $lat=15.624256;(works)
    $long=73.7943410;


   <script>
   function initialize() {
    var mapCanvas = document.getElementById('map');
    var mapOptions = {
    center: new google.maps.LatLng(<?php echo $lat.', '.$long; ?>),
      zoom: 16,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(mapCanvas, mapOptions)
  }
  google.maps.event.addDomListener(window, 'load', initialize);
</script>

1 个解决方案

#1


0  

Check the data. Also put enough validations to ensure you have sane coordinates and proper precision. The query should replace null with 0.

检查数据。还要进行足够的验证,以确保您具有理智的坐标和适当的精度。查询应该用0替换null。

In the resulting html page, check if the html and javascript are properly formatted with the data.

在生成的html页面中,检查html和javascript是否与数据格式正确。

Write a dummy php to know the data

写一个虚拟的PHP来了解数据

$lat= $row['latitude'];
$long=$row['longitude'];
echo '<p>'.$lat.','.$long.'</p>'

TIP: Preferably avoid $long variable name. Use $longitude instead

提示:最好避免使用$ long变量名。请改用$经度

#1


0  

Check the data. Also put enough validations to ensure you have sane coordinates and proper precision. The query should replace null with 0.

检查数据。还要进行足够的验证,以确保您具有理智的坐标和适当的精度。查询应该用0替换null。

In the resulting html page, check if the html and javascript are properly formatted with the data.

在生成的html页面中,检查html和javascript是否与数据格式正确。

Write a dummy php to know the data

写一个虚拟的PHP来了解数据

$lat= $row['latitude'];
$long=$row['longitude'];
echo '<p>'.$lat.','.$long.'</p>'

TIP: Preferably avoid $long variable name. Use $longitude instead

提示:最好避免使用$ long变量名。请改用$经度