[OpenLayers-Users] snap to road

Jordan Anderson jordandrsn at gmail.com
Wed Mar 18 11:43:11 EDT 2009


Hey Maxx,

ridethecity.com does something similar to this and you can see it in two places:

On the main page (http://www.ridethecity.com), if you drop a marker or
drag the market around, we send the lon/lat to the server and look up
the nearest street name in our PostGIS street database (but only in
NYC).

On the feedback page (http://www.ridethecity.com/feedback.php), you
can click on the map, we send the lon/lat to the server, look up the
nearest street name and return both the name of the street, the kind
of bike facilities on that street segment, and the geometry and then
plot it on the map.

If you have firebug, you can see the requests firing off and the XML
data that gets returned.

Jordan


> emmexx wrote:
>> I started to study OL a couple of weeks ago so I don't master it pretty
>> well.
>> I wrote some simple code based on the examples.
>> I'm going to write a web application that will have to manage complex
>> data about cycleways and users will draw routes on a map.
>>
>> I don't know if the user will be restricted to use just one map
>> (opencyclemap or gmaps or something else) but I'd like to know if the
>> following features are available in OL:
>>
>> 1. is it possible to get info from the "map"? I mean, if I click on a
>> road is it possible to get some kind of info from the map about that road?
>>
>> 2. is it possible to use snapping on a layer map rather than on a vector
>> layer?
>
> maxx,
>
> You can not do this strictly in OL, but you can do it with some help
> from the server. Here is the high-level approach to the problem.
>
> 1) user clicks on map
> 2) in OL, you get the click, convert it to lat/lon and pass it to the server
> 3) the server then returns info about the nearest line and maybe it
> snaps the point to that line and returns that info also
> 3a) if the server returns the geometry of the feature, then you can snap
> to that in javascript
> 4) you get the return package of data and use in OL
>
> WMS and Mapserver let you query more info based on a coordinate.
> You might need to write an AJAX handler on the server to help process
> your query requests.
>
> I will leave the details to others and maybe someone can point out an
> example that does some of these pieces.
>
> -Steve W



More information about the Users mailing list