verifying a point on a road

47 views
Skip to first unread message

vishal garg

unread,
Nov 3, 2011, 5:41:39 AM11/3/11
to google-map...@googlegroups.com
Hi,

I am working on a course project where I get the user's location via
GPS. Is there any API which returns in boolean whether the location
lies on a road or not? I tried but was unable to find any related
discussions on the web. If no API exists, what could be the best
possible way of implementing the function?

-vishal garg

MymsMan

unread,
Nov 3, 2011, 7:16:14 AM11/3/11
to google-map...@googlegroups.com
You can use the Reverse geocoder to find the address of the nearest point on a road known to the geocoder.  You could then compute the distance between the location returned by the geocoder and your GPS location (using the Geometry library).

However this is not foolproof - I have seen occasions when there has been over 750m difference between a map pin placed on a public road and the location returned by the reverse geocoder.


vishal garg

unread,
Nov 3, 2011, 8:01:06 AM11/3/11
to google-map...@googlegroups.com, bobb...@gmail.com
Thanks for the solution. Later a change in the search string led me to
the following which is what you are saying :

http://econym.org.uk/gmap/snap.htm

-vishal garg

> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/9PfsJepen7QJ.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

geoco...@gmail.com

unread,
Nov 3, 2011, 9:05:16 AM11/3/11
to Google Maps JavaScript API v3
The Directions Service will "snap to" a road. The geocoder could
return the locations of buildings (rather than the road) in areas
where "rooftop" geocoding exists.

-- Larry

vishal garg

unread,
Nov 3, 2011, 9:31:40 AM11/3/11
to google-map...@googlegroups.com, geoco...@gmail.com
Thanks for the information, Larry. I am using 'snap to' since I was
unable to find how directions service could be implemented for this.

-vishal garg

> --
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.

MymsMan

unread,
Nov 3, 2011, 11:20:18 AM11/3/11
to google-map...@googlegroups.com, geoco...@gmail.com
Vishal,

The econym sample you found is a V2 API sample so you would probably want to update it V3 before use but it is using the directions service as Larry suggested to find the nearest road by calculating the directions between the point to itself -  a null journey and then using the start location returned to plot the marker.

The location returned by the directions service may not be the same as that returned by the geocoder because it will depend on the type of directions you have requested (walking, driving, cycle).
This brings up the question of what is the definition of Road for your purposes?  Winchester High street, UK is a road along which buses run but which is closed to normal cars so the directions service would not return a location along it for Driving directions but would for Walking directions, would your app wish to consider it a road?   What would you want to consider a road if you were looking at a map of Venice?
Reply all
Reply to author
Forward
0 new messages