[Users] Why don´t my measure Controls toggle off?
Eric Lemoine
eric.lemoine at camptocamp.com
Thu Oct 7 06:31:48 CEST 2010
On Wednesday, October 6, 2010, Robert Buckley <robertdbuckley at yahoo.com> wrote:
> Hi,
>
>
> I thought I had this toggling business sorted out, and then this happened. I
> can´t see why the select tool doesn´t disable the measure tools?
> Can anyone see my error?
Not really. Have you tried to not set the toggleGroup property in the
menu button?
> var toolbarItems = [], action, actions = {};
> var toggleGroup = "ToogleGroup";
>
> // ### important ###
> OpenLayers.Control.Measure.prototype.geodesic = true;
> function check(btn)
> {
> if (btn == 'OK'){
> oDragPanCtrl.activate();
> }
> };
>
>
> // MaxExtent control
> action = new GeoExt.Action({
> text: "",
> tooltip: "Auf Verbandsgebiet zoomen",
> icon: '../images/arrow_out.png',
> control: new OpenLayers.Control.ZoomToMaxExtent(),
> map: map
> });
> actions["max_extent"] = action;
> toolbarItems.push(action);
> toolbarItems.push(' ',' ',' ',' ');
>
> // Pan control
> action = new GeoExt.Action({
> text: "",
> enableToggle: true,
> toggleGroup: toggleGroup,
> tooltip: "Schwenken",
> icon: '../images/hand.png',
> control: new OpenLayers.Control.DragPan({isDefault: true,title:
> 'Pan'}),
> map: map
> });
> actions["Pan"] = action;
> toolbarItems.push(action);
> toolbarItems.push(' ',' ',' ',' ');
>
> //Keyboard zoom control
> action = new GeoExt.Action({
> text: "",
> tooltip: "Heranzoomen",
> enableToggle: true,
> icon: '../images/zoombox.png',
> toggleGroup: toggleGroup,
> control: new OpenLayers.Control.ZoomBox({alwaysZoom:true}),
> map: map
> });
> actions["Zoom"] = action;
> toolbarItems.push(action);
> toolbarItems.push(' ',' ',' ',' ');
>
> // Navigation history - two "button" controls
> ctrl = new OpenLayers.Control.NavigationHistory();
> map.addControl(ctrl);
>
> action = new GeoExt.Action({
> text: "",
> icon: '../images/arrow_left.png',
> control: ctrl.previous,
> disabled: true,
> tooltip: "zurück zur vorherigen Ausdehnung"
> });
> actions["previous"] = action;
> toolbarItems.push(action);
> action = new GeoExt.Action({
> text: "",
> control: ctrl.next,
> icon: '../images/arrow_right.png',
> disabled: true,
> tooltip: "vor zur nächsten Ausdehnung"
> });
> actions["next"] = action;
> toolbarItems.push(action);
> toolbarItems.push(' ',' ',' ',' ');
>
> //select control
> action = new GeoExt.Action({
> text: "",
> tooltip: "Features selektieren",
> enableToggle: true,
> icon: '../images/information.png',
> toggleGroup: toggleGroup,
> control: new OpenLayers.Control.SelectFeature(
> [layer_wea,layer_biogas,layer_wasserkraft,layer_kraftwerke],
> {
> clickout: true, toggle: false,
> multiple: false, hover: false
> }
> ),
> map: map
> });
> actions["Select"] = action;
> actions["area", "Entfernung"].disabled=true;
> toolbarItems.push(action);
> toolbarItems.push(' ',' ',' ',' ');
>
> // Measure line control
>
>
> // style the sketch fancy
> var sketchSymbolizers = {
> "Point": {
> pointRadius: 4,
> graphicName: "square",
> fillColor: "white",
> fillOpacity: 1,
> strokeWidth: 1,
> strokeOpacity: 1,
> strokeColor: "#333333"
> },
> "Line": {
> strokeWidth: 3,
> strokeOpacity: 1,
> strokeColor: "#2AFF2A",
> strokeDashstyle: "dash"
> },
> "Polygon": {
> strokeWidth: 2,
> strokeOpacity: 1,
> strokeColor: "#2AFF2A",
> strokeDashstyle: "dash",
> fillColor: "#2AFF2A",
> fillOpacity: 0.2
> }
> };
> var style = new OpenLayers.Style();
> style.addRules([
> new OpenLayers.Rule({symbolizer: sketchSymbolizers})
> ]);
> var styleMap = new OpenLayers.StyleMap({"default": style});
>
> action = new GeoExt.Action({
> text: "area",
> toggleGroup: toggleGroup,
> group: toggleGroup,
> control: new OpenLayers.Control.Measure(OpenLayers.Handler.Polygon,
> {
> persist: false,
> handlerOptions: {
> layerOptions: {styleMap: styleMap}
> },
> eventListeners: {
> measure: function(evt) {
> Ext.MessageBox.show(
> {
> title: 'Flächenberechnung',
> buttons: Ext.MessageBox.OK,
> width: 200,
> msg: "Area: " + evt.measure.toFixed(2) + evt.units + "²",
> fn: check
> });
> }
> }
> }),
> map: map
> });
> actions["area"] = action;
>
>
> // Measure area control
> action = new GeoExt.Action({
> text: "Entfernung",
> toggleGroup: toggleGroup,
> group: toggleGroup,
> control: new OpenLayers.Control.Measure(OpenLayers.Handler.Path, {
> persist: false,
> handlerOptions: {
> layerOptions: {styleMap: styleMap}
> },
> eventListeners: {
> measure: function(evt) {
> Ext.MessageBox.show(
> {title: 'Flängenberechnung'
> ,buttons: Ext.MessageBox.OK
> ,width:200
> ,msg:"Länge: " + evt.measure.toFixed(2) + evt.units,
> fn: check
> });
> }
> }
> }),
> map: map
> });
> actions["Entfernung"] = action;
>
>
>
> toolbarItems.push({
> text: "",
> icon: '../images/ruler.png',
> tooltip: "Messwerkzeuge",
> toggleGroup: toggleGroup,
> menu: new Ext.menu.Menu({
>
> items: [
> new Ext.menu.CheckItem(actions["area"]),
> new Ext.menu.CheckItem(actions["line"])
>
> ]
>
> })
> });
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
More information about the Users
mailing list