AW: [OpenLayers-Users] drawfeature question

Arnd Wippermann arnd.wippermann at web.de
Thu Feb 16 17:57:14 EST 2012


You can try 

function activeControlList()
{
    var Msg = "";
    var NL  = "\n";

    var oCtrls = map.controls;
    for(var i=0;i<oCtrls.length;i++)
            Msg += i + ", " +
oCtrls[i].CLASS_NAME.replace(/OpenLayers.Control./,"") + ", " +
oCtrls[i].displayClass + ", " + oCtrls[i].active + NL;
            //Msg += i + ", " +
oCtrls[i].CLASS_NAME.replace(/OpenLayers.Control./,"") + ", " + oCtrls[i].id
+ NL;
            //Msg += i + ", " +
oCtrls[i].CLASS_NAME.replace(/OpenLayers.Control./,"") + ", " +
oCtrls[i].active + NL;
    return(Msg);
}

console.log(activeControlList());

It should list the status of the controls as below:

0, PanZoomBar, olControlPanZoomBar, null
1, Navigation, olControlNavigation, true
2, Attribution, olControlAttribution, null
3, MousePosition, olControlMousePosition, true
4, Panel, olControlPanel, true
5, Navigation, olControlNavigation, false
6, DrawFeature, olControlDrawFeaturePoint, false
7, DrawFeature, olControlDrawFeaturePath, null
8, DrawFeature, olControlDrawFeaturePolygon, null
9, DrawFeature, olControlDrawFeaturePolygonRegular, null
10, ModifyFeature, olControlModifyFeature, false
11, SelectFeature, olControlSelectFeature, null
12, DragFeature, olControlDragFeature, true



To get the second point, you could register "featureadd" for your vector
layer.
 
var ftCounter=0;

function secondPoint(evt)
{
    //to prevent an endless loop
    ftCounter++;
    if(ftCounter%2==0)
        return;

    //move ft relative in x,y direction
    ft.geometry.move(0,5);
    map.layers[2].addFeatures([ft]);

}
map.layers[2].events.register("featureadded", map.layers[2], secondPoint);

Arnd


-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von sqgs
Gesendet: Mittwoch, 15. Februar 2012 23:46
An: openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] drawfeature question

I am new to openlayers and am trying to make one similar to the the
Snap-Split example:
(http://openlayers.org/dev/examples/wfs-snap-split.html). I have two
questions:

1. I have drawFeature and modifyFeature, and I need a function like
isActivated() to see which control is currently active. I checked OpenLayers
document, and didn't see one. Is this function available? or any available
function to check which control is active?

2. When user clicks the Draw_Point icon, then clicks on map, I want to put
two points on the map, one at the click location, the other is 5degree north
of the click location. I want both points be movable (by clicking modify
icon to move points). Can someone give me a clue how to do it? Because
Clicking the Draw_Point icon will create a Point feature, I tried to
duplicate the Point feature, then change the centerlatlon, but not sure how
to do it. 

Thanks. 

here is my drawfeature and modifyfeature object:

var draw = new OpenLayers.Control.DrawFeature(
                vector, OpenLayers.Handler.Point,
                {
                    title: "Draw Feature",
                    displayClass: "olControlDrawFeaturePoint",
                    handlerOptions: {multi: false}
                }
            );

modify = new OpenLayers.Control.ModifyFeature(
                vector, {displayClass: "olControlModifyFeature"}
            );

--
View this message in context:
http://osgeo-org.1560.n6.nabble.com/drawfeature-question-tp4474203p4474203.h
tml
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list