Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to know if it is possible to create an interactive map where the user will be allowed to add their own location to the map (I would use OSM as the basemap) and then calculate the distance between that location and some other objects that the map shows? If it is possible I would appreciate if you could explain to me the basic idea how it could be done. Thanks

share|improve this question
    
Google Maps v3 and a database [Fusion Tables / PostGIS] can do the distance calculation. developers.google.com/fusiontables/docs/samples/circle_example –  Mapperz Jan 25 '13 at 20:19
    
I'm not sure if it helps me. I want to create my own interactive map with OSM as my basemap. I will have few layers which will show different objects and I would like if it could be possible that user of that map mark his own location on map and then calculate the distance to one of that objects that he can select. –  user14026 Jan 25 '13 at 20:33
1  
Please change your question to highlight Open Street Maps (OSM) is your desired base-map. Openlayers would be a good solution. openlayers.org/dev/examples/editingtoolbar.html –  Mapperz Jan 25 '13 at 20:43
    
Yes, sorry, I agree I should mention it. Do you think Openlayers have controls to do that? I was searching a little bit but I couldn't find anything like that. Just the measure tool but no tool which would enable user to add his location. –  user14026 Jan 25 '13 at 20:50
    
show 1 more comment

1 Answer 1

up vote 1 down vote accepted

The answer reside on the several sources. First you must create an html code to get the user location. It can be an html form/input (doc here). You can also use a locator (go here and choose locate) . This location you store it in a OpenLayers.LonLat (doc here), and you use it to draw the point as an Openlayers.Marker (doc enter link description here). Then you need the other point to hich to compute the distance. The distance computing can be done like here.

"then calculate the distance between that location and some other objects that the map shows?"

To what do you refer here? You want to select these feature on the map? Or what?

share|improve this answer
    
Yes, I would like if user could select one of the features on the map. The best possible way would be if it could automatically show him the closest features from his location but I suppose it requires a lot of programming knowledge which I still don't have. But what you have already wrote to me is still very helpful. I'm sure it will help me a lot when I come to that part of my web gis application. I just wanted to know for now if it is possible and some basic principle. You helped me with that very much. –  user14026 Jan 30 '13 at 19:49
    
Well, if the data which you want to show to the user does not exceed around 1000 points, you could draw those point in an OpenLayers.Layer using a json or kml file, and let the user select one of them. –  Niculita Mihai Jan 30 '13 at 19:53
    
Yes I know, it doesn't exceed 1000 points. It was my idea to draw them all, it shouldn't be problem, I know how to do it. The only problem for me was how to let user add his own location but I think that now I know that too. Thanks :) –  user14026 Jan 30 '13 at 20:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.