JavaScript class definition based on the Openlayer toolbar management class __java

Source: Internet
Author: User
Tags class definition

JavaScript class definition based on Openlayer toolbar management class

Mapcwgistoolbarclass.js

Define toolbar Management class//mapcwgistoolbarclass.js//VP:HSG//create date:2013-07-31//modify date:2013-08-01//define global variable var CmToolbar =
Null
Plug-in Call Method Cmtoolbar.additem (Plugincmdtool);
    Define the toolbar management class Mapcwgistoolbarclass = Openlayers.class ({//M_toolbaritems:null, Isscan:false,//initialization functions
        
    Initialize:function () {this.m_toolbaritems = [];
        },//Add Plug-in item additem:function (item) {if (item!= null) {This.m_ToolBarItems.push (item); },//anti-activating plug-in collection deactivateitems:function () {//Clear global Map event Mouse listener MapWrap.map.events.clearMou
        Selistener ();
        Reverse activates all global tools if (This.m_toolbaritems = null) return; For (var item in This.m_toolbaritems) {if (item!= null) {try {this.m_t
                Oolbaritems[item].dispose ();
            catch (e) {} this.m_toolbaritems[item].deactivate (); }},//Start scan STartscan:function () {This.isscan = true; Window.setinterval (' loopscanitemevent () ', 1000);
            1000 is 1 seconds, time can set itself},//cyclic scan Item Event Loopscanitemevent:function () {if (This.isscan = = True) {
                For (var item in This.m_toolbaritems) {if (This.isscan = = false) break;
                if (item!= null) {item.enabled;
        }},//Release class Dispose:function () {This.isscan = false;
        This.deactivateitems ();
        This.m_toolbaritems = null;
    OpenLayers.Class.prototype.destroy.apply (this, arguments);
},//class name class_name: "Mapcwgistoolbarclass"});

Instantiate a global toolbar admin class Cmtoolbar = new Mapcwgistoolbarclass (); Define plug-in command base class inherits from Openlayers.class (Openlayers.control)//base class abstract class name: Mapcwgisplugincommand Mapcwgisplugincommand =  Openlayers.class (Openlayers.control, {//define attribute Mapwrap:null,//define class initialization function init:function (P_mapcwgisclass)
   {     This.mapwrap = P_mapcwgisclass;
    This.setmap (THIS.MAPWRAP.MAP);
        }, Initialize:function (P_mapcwgisclass, Options) {this.init (p_mapcwgisclass); This.displayclass = this.

        Class_name.replace ("Openlayers.", "Ol"). Replace (/\./g, "");
        OpenLayers.Util.extend (this, options); this.events = new Openlayers.events (this, null, this.
        Event_types);
        if (this.eventlisteners instanceof Object) {this.events.on (this.eventlisteners); } if (this.id = = null) {this.id = OpenLayers.Util.createUniqueID (this.
        Class_name + "_");
    },///---------------------------------------------/** * method:activate * Activates the control.
    * * Returns: * {Boolean} The control is effectively activated. */Activate:function () {if (!this.active) {for (var i-this.handlers) {This
. Handlers[i].activate ();            } Return to OpenLayers.Control.prototype.activate.apply (this, arguments);
    },/** * method:deactivate * deactivates the control.
    * * Returns: * {Boolean} The control is effectively deactivated. */Deactivate:function () {if (this.active) {for (var i in this.handlers) {thi
            S.handlers[i].deactivate ();
    } Return to OpenLayers.Control.prototype.deactivate.apply (this, arguments);
    },//---------------------------------------------//Release class Dispose:function () {this.deactivate ();
        },//define Click event Onclick:function () {if (Cmtoolbar!= null) {Cmtoolbar.deactivateitems (); } this.activate ();

Activate control},//class name class_name: "Mapcwgisplugincommand"}); Define plug-in tool base class inherits from Openlayers.class (Mapcwgisplugincommand)//base class abstract class name: Mapcwgisplugintool MapcwgisplugiNtool = Openlayers.class (Mapcwgisplugincommand, {//Definition attribute layer:null, Callbacks:null, Multi:false, H 
        Andleroptions:null, Handlerclass:null,//define class initialization function initialize:function (p_mapcwgisclass,handler,options) {
        This.init (P_mapcwgisclass);
        Define the handle mouse event base Object (dots)/Line/face etc ... this.handlerclass = handler;
        var handlerabsclass = This.handlerclass;
        This.handleroptions = Handlerabsclass;
        Initializes the initialization method of the base class Openlayers.control OpenLayers.Control.prototype.initialize.apply (this, [this.handleroptions]); Defines a callback function this.callbacks = OpenLayers.Util.extend ({done:function (geometry) {} , Modify:function (vertex, feature) {}, Create:function (vertex, Featur
        e) {}}, this.callbacks); if (this.mapWrap.vlayer_drawFeature = = null) {THIS.MAPWRAP.VLAYer_drawfeature = new OpenLayers.Layer.Vector ();
        This.mapWrap.map.addLayer (this.mapWrap.vlayer_drawFeature);
        //Define a temporarily drawn layer This.layer = this.mapWrap.vlayer_drawFeature; This.handleroptions =openlayers.handler.point;//This.handleroptions | |
        {}; if (! ()
        Multi "in This.handleroptions") {this.handlerOptions.multi = This.multi; var sketchstyle = This.layer.styleMap && this.layer.styleMap.styles.select;
        . Temporary; if (sketchstyle) {this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults (this.hand
        Leroptions.layeroptions, {stylemap:new openlayers.stylemap ({"Default": Sketchstyle})});
    }//define handle mouse Event Base Object This.handler = new Handlerabsclass (this, this.callbacks, this.handleroptions); //define Mouse Handling Events collection//define mouse press event Onmouseup:function (e) {},//define mouse down event onmousedown:function(e) {},//define mouse Move event Onmousemove:function (e) {},//define mouse double-click event Ondoubleclick:function (e) {},        
        Define right-click event Onrightclick:function (E) {},//release class mouse movement event dispose:function () {//
        This.layer.destroyFeatures ();
        This.layer.redraw ();
        Selected block clearance Operation//this.mapwrap.layer_highlight.destroyfeatures ();
        This.mapWrap.layer_Highlight.redraw ();
        Anti-registration Mouse press on event MouseUp this.mapWrap.map.events.unregister ("MouseUp", This.mapWrap.map, This.onmouseup);
        Anti-Registration Mouse press event MouseDown this.mapWrap.map.events.unregister ("MouseDown", This.mapWrap.map, This.onmousedown); 
        Anti-registration Mouse movement Event MouseMove this.mapWrap.map.events.unregister ("MouseMove", This.mapWrap.map, This.onmousemove); Anti-register mouse double click event DblClick this.mapWrap.map.events.unregister ("DblClick", This.mapWrap.map, This.ondoubleclick)
        ; Reverse-Register the right mouse click event RightClick THIS.MAPWRAP.MAP.EVENTS.UNREgister ("RightClick", This.mapWrap.map, This.onrightclick);
    This.deactivate ();
        },//define Click event Onclick:function () {if (Cmtoolbar!= null) {Cmtoolbar.deactivateitems ();
        }//Initialize event processing object var handlerabsclass = This.handlerclass;
        This.handleroptions = Handlerabsclass;
        This.handler = new Handlerabsclass (this, this.callbacks, this.handleroptions);
        Register Mouse Press on event MouseUp this.mapWrap.map.events.unregister ("MouseUp", This.mapWrap.map, This.onmouseup);
        This.mapWrap.map.events.register ("MouseUp", This.mapWrap.map, This.onmouseup);
        Register Mouse Press event MouseDown this.mapWrap.map.events.unregister ("MouseDown", This.mapWrap.map, This.onmousedown);
        This.mapWrap.map.events.register ("MouseDown", This.mapWrap.map, This.onmousedown);
        Registered Mouse Movement Event MouseMove this.mapWrap.map.events.unregister ("MouseMove", This.mapWrap.map, This.onmousemove); This.mapwraP.map.events.register ("MouseMove", This.mapWrap.map, This.onmousemove);
        Register mouse Double click event DblClick this.mapWrap.map.events.unregister ("DblClick", This.mapWrap.map, This.ondoubleclick);
        This.mapWrap.map.events.register ("DblClick", This.mapWrap.map, This.ondoubleclick);
        Register the right mouse click event RightClick this.mapWrap.map.events.unregister ("RightClick", This.mapWrap.map, This.onrightclick);
        This.mapWrap.map.events.register ("RightClick", This.mapWrap.map, This.onrightclick); This.activate ();

Activate control},//class name class_name: "Mapcwgisplugintool"});
        Define map Translation Plug-in command function mapcwgismappancmd = Openlayers.class (Mapcwgisplugincommand, {//define Click event Onclick:function () {
        if (Cmtoolbar!= null) {Cmtoolbar.deactivateitems ();
    }//Activate control this.activate ();
}, Class_name: "Mapcwgismappancmd"//});
Map Translation tool var mappancmd = new Mapcwgismappancmd (mapwrap); Register if (Cmtoolbar!= to the Global toolbar Management Class)NULL) {Cmtoolbar.additem (mappancmd);}//--//define Map Full Screen plug-in command function Mapcwgismapfullextentcmd = Openlayers.class (mapcwgisplu Gincommand, {//define Click event Onclick:function () {if (Cmtoolbar!= null) {Cmtoolbar.deactivateite
        MS ();
        } if (This.mapWrap.map) {this.mapWrap.map.zoomToMaxExtent ();
    }//Activate control this.activate ();
}, Class_name: "Mapcwgismapfullextentcmd"//});
Map Full-screen Display tool var mapfullextentcmd = new Mapcwgismapfullextentcmd (mapwrap); Manage class registration to global toolbar if (Cmtoolbar!= null) {Cmtoolbar.additem (mapfullextentcmd);}//--



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.