Created
July 3, 2013 11:49
-
-
Save itsbalamurali/5917274 to your computer and use it in GitHub Desktop.
Google Maps Api Coodrinates
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
$("#SomeIDOfATextBox").val("Some value"); | |
//Can be replaced by: | |
document.getElementById('SomeIDOfATextBox').value = "Some value"; |
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
var map; | |
function initialize() { | |
if (GBrowserIsCompatible()) //a check to make sure the browser is compatible for GEmaps. | |
{ | |
map = new GMap2(document.getElementById("map_canvas")); //assign the div to map var | |
map.setCenter(new GLatLng(18, -77.4), 13); //centering the location | |
map.setUIToDefault(); //setting the default location to the center. | |
//The GE event for clicking the map. | |
GEvent.addListener(map, 'click', function(overlay, point) { | |
map.clearOverlays(); //clearing the previous marker | |
var lati = point.lat(); //Function to extract latitude | |
var longi = point.lng(); //Function to extract longitude | |
var marker = new GMarker(new GLatLng(lati, longi), { draggable: false }); //Setting the marker to clicked location | |
map.addOverlay(marker); //adding the marker to the map | |
//JQuery function to assign the lat and long to the values of textboxes. | |
$('#LatTxt').val(lati); | |
$('#LonTxt').val(longi); | |
}); | |
} | |
//This JQuery Function operates almost the same as the onload function, except more earlier | |
$(function() { | |
initialize();//call to initialize the map. | |
} |
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
<div id="map_canvas" style="width: 600px; height: 400px;"> | |
</div> | |
<label> | |
Latitude | |
<input id="LatTxt" disabled="disabled" type="text" /> | |
</label> | |
<label> | |
Longitude | |
<input id="LonTxt" disabled="disabled" type="text" /> | |
</label> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment