Jeremy Leys
asked on
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?
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, new google.maps.LatLng(sw.lat(
];
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
NE Latitude Longitude -32.95337 179.86816
SW Latitude Longitude -47.39835 162.94922