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

Posted on 2012-08-25
Last Modified: 2012-08-25

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).

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:

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(, sw.lng()),
      sw, new google.maps.LatLng(, 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?
Question by:jwleys
    LVL 38

    Accepted Solution

    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.

    Author Comment

    Thanks that is very helpful:

    NE Latitude Longitude -32.95337 179.86816
    SW Latitude Longitude -47.39835 162.94922

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Hire Freelancers to Complete JavaScript Projects

    Source the talented Expert Exchange community
    for top quality work on your JavaScript projects.

    Hire the best. Collaborate easily. Get quality work.

    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now