How can I make Edit mode active on load?

25 views
Skip to first unread message

Rodrigo Cea

unread,
Feb 10, 2011, 8:27:58 AM2/10/11
to olwi...@googlegroups.com
I'm using an EditableMap with geometry:'point', where users need to enter a point coordinate. 
Is there a way for the edit interface to be visible and selected on load? Right now they have to

a) click on edit
b) guess that the 'pencil' icon is what they want
c) select and use it

whereas I'd like for the steps to be

a) open map with 'pencil' tool already active, and use it.

Charlie DeTar

unread,
Feb 11, 2011, 7:27:38 AM2/11/11
to olwi...@googlegroups.com

Hi,

There's currently no way to do this using python code. You can do it by
overriding the template to execute "setEditing" on the map:

// editable_layer.html
var map new olwidget.EditableLayer("{{ id }}", {{ options|safe }})
map.setEditing();

best,
Charlie

Rodrigo Cea

unread,
Feb 11, 2011, 10:17:37 AM2/11/11
to olwi...@googlegroups.com
Thanks, however I haven't been able to get it to work, thus:

var map = new olwidget.EditableMap('id_ubicacion', {
                        name: 'punto',
                        geometry: 'point',
                        controls: ['DrawFeature'],
                        overlayStyle: {
                            fillColor: "#ffffff",
                            strokeColor: "#F46523",
                            fillOpacity: 0.7,
                            strokeWidth: 10
                        },
                        layers: ['google.hybrid', 'google.streets','google.physical', 'google.satellite'],
                        defaultLon: {{obj.mapa_deslindes.centroid.x|floatpoint|default:0}},
                        defaultLat: {{obj.mapa_deslindes.centroid.y|floatpoint|default:0}},
                        defaultZoom: 12
                     }
                         );
                    map.setEditing();

Charlie DeTar

unread,
Feb 12, 2011, 2:07:47 PM2/12/11
to olwi...@googlegroups.com

Oops, you're totally right, my mistake -- "setEditing" is a property of
the editable layer switcher control, not the map. Here's a correct
working version, which is unfortunately rather complex.

var map = new olwidget.EditableMap('id_ubicacion', {
name: 'punto',

...);

// Open up the editing control.
for (var i = 0; i < map.controls.length; i++) {
if (map.controls[i] && map.controls[i].CLASS_NAME ==
"olwidget.EditableLayerSwitcher") {
map.controls[i].setEditing(map.vectorLayers[0]);
break;
}
}

-charlie

Rodrigo Cea

unread,
May 24, 2011, 10:22:00 AM5/24/11
to olwi...@googlegroups.com
Kind of late answer, but thanks! That worked.
Reply all
Reply to author
Forward
0 new messages