I have created the draggable marker using vector layer. Now I have to open a popup at dragend I have tried the following code:

vectors = new OpenLayers.Layer.Vector("Vector Layer",{ styleMap: new OpenLayers.StyleMap({ externalGraphic: "images/red-dot.png", graphicOpacity: 1.0, graphicWith: 16, graphicHeight: 26, graphicYOffset: -26 }) });

        point = new OpenLayers.Geometry.Point(77.768553,23.402765);
        vectors.addFeatures([new OpenLayers.Feature.Vector(point)]);
        map1.addLayer(vectors);

var drag=new OpenLayers.Control.DragFeature(vectors);

        map1.addControl(drag);
        drag.activate();

vectors.events.on( { 'dragend': onFeatureSelect, 'dragstart': onFeatureUnselect }

function onFeatureSelect(evt) { try {

    feature = evt.feature;
    var zoom = map1.getZoom();

    popup = new OpenLayers.Popup.FramedCloud("featurePopup",
                             feature.geometry.getBounds().getCenterLonLat(),
                             new OpenLayers.Size(100,100),
                             "<h2>"+feature.attributes.title + "</h2>" +
                             feature.attributes.description, 
                             null, true, onPopupClose);
    feature.popup = popup;
    popup.feature = feature;
    map1.addPopup(popup, true);
    }
    catch(e)
    {
        alert(e);
    }
}

function onFeatureUnselect(evt) { feature = evt.feature; if (feature.popup) { popup.feature = null; map1.removePopup(feature.popup); feature.popup.destroy(); feature.popup = null; } }

function onPopupClose(evt) {

    var feature = this.feature;
    if (feature.layer) {
        drag.unselect(feature);
    } else {

        this.destroy();
    }
}

but it is not working. Please suggest any solution.

asked 17 Sep '12, 12:33

Niki%20Kallurwar's gravatar image

Niki Kallurwar
11445
accept rate: 0%

edited 17 Sep '12, 13:26

SomeoneElse's gravatar image

SomeoneElse ♦
32.1k63332751

2

There are a bunch of OpenLayers mailing lists described here, and other useful resources, including an IRC channel, here.

(17 Sep '12, 13:31) SomeoneElse ♦
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×114
×70
×17
×1

question asked: 17 Sep '12, 12:33

question was seen: 4,298 times

last updated: 17 Sep '12, 13:31

powered by OSQA