简体   繁体   English

使用PHP中的Google Maps将字符串转换为纬度和经度

[英]Conversion of a String to a latitude and longitude using google maps in PHP

I have this code that should show me Marker in Google map: 我有此代码应在Google地图中向我显示标记:

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>

But when I visualize the map, i haven't the marker. 但是当我可视化地图时,我没有标记。 In which way can i transfer the values "Latitudine" and "Longitudine"? 我可以通过哪种方式传递“ Latitudine”和“ Longitudine”值?

EDIT: Threw out my entire previous answer. 编辑:扔了我整个以前的答案。 Looks like you did the echo syntax wrong: 看起来您的echo语法错误:

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

should be 应该

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

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

相关问题 使用纬度和经度显示谷歌地图 - DISPLAY Google maps using Latitude & Longitude 使用纬度和经度在谷歌地图中搜索附近 - Near by search in google maps using latitude and longitude 从 MySQL 数据库加载纬度/经度并使用 PHP、html 和 JavaScript 在谷歌地图上显示点 - Loading latitude/longitude from MySQL database and showing point on Google Maps using PHP,html and JavaScript 使用 PHP 和谷歌地图 Api 计算出 2 个纬度和经度之间的距离 - Using PHP and google Maps Api to work out distance between 2 latitude and longitude 如何使用PHP JSON对象从Google Maps API获取5个附近地点的经度和纬度? - How to fetch Latitude and Longitude of 5 Nearby Places from Google Maps API using PHP JSON object? 谷歌地图 - 将地址转换为纬度和经度 - PHP后端? - Google Maps - converting address to latitude & longitude - PHP backend? 如何在不使用Google地图的情况下用折线匹配当前的经度和纬度 - How to match current latitude and longitude with polyline without using Google Maps 如何使用谷歌地图 api 将邮政编码转换为地理位置(纬度和经度)? - How to convert postcode to Geolocation (latitude & longitude) using google maps api? 在Google地图中设置纬度和经度-未定义结果 - Setting Latitude and Longitude in Google Maps - undefined results 解析谷歌地图API的纬度和经度 - Parsing Google Maps API for Latitude and Longitude
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM