Working out if an address is in the channel islands

83 views
Skip to first unread message

chris leate

unread,
Oct 27, 2011, 9:27:46 AM10/27/11
to google-map...@googlegroups.com
I've got to determnine if an address is in the channel islands, ireland or UK so that I can convert the geolocation into an NGR.

I've looked into this and was expecting that the address returned from the places API would tell me where a place is in the address. Unfortunately the way it does this is strange. It seems to not contain the word guernsey, jersey or any of that in the address. I was thinking I'll either have to create rectangles of long and lat and check against them before doing my calculation or ask the clever people of the community if they have come up with a clever solution for this.

Tar

xelawho

unread,
Oct 27, 2011, 5:00:32 PM10/27/11
to Google Maps JavaScript API v3
> I've got to determnine if an address is in the channel islands, ireland or
> UK so that I can convert the geolocation into an NGR.
>
> I've looked into this and was expecting that the address returned from the
> places API would tell me where a place is in the address.

I'm confused... you type in 23 Smith street and you expect to be told
if that address exists within the channel islands, ireland or UK? and
if it exists elsewhere as well...? ignore it I guess.

seems to be problematic to me. You can use a geocoder to find an
address' position, but the geocoder gets confused if you don't give it
enough detail and it returns multiple results. I guess you could loop
through the results, send them to the reverse geocoder then loop
through those results looking for the country names that you
mentioned.

or there may be a much simpler way to do this...

Rossko

unread,
Oct 28, 2011, 5:04:32 AM10/28/11
to Google Maps JavaScript API v3
> I've got to determnine if an address is in the channel islands, ireland or
> UK so that I can convert the geolocation into an NGR.

I think your bounding-box idea should work more reliably than
analysing returned results text.

Did they forget to mention Isle of Man too?

Trent Rebeiro

unread,
Oct 29, 2011, 12:03:42 AM10/29/11
to Google Maps JavaScript API v3
> I was thinking I'll either have to create rectangles of long and lat and check
> against them before doing my calculation...

You haven't really specified how the user inputs the location.
Regardless, if you can get the lat/lng of the location through mouse
event click on the map or passing address to geocoder, do the
following for the most accuracy and control:
1. Create a polygon of the channel islands (you don't necessarily have
to display it on the map)
2. Check whether the lat/lng is inside the polygon. See the following
script of various methods to extend google.maps.Polygon, in particular
the method .Contains(latlng)
http://www.cnblogs.com/alli/archive/2010/11/12/1875536.html
3. If the lat/lng is inside the polygon, convert it into an NGR
(whatever that is)
Reply all
Reply to author
Forward
0 new messages