Search a location, drag the marker to adjust the position and get the GPS coordinates.
Code snippet to create a Google map and deect user location,
this project uses Google Maps Javascript API v3
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
var map;
function geoinitialize() {
var mapOptions = {
zoom: 6
};
map = new google.maps.Map(
document.getElementById('map-canvas'),
mapOptions
);
// Try HTML5 geolocation
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = new google.maps.LatLng(
position.coords.latitude,
position.coords.longitude
);
map.setCenter(pos);
var marker = new google.maps.Marker({
map:map,
draggable:true,
animation: google.maps.Animation.DROP,
position: pos
});
});
}
}
google.maps.event.addDomListener(window, 'load', geoinitialize);
</script>
<div id="map-canvas"></div>