billy-poon / echarts-amap

an echarts extension to support AMap(http://lbs.amap.com/)
MIT License
60 stars 31 forks source link

How to access amap instance? #5

Closed jeange1003 closed 6 years ago

jeange1003 commented 6 years ago

In amap official example, to use a plugin, an access to map instance is needed.

    var map = new AMap.Map('container',{
            resizeEnable: true,
            zoom: 10,
            center: [116.480983, 40.0958]
    });
    AMap.plugin(['AMap.ToolBar','AMap.Scale'],function(){
        var toolBar = new AMap.ToolBar();
        var scale = new AMap.Scale();
        map.addControl(toolBar);
        map.addControl(scale);
    })

how to access it in echarts-amap?

dfEric commented 6 years ago
var map = echart.getModel().getComponent('amap').getAMap();

You can find the code in index.html

jeange1003 commented 6 years ago

@dfEric thank you