<!DOCTYPE html> <html> <head> <script src="http://maps.google.com/maps/api/js?sensor=false"> </script> <script> if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showCurrentLocation); } else { alert("Geolocation API not supported."); } function showCurrentLocation(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; var coords = new google.maps.LatLng(latitude, longitude); var mapOptions = { zoom: 15, center: coords, mapTypeControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP }; //create the map, and place it in the HTML map div map = new google.maps.Map( document.getElementById("mapPlaceholder"), mapOptions ); //place the initial marker var marker = new google.maps.Marker({ position: coords, map: map, title: "Current location!" }); } </script> </head> <style> #mapPlaceholder { height: 400px; width: 700px; </style> <body> <div> <h2>HTML5 Show Location on GoogleMap Sample</h2> <div id="mapPlaceholder"></div> </div> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)