Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1401
  • Last Modified:

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?
0
Jeremy Leys
Asked:
Jeremy Leys
1 Solution
 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now