Using drag and drop to get Latitude and Longitude

JS Bin


function initialize() {
var $latitude = document.getElementById(‘latitude’);
var $longitude = document.getElementById(‘longitude’);
var latitude = 50.715591133433854
var longitude = -3.53485107421875;
var zoom = 7;

var LatLng = new google.maps.LatLng(latitude, longitude);

var mapOptions = {
zoom: zoom,
center: LatLng,
panControl: false,
zoomControl: false,
scaleControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP

var map = new google.maps.Map(document.getElementById(‘map’),mapOptions);

var marker = new google.maps.Marker({
position: LatLng,
map: map,
title: ‘Drag Me!’,
draggable: true

google.maps.event.addListener(marker, ‘dragend’, function(marker){
var latLng = marker.latLng;
$latitude.value =;
$longitude.value = latLng.lng();



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s