-1

Given coordinates, how could I find the way to draw a line all over the street (or nearest street if coordinates are not so accurate) ?

Example: I have these coordinates: 40.752443,-73.987376 (part of Broadway, NYC) … I would like to draw a line all over Broadway.

Using Google Directions API can draw a line through the street ... but I'd need to know the beginning and end of the street.

Thank you in advance !

FlamingMoe
  • 2,709
  • 5
  • 39
  • 64

1 Answers1

2

A latitude/longitude coordinate pair only specifies a single point on the globe, and doesn't imply any details about the geography of the area around it. There may be an API that can take in a coordinate pair and give you the name of the nearest street, and then the Google Directions API could give you a set of coordinates that indicate turning points along the street (since not all streets are completely straight). Once you've got those coordinates, you can draw a line passing through all of them, and that will represent the street.

Hope that's helpful - unfortunately I haven't used the Google Directions API in a long time so I'm not sure of it's capabilities regarding this type of thing.

EDIT: This question may be helpful for the first part. The top answer links to an API someone made to find the name of the nearest street to a given Lat/Long pair. Not sure if it works in every country though.

Community
  • 1
  • 1
benwad
  • 6,414
  • 10
  • 59
  • 93
  • Well ... I see a challenge here yet ... How to know the beggining and the end of a street ? If I'd know this, then I can use the Directions API to get the line through the street (if Google decides to follow the street is the fastest way although the street has a lot of curves, afortunately this is not usual) ... but I need to know the edges coordinates of the street. – FlamingMoe Sep 20 '12 at 15:05
  • Yeah that'll be the hardest part, and I'm not sure how you'd go about it. Maybe examine the output of that API I linked you to: maybe it gives you details about the street, or maybe you could plug the name of the street into another API that contains the geometry of all streets. Map data is notoriously difficult to work with, so it's not going to be easy. Good luck! – benwad Sep 20 '12 at 15:29