- Call google maps javascript API :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> - Put this javascript :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
<script type="text/javascript"> function initialize() { var latlng = new google.maps.LatLng(-6.5975564, 106.7911592); //based on latitude & longitude, got from your GPS var mapOptions = { center: latlng, zoom: 13, mapTypeId: google.maps.MapTypeId.HYBRID, // map is overlay on satellite view mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU, position: google.maps.ControlPosition.TOP_CENTER } }; var map = new google.maps.Map(document.getElementById('map_container'), mapOptions); //this is marker position code var marker = new google.maps.Marker({ position: latlng, map: map, title: "My Position!" }); } </script> - Type this in your body tag :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
<body onload="initialize()"> <div id="map_container"></div> </body> - Type this under head tag, to set css style (optional) :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
<style type="text/css"> div#map_container{ width:100%; height:350px; } </style>
For complete tutorial and reference, please read Google Map Javascript API Tutorial and Google Map Javascript API Reference
May it helps,
Thanks
No comments:
Post a Comment