zoukankan      html  css  js  c++  java
  • vue-amap详细使用教程

    在antd pro内使用vue-amap,实现地图和坐标点。

    1,安装

    npm install vue-amap --save

    2,在main,js内引入

    import VueAMap from 'vue-amap';
    
    Vue.use(VueAMap);
    VueAMap.initAMapApiLoader({
      key: 'YOUR_KEY',
      plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
      v: '1.4.4'
    });

    3.在vue中使用,template

    <template>
      <div id="app">
        <div class="amap-wrapper">
          <el-amap
            ref="map"
            :vid="'amapDemo'"
            :center="center"
            :zoom="zoom"
            :plugin="plugin"
            :events="events"
            class="amap-demo"
          >
            <el-amap-marker v-for="u in markers" :position="u.position"></el-amap-marker>
            <el-amap-marker :position="[121.5273285, 31.21515044]" :icon="icon"></el-amap-marker>
          </el-amap>
        </div>
      </div>
    </template>

    script

    <script>
    export default {
      data() {
        return {
          center: [121.5273285, 31.21515044],
          zoom: 12,
          position: [121.5273285, 31.21515044],
          icon: '/huoche.png',
          events: {
            init(o){
              console.log(o.getCenter());
            },
            zoomchange: (e) => {
                console.log(e);
            },  
            zoomend: (e) => {
            //获取当前缩放zoom值 console.log(
    this.$refs.map.$$getInstance().getZoom()); console.log(e); }, click: e => { alert('map clicked') } }, markers: [ { position: [121.5273285, 31.41515044] }, { position: [121.5273286, 31.31515045] } ],
    //使用其他组件 plugin: [ { pName:
    'Scale', events: { init(instance) { console.log(instance) } } }, { pName: 'ToolBar', events: { init(instance) { console.log(instance) } } } ] } }, } </script>
  • 相关阅读:
    继承
    包、logging模块、hashlib模块、openpyxl模块、深浅拷贝
    Java中的Lambda表达式
    Java中udp/tcp的发送和接收
    Java中的IO流总结
    Java中的多线程
    Java中使用try-catch-finally处理IO流中的异常
    Java中的杂流(闸总)
    Java中的Properties
    Java中IO流之字符流
  • 原文地址:https://www.cnblogs.com/blog-zy/p/11504683.html
Copyright © 2011-2022 走看看