简体   繁体   中英

DISPLAY Google maps using Latitude & Longitude

I have a problem... well i save my Latitude & Longitude at .xml file

php:

$lat=$_POST['lati'];
$long=$_POST['lng'];

And i am trying to show user's location on google map. my code for showing my map is:

<!--GOOGLE MAPS LIBRARY:-->
<script>
//LOCATION SCRIPT HERE

        function initialize() {
            var lat_place=document.getElementById("lati");
            var lng_place=document.getElementById("lng");
            var myLatlng = new google.maps.LatLng((document.getElementById("lati")), (document.getElementById("lng")));
            var myOptions = {
                zoom: 8,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
  }
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}

            function loadScript() {
            var script = document.createElement("script");
                script.type = "text/javascript";
                script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
                document.body.appendChild(script);
}

        window.onload = loadScript;


        //LOCATION SCRIPT ENDS HERE
</script>

You haven't assign values The correct code should be :

        function initialize() {
            var lat_place=document.getElementById("lati").value;
            var lng_place=document.getElementById("lng").value;
            var myLatlng = new google.maps.LatLng(lat_place, lng_place);
            var myOptions = {
                zoom: 8,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
         }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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