[OpenLayers-Users] erase drawn features

Christopher Schmidt crschmidt at metacarta.com
Wed Apr 18 17:12:20 EDT 2007


On Wed, Apr 18, 2007 at 01:48:16PM -0700, Mike Quentel wrote:
> So, attaching an erase drawing features function to an onclick event of an icon (outside of the OL API) was simple, but how might I actually turn this into an OL control?  This is supposed to erase all drawn features upon the user clicking a button.  Would I need to implement a class that inherits from OpenLayers.Control?  Here is what I started...

For Controls which perform a single action,
http://openlayers.org/dev/lib/OpenLayers/Control/ZoomToMaxExtent.js is
probably a good starting point. (note the TYPE_BUTTON, rather than
type_toggle).

Panel drawing is controlled via CSS:
http://openlayers.org/dev/examples/panel.html is a good example of some
useful CSS, specifically: 

        .olControlPanel div { 
          display:block;
          width:  24px;
          height: 24px;
          margin: 5px;
          background-color:red;
        }

combined with:

        .olControlPanel .olControlYourNameHereInactive { 
          width:  18px;  
          height: 18px;
          background-image: url("../img/my-control-icon.png");
        }

If you read the CSS and  code there, combined with the ZoomToMaxExtent
control, you should be in good shape.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list