Code is working fine but i want to add my own location .
for example in below script
map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);
is giving me map for that perticular location if I want Pune,India map
then where I need to put this location or how can I get the lat lng for this location?
how can i do it please help me i’m newbie in mvc.
<script type="text/javascript" src="http://www.google.com/jsapi?key=mykey"></script>
<script type="text/javascript">
var allMarks = [];
google.load("maps", "2");
//This function will help us to add the mark at
//location where user has double clicked. Then
//we will add all the marks in our array so that
//we can send it back to the controller
function initialize() {
var map = new google.maps.Map2(document.getElementById("map"));
map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);
marker = new google.maps.marker
map.setUIToDefault();
GEvent.addListener(map, "dblclick", function(overlay, latlng) {
if (latlng) {
var mark = new GMarker(latlng);
allMarks.push(latlng);
map.addOverlay(mark);
}
});
}
google.setOnLoadCallback(initialize);
//This function will be called for saving the mark
//for that it will send the data back to the controller
function saveMap() {
//gmap object with all values of the map mark
var gmap = {
Locations: allMarks,
Description: Description.value
}
//Ajax call for saving the data at the server. It will send the gmap
//object tot the server
$.ajax({
type: "POST",
url: "/Home/Create",
data: gmap
});
}
</script>
Assuming that you just need to do this once, and not geocode arbitrary locations on the fly, then all you have to do is replace the coordinates in
with your own coordinates and zoom level. You can easily find the lat/lon for a location manually in a variety of ways – I like getlatlon.com.
Was that really your question? If you need to take an arbitrary address, e.g. based on user input, and center the map there, you might want to look at Google’s geocoding API.