Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find the nearest intersection via the Google Maps API?

How can I find the closest intersection of the street I have coordinates of?

For instance, say I have street A running from south to north that is crossed by street X on the north and by street Y on the south.

Does the Google Maps API allow for finding coordinates of the nearest crossroad (either X or Y) of street A? I couldn't find it mentioned anywhere.

PS: The only solution I am aware of is to guess the lowest number and the highest number of building on the street A and to draw polyline between them. I am not sure about this though.

like image 946
dusoft Avatar asked Feb 16 '09 21:02

dusoft


People also ask

How do you find intersections in Google Maps?

Finding Intersections To find the intersection between two roads, insert an ampersand ("&") between the two street names. Search for "Broadway & E 14th St, New York, NY" to find the intersection between Broadway and East 14th Street in New York, for example.

Is Google geocoding API free?

The Geocoding API uses a pay-as-you-go pricing model. Geocoding API requests generate calls to one of two SKUs depending on the type of request: basic or advanced.


1 Answers

[see comments above]

unfortunately, no. even with gdirections, there is no way to locate the beginning and end of the street (coordinates). I have solved it by using the hack proposed above: looping over building numbers from 1 to XXX.

if accuracy is 6 for a while (8 = building number, 7=intersection, 6 = approximate address only) that means no new numbers exist. so i just take first point (lat/long), middle one and the last one (all with accuracy 8) and create path between them. this however sometimes only provides only a part of the street as other parts are either without any buildings or google does not have further data :(

like image 123
dusoft Avatar answered Sep 25 '22 13:09

dusoft