<!--
 
   高德地图组件
   
   @author zhouhan
   @email : zhouhan102@163.com
   @date 2019/3/11 2:13 PM
   @example 
        <e-map></e-map>
 -->

<template>


    <div class="eye-map">
        <el-amap ref="map"
                 vid="eMap"
                 :amap-manager="amapManager"
                 :center="center"
                 :zoom="zoom"
                 :plugin="plugin"
                 :events="mapEvents"
                 class="eye-map__container">
            <slot></slot>
        </el-amap>
    </div>


</template>

<script>

    import VueAMap from 'vue-amap';
    import { AMapManager } from 'vue-amap';
    //import { lazyAMapApiLoaderInstance } from 'vue-amap';
    const amapManager = new VueAMap.AMapManager();
    export default {

        name: "e-map",

        components: {},

        props: {

            /**
             * 地图中心位置
             */
            center: {
                type:Array,
                default: n => {
                    return [
                        121.59996, 31.197646
                    ]
                }
            },

            zoom: {
                type: Number,
                default: 12
            },

            mapEvents: {
                type: Object,
                default: n => {

                    return {
                        // mapmove : function (e) {
                        //     let res = this.getCenter();
                        //     console.log('center',res.lng,res.lat)
                        // }
                    }
                }
            }
        },

        data: function() {
            return {
                amapManager,
                plugin: [
                    'ToolBar',
                    {
                        pName: 'Scale',
                        defaultType: 0,
                        events: {
                            init(o) {
                            }
                        }
                    },
                    // {
                    //     pName: 'Geolocation',
                    //     events: {
                    //         init(o) {
                    //             o.getCurrentPosition((status, result) => {
                    //                 console.log('getCurrentPosition',result)
                    //             });
                    //         }
                    //     }
                    // },
                ]
            };
        },

        mounted() {

        },

        methods: {},

        computed: {},

        watch: {}
    }
</script>

<style scoped>
    .amap-demo {
        height: 300px;
    }
</style>