0

I am new to OpenLayers. I have seen the examples in which DragFeature is able to move my points, polygon and lines. But when it comes to test the Label moving in IE8, then the dragging functionality doesn't work,though I am able to drag the label in Firefox.

Please provide me help here.

1

I just follow the link and it helped me to make the DRAG and Delete option working.

         var labelAnnotation = new OpenLayers.Control.DrawFeature(LayerVector, 
              OpenLayers.Handler.Click, {

        title: "Add Text",
        displayClass: "olControlTextAnnotation",
        eventListeners:{
            'activate': function(e)
            {

                map.events.remove("click");
                map.events.register("click", map, function(e) {
                    var userInput = prompt("Please enter your annotation", "");
                    if (userInput != '' && userInput != null)
                    {
                        var positionN = this.events.getMousePosition(e);                            
                        var lonlat = map.getLonLatFromPixel(positionN);                         
                        var TempPoint = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);                          
                        var feature = new OpenLayers.Feature.Vector(TempPoint,{
                            text: userInput
                        },
                        {

                                label: userInput,
                                labelSelect: true

                        });                         
                        LayerVector.addFeatures([feature]);
                    }


                    map.events.remove("click");
                });

            },
            'deactivate': function(e){
                map.events.remove("click");
            }
        }
        });


        var drag = new OpenLayers.Control.DragFeature(LayerVector, {
        title: "Drag",
        displayClass: "olControlDragAnnotation"
    });

    /* Adding the control to the map.*/

    map.addControl(labelAnnotation);
    map.addControl(drag);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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