Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify of 'scaleCtrl' #3

Closed
xiabin1235910 opened this issue Jun 3, 2016 · 6 comments
Closed

Modify of 'scaleCtrl' #3

xiabin1235910 opened this issue Jun 3, 2016 · 6 comments

Comments

@xiabin1235910
Copy link

xiabin1235910 commented Jun 3, 2016

I make some new features to the code. For example,

First, scaleCtrl boolean --> Object

this.opts = {
            center: {
                longitude: 121.60399778,
                latitude: 31.2109038
            },
            zoom: 15,
            navCtrl: true,
            scaleCtrl: {
                width: 5,
                height: 40
            },
            overviewCtrl: true,
            enableScrollWheelZoom: true
        };

Second, scaleCtrl boolean --> any

export interface MapDefaultOptions {
    navCtrl?: boolean;
    scaleCtrl?: any;
    overviewCtrl?: boolean;
    enableScrollWheelZoom?: boolean;
    zoom?: number;
}

Third, add offset to scale control.

const createInstance = function(opts: MapOptions, element: any) {
    if (opts.scaleCtrl) {
        // add scale control
        map.addControl(new BMap.ScaleControl({offset: new BMap.Size(opts.scaleCtrl.width, opts.scaleCtrl.height)}));
    }
    if (opts.overviewCtrl) {
        //add overview map control
        // default --- BMAP_ANCHOR_BOTTOM_RIGHT
        map.addControl(new BMap.OverviewMapControl({isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT}));
    }
    return map;
};

Finally, about the overviewCtrl
I think that we may add some extension of it.
For example,

this.opts:{
    overviewCtrl: 'bottom-right'  // maybe contains other position information
}

So we can dynamically identify the position of overview.
But now I just make it static...

Do you have any good recommendation? Thank you.

@xiabin1235910
Copy link
Author

The new feature 'geolocationCtrl' may resolve the extension of 'overviewCtrl'.

@leftstick
Copy link
Owner

Sorry, I don't have time to go through all your comments, you mean the newly added feature geolocationCtrl solved your problem?

@xiabin1235910
Copy link
Author

I mean how to define the 'offset, anchor' in scaleCtrl ?

Please refer to the url below.
http://developer.baidu.com/map/reference/index.php?title=Class:%E6%8E%A7%E4%BB%B6%E7%B1%BB/ScaleControlOptions

I just provide an example for the angular2-baidu-map module.

@leftstick
Copy link
Owner

OK, i see, you'd like to have a an options for overviewCtrl just like what i have done for geolocationCtrl?

Sounds nice, i will do the refactor once i got time. Thanks for clarification

@xiabin1235910
Copy link
Author

Yeah, I think the 'boolean | Interface' is much better than 'any', but just a little complicated...

@leftstick
Copy link
Owner

Please upgrade to 2.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants