<template>
  <div>
     <!--<amap :singlepoint="single" :outerlinedata="data" :points="points"> </amap>-->
    <div id="containerr"></div>
  </div>
</template>

<script>
  export default {
    title: "地图",
    data(){
      return {
        curuser:{},
        // points: {url:"api/af-revenue/sql/getAllCurrentPosition",data: {subcompany:this.$login.f.f_fengongsi}},
        single:{},
        data:[],
        // url:'api/af-revenue/logic/FetchFootprint',
        // f_fengongsi:this.$login.f.f_fengongsi
      }
    },
    methods:{
      getData(val){
        this.data = val
      },
      // select选中
      onComplete(data) {
        console.log('定位成功')
      },
      //解析定位错误信息
      onError(data) {
        console.log('失败原因排查信息:' + data.message)
      },
    },
    ready(){
      //  初始化地图
      this.map = new AMap.Map("containerr", {
        resizeEnable: true,
        scrollWheel: false,
        zoom: 7,
        mapStyle: "amap://styles/blue"
      });

      // this.map.setMapStyle('amap://styles/blue');
      // this.changeType()
      console.log("地图加载正常");
      var thisp = this;
      // 异步加载插件
      AMap.plugin(
        [
          "AMap.ToolBar",
          "AMap.PlaceSearch",
          "AMap.Driving",
          "AMap.Geolocation"
        ],
        () => {
          // 工具条，控制地图的缩放、平移等
          var geolocation = new AMap.Geolocation({
            // 是否使用高精度定位，默认：true
            enableHighAccuracy: true,
            // 设置定位超时时间，默认：无穷大
            showButton: false,
            //控制按钮的显示
            // timeout: 10000,
            // 定位按钮的停靠位置的偏移量，默认：Pixel(10, 20)
            // buttonOffset: new AMap.Pixel(-10, -20),
            //  定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            zoomToAccuracy: true,
            //  定位按钮的排放位置,  RB表示右下
            // buttonPosition: 'LB'
          })
          this.map.addControl(geolocation);
          geolocation.getCurrentPosition(function (status, result) {
            if (status == 'complete') {
              thisp.onComplete(result)
            } else {
              thisp.onError(result)
            }
          });
          this.map.addControl(new AMap.ToolBar());
        }
      );

    }

  }
</script>
