Wednesday 20 April 2022

How to create a map based on Latitude & Longitude?

Sometimes we need a map based on specified location or dynamically create a map. Then we need to use Latitude & Longitude. Latitude & Longitude provide the perfect location of any place. By finding that we can create a map using it.

Below Gives full code of Creation of map base on Latitude & Longitude.

<html>
<head>
<style type="text/css">
            div#map {
width: 100%;
height: 200px;
            }
</style>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript">
            var map;
            var geocoder;
            var centerChangedLast;
            var reverseGeocodedLast;
            var currentReverseGeocodeResponse;

            function initialize() {
                var latlng = new google.maps.LatLng(-41.2785537,174.778663);
/*FOR PHP CODE:  var latlng = new google.maps.LatLng("<?php echo $is_about_physical_address_lat; ?>","<?php echo $is_about_physical_address_lng; ?>");  */
                var myOptions = {
                    zoom: 14,
                    center: latlng,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                geocoder = new google.maps.Geocoder();

                var marker = new google.maps.Marker({
                    position: latlng,
                    map: map,
                    title: "Hello World!"
   /*FOR PHP CODE:  title: "<?php echo $is_about_postal_address; ?>, <?php echo $is_about_country_name; ?>"  */
                });

            }
</script>
</head>

<body onLoad="initialize()">
        <div id="map">
            <div id="map_canvas" style="width:100%; height:200px"></div>
            <div id="maparea"></div>
        </div>
</body>
</html>






For more Interesting, Useful Article & codes visit IT New Code.

Ankit Shah PHP Expert

IT New Code suggest a solution for your problem related to coding, Specially .PHP, Wordpress, WooCommerce, Magento, HTML and CSS. Visit Our website for Information.

0 comments:

Post a Comment

 

Copyright @ 2016 IT New Code | Developing Code | Designing Code.

Designed by: Ankit Shah