How do I get North-east and south-west points of a country in Google maps?

Hi,

I am new to using Google Maps API V3 and I am looking at setting up a form to auto Geo code a user based on an address field which will also auto-complete based on what the user types.

I found this great tutorial which more or less does what I want to do, however, it doesn't isolate to a specific country which is what I want to do (isolate the auto-complete suggestions to New Zealand).

http://tech.cibul.net/geocode-with-google-maps-api-v3/

That same tutorial then mentions that you can specify the region, see the example below, however this doesn't seem to work:
{‘address’: request.term, ‘region’: ‘NZ’ }, function(results, status) {…

Through doing a bit more searching I stumbled across this post that offered a better point in the right direction for solving the problem at hand:

http://stackoverflow.com/questions/2647086/googles-geocoder-returns-wrong-country-ignoring-the-region-hint

Concatenating ", NZ" on to the address string does seem to help by narrowing results to New Zealand and the Netherlands:
geocoder.geocode( {'address': request.term + ', NZ', 'region': 'NZ' }, function(results, status) {...

The post then goes on to mention that a bounding box can be defined to isolate the search to a specific country.

This example works fine for isolating searches to the UK

// Define north-east and south-west points of UK
   var ne = new google.maps.LatLng(60.00, 3.00);
   var sw = new google.maps.LatLng(49.00, -13.00);

   // Define bounding box for drawing
   var boundingBoxPoints = [
      ne, new google.maps.LatLng(ne.lat(), sw.lng()),
      sw, new google.maps.LatLng(sw.lat(), ne.lng()), ne
   ];

How do I get North-east and south-west points of New Zealand from Google maps, so that I can put a bounding box around New Zealand?

Or is there a better solution out there so I don't have to use this hack?
Jeremy LeysTechnical LeadAsked:
Who is Participating?
 
Tom BeckCommented:
You can just go to a site like this one and drop a pin and it will give you the coordinates at the pin location.

http://universimmedia.pagesperso-orange.fr/geo/loc.htm
0
 
Jeremy LeysTechnical LeadAuthor Commented:
Thanks that is very helpful:

NE Latitude Longitude -32.95337 179.86816
SW Latitude Longitude -47.39835 162.94922
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.