zoukankan      html  css  js  c++  java
  • 前端随心记---------小程序地图map组件应用

     简单实现小程序地图

      官方文档:https://developers.weixin.qq.com/miniprogram/dev/component/map.html

      map.wxml:

    <view>
        <map id="map" longitude="{{获取的坐标}}" latitude="{{获取的坐标}}" scale="14" show-location style=" 100%; height: 300px;">
    </map>
    </view>

      map.js:

    Page({
      data: {
        markers: [{
          iconPath: "/resources/others.png",
          id: 0,
          latitude: 23.099994,
          longitude: 113.324520,
           50,
          height: 50
        }],
        polyline: [{
          points: [{
            longitude: 113.3245211,
            latitude: 23.10229
          }, {
            longitude: 113.324520,
            latitude: 23.21229
          }],
          color:"#FF0000DD",
           2,
          dottedLine: true
        }],
        controls: [{
          id: 1,
          iconPath: '/resources/location.png',
          position: {
            left: 0,
            top: 300 - 50,
             50,
            height: 50
          },
          clickable: true
        }]
      },
      regionchange(e) {
        console.log(e.type)
      },
      markertap(e) {
        console.log(e.markerId)
      },
      controltap(e) {
        console.log(e.controlId)
      }
    })

     由于map应用需要获取个人信息,需要设置信息

    “permission”:{
         “scope.userLocation”:{
             “desc”:“你的位置将用于小程序地图展示”  //描述信息
        }    
    }

     在页面加载时,调用获取地理位置API

    wx.getLocation({
     type: 'wgs84',
     success (res) {
       const latitude = res.latitude
       const longitude = res.longitude
       const speed = res.speed
       const accuracy = res.accuracy
     }
    })

    关于分辨率rpx

    集思广益,仅供学习,侵权即删!!
  • 相关阅读:
    MySQL--CREATE INDEX在各版本的优化
    MySQL--各版本DDL 操作总结
    MySQL--事务隔离级别RR和RC的异同
    MySQL--运维内参中的binlog_summary脚本
    认知:人性
    诉衷情
    初中生读物
    DTO和Entity转换
    layui开发常用插件列表
    mongodb配置
  • 原文地址:https://www.cnblogs.com/hudunyu/p/11983477.html
Copyright © 2011-2022 走看看