[OpenLayers-Users] Control Panel Multiple Tools with different icons

Andrew de Klerk andrew.deklerk at gmail.com
Thu Dec 6 15:45:49 EST 2007


Hi all

 

I will try and explain my problem as best as I can without confusing you. I
have searched the forum's but have not found a solution to my problem. I am
trying to implement a toolbar using the control Panel. My toolbar will
contain the following tools:

Zoom Extent

ZoomBox

Pan

Select feature

Delete Feature

Measure

Draw Point

Draw polygon

Draw Line

 

The measure tool will be implemented using the "DrawFeaturePath" and the
Delete feature using the "SelectFeature". I can successfully assign the
appropriate function to each tool, but cannot seem to get it right in
assigning an appropriate icon through the stylesheet - i.e Measure icon
always defaults to the DrawFeaturePathItemActive/Inactive icons regardless
of trying to assign it different classes. 

 

What do I need to do to assign it a different icon? Also, How do you assign
the default control to your panel? I think my syntax must be incorrect below
for "defaultControl".  Below is my code I have implemented:

___________________________________________________

  var  zb = new OpenLayers.Control.ZoomBox({title: "Zoom Box: Selecting it
you can zoom on an area by clicking and draging"});

  var panel = new OpenLayers.Control.Panel({div:$('panel')},{defaultControl:
zb,'displayClass': 'olControlPanel'}); 

  var select = new OpenLayers.Control.SelectFeature(vlayer,{onSelect:
onFeatureSelect, handlerOptions: {'displayClass': 'olControlSelectFeature'
}});

  var mt = new OpenLayers.Control.DrawFeature(vlayer,
OpenLayers.Handler.Path, 

  {featureAdded: ShowMeasureDistance,handlerOptions: {'freehand': false},
'displayClass': 'MeasureTool'});

   // Add a multi-point polygon drawing tool tip container 

  var dply = new OpenLayers.Control.DrawFeature(vlayer,
OpenLayers.Handler.Polygon, 

  {featureAdded: handleFeatureAdded,handlerOptions: {'freehand': false},
'displayClass': 'olControlDrawFeaturePolygon'}); 

   // Add a multi-point line drawing tool tip container 

  var df = new OpenLayers.Control.DrawFeature(vlayer,
OpenLayers.Handler.Path, 

  {featureAdded: handleFeatureAdded,handlerOptions: {'freehand': false},
'displayClass': 'olControlDrawFeaturePath'});  

   // Add a single point drawing tool tip container 

   var dp = new OpenLayers.Control.DrawFeature(vlayer,
OpenLayers.Handler.Point, 

   {featureAdded: handleFeatureAdded,handlerOptions: {'freehand': false},
'displayClass': 'olControlDrawFeaturePoint'});

  //add selecttodelete tool

  var seldel = new OpenLayers.Control.SelectFeature(vlayer,{onSelect:
onFeatureSelectDelete, handlerOptions: {'displayClass': 'DeleteTool' }})

 

  panel.addControls([ new OpenLayers.Control.ZoomToMaxExtent(),new
OpenLayers.Control.Navigation(), zb, select,mt,dply,df,dp,seldel ]); 

  //add panel to map 

  map.addControl(panel);

___________________________________________________

 

I hope that all makes sense

 

Regards

Andrew

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20071206/cdd43758/attachment.html


More information about the Users mailing list