[英]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.