Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
-2
rated 0 times [  4] [ 6]  / answers: 1 / hits: 30404  / 15 Years ago, mon, november 16, 2009, 12:00:00

I'm using the Google Maps API (v2) and would like to center the map onload to a country (for example england).



At the moment i center the map using:



map.setCenter(new GLatLng( 43.907787,-79.359741), 9);


But this obviously requires longitude and Latitude.



Any way to do this by inserting a name of a country?


More From » google-maps

 Answers
14
var country = United States
var map = new GMap2($(#map)[0]);
map.setUIToDefault();

var geocoder = new GClientGeocoder();
geocoder.getLatLng(country, function (point) {
if (!point) {
// Handle error
} else {
map.setCenter(point, 8, G_PHYSICAL_MAP);
}
});

[#98301] Thursday, November 12, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
victorw

Total Points: 484
Total Questions: 120
Total Answers: 107

Location: Faroe Islands
Member since Thu, Apr 8, 2021
3 Years ago
victorw questions
Fri, Mar 18, 22, 00:00, 2 Years ago
Sun, Feb 20, 22, 00:00, 2 Years ago
Fri, May 7, 21, 00:00, 3 Years ago
Sat, Mar 13, 21, 00:00, 3 Years ago
;