[OpenLayers-Users] How do I separate OpenLayers methods from my own, while using inheritance?

João Rodrigues joaorodr84 at gmail.com
Wed Aug 6 07:25:10 PDT 2014


Hi, everyone!

I am working on a GIS API, that uses OpenLayers. I initialize the map lke
this:


    xgis.map = OpenLayers.Class(OpenLayers.Map, {
        var mapOptions = {};
        mapOptions.allOverlays = false;
        /*
            more mapOptions here
        */
        OpenLayers.Map.prototype.initialize.apply(this, ['map',
mapOptions]);
    });

Of course, I do this because I want to create my own methods, like this
one, for example.

    xgis.map.prototype.zoom(action) {
        switch(action) {
            case 'in:
                this.zoomIn();    // Uses the OpenLayers zoomIn method
                break;
            case 'out:
                this.zoomOut();    // Uses the OpenLayers zoomOut method
                break;
    };

The problem is this 'zoom' method I created is not recognized as a function
(I get: number is not a function), because OpenLayers has a 'zoom' numeric
value where it stores the zoom.

Is there a way to use inheritance and access the parent's methods like this?

    this.parent.zoomIn()

This would definitely fix the 'zoom' name problem.

Thanks.

João Rodrigues
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140806/64189d37/attachment.html>


More information about the Users mailing list