When you are inserting Google map on your page, you often want to set certain point, where the map will be centered. Getting the center point from google is often not very convenient as their map has a different size than yours. Here is the easiest way to center Google map I found:
Activate the google map with dimensions you want to use and any starting point you like.. The standard code could look like this:
function initialize() {
var mapStartOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoom: 6,
center: new google.maps.LatLng(55.720922807787, 10.634765625)
}
map = new google.maps.Map(document.getElementById("map_canvas"), mapStartOptions);
}
You see that you need to enter latitude and longitude values for setting the center variable on line #5.
So just drag the map to the position, where you want to have it, and then enter following code straight to the address bar of your browser:
javascript:void(prompt('',map.getCenter()));
This will get you nice box, where you can copy the Latitude and Longitude values and use them to center your map. You will only need to adjust the variable map if your map has a different name (the name is set on line #8 in the code above).
Žádné příbuzné články.