Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am setting a form (for multiple addresses) where users can click on map by creating a marker for each address they want to input. Users can only create one marker per address and once the marker has been created I need to get nearest address and update the address field (form input) with that address.

I am able to activate the marker drawing control but how can I make sure that user only creates one marker (not more) per address and then take that calculated address and update original text field (which fired the event) with new information.

This is what I have so far:

<form name="xxxx">

POI 1: <input type="text">
<a href="#" onClick="edrawMarker(event)"> click here to select address on map</a>
POI 2: <input type="text">
<a href="#" onClick="edrawMarker(event)"> click here to select address on map</a>

<a href="#"> Add more poi's </a>

Here's the javascript code

poi_markers = new OpenLayers.Layer.Vector('markers',{styleMap:markerStyleMap});
poi_marker_control = new openLayers.Control.DrawFeature(poi_markers,OpenLayers.Handler.Point);  

function e_drawPOIMarker(evt){'featureadded',poi_markers,function(evt){
         //get JSON response
                     var place_name = getGeoName(evt.feature.geometry)  
                            //Somehow find the id of the text field which fired original event and update its contents with data returned in place name.

Basically I have to capture co-ods of locations clicked by users. Each field (in form) should only allow 1 marker. Suppose if I have unknown numbers of poi address fields (which users can add dynamically) whats the best way of capturing coods and then updating original fields with that information.

At the moment I can activate and deactivate controls and allow users to create marker(s). but how can I know which marker belongs to which text field ?


share|improve this question

I would probably add a token to the *e_drawPOIMarker()* function. When called, just test if a marker having the passed token already exists or not.

share|improve this answer

Your Answer


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