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 have the following code:

    function mapCreate(lon,lat){
    map = new OpenLayers.Map("map1");
    var osm = new OpenLayers.Layer.OSM();
    vectors = new OpenLayers.Layer.Vector("Vector Layer");
    var center = new OpenLayers.LonLat(lon,lat).transform(
        new OpenLayers.Projection("EPSG:4326"),

    point = new OpenLayers.Geometry.Point(center.lon,;
    vectors.addFeatures([new OpenLayers.Feature.Vector(point)]);
    drag = new OpenLayers.Control.DragFeature(vectors);
    map.setCenter(center, 15);
    map.addLayer(vectors);'moveend',point, function(evt){


The part that does not work is:'moveend',point, function(evt){

Can anyone help me with creating an event listener for a point in open layers?

share|improve this question
up vote 5 down vote accepted

You should use onComplete property of OpenLayers.Control.DragFeature, for example:

drag = new OpenLayers.Control.DragFeature(vectors, {
    autoActivate: true,
    onComplete: function() {alert('hello')}

Here is my online example: DragFeature.

share|improve this answer
Thanks, this helped me out too. Question: It strikes me that having to pass an empty function to a control to make it work is, well...kind of dumb. What is going on here that leads to this? – bshender May 2 '13 at 13:43

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.