NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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 ♦
36.9k71370866

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 ♦

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:

×122
×98
×23
×1

question asked: 17 Sep '12, 12:33

question was seen: 5,997 times

last updated: 17 Sep '12, 13:31

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum