加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

微信小程序 - 多地点标识(map)

发布时间:2020-12-14 19:36:38 所属栏目:资源 来源:网络整理
导读:演示如下: wxml 1 map id = "map" scale "{{scale}}" controls "{{controls}}" bindcontroltap "controltap" markers "{{markers}}" bindmarkertap "markertap" bindregionchange "regionchange" show - location style "width: 100%; height: 580px;" / ma

演示如下:

wxml

  1. 1 <map id="map" scale"{{scale}}" controls"{{controls}}" bindcontroltap"controltap" markers"{{markers}}" bindmarkertap"markertap" bindregionchange"regionchange" show-location style"width: 100%; height: 580px;"></map>

js

   let hospitalData =require('hospitalData')
  • 3 data:{
  • 5 centerY7 scale:159 controls[{
  • 11 iconPath '/image/location-control.png'13 left017 },102);">18 clickabletrue
  • 20 21 onReadyfunction(e){
  • 23 this.mapCtx wxcreateMapContext'myMap')
  • 26 onLoad(){
  • )
  • 29 wxgetLocation({
  • //返回可以用于wx.openLocation的经纬度
  • 33 longitude longitude;
  • 35setData({
  • 37 centerY latitude38 markersgetHospitalMarkers()
  • 40}
  • 4244 /**
  • 45 * 标示点移动触发
  • 47 regionchange{
  • 4951/**
  • 53 */
  • 55)
  • 58/**
  • 60 */
  • 63moveToLocation()
  • 67/**
  • 69 */
  • 71 markers [];
  • 74 markerspushmarker)
  • 76return;
  • 79/**
  • 81 */
  • 85868788 89 * 还有地图标识,可以在name上面动手
  • 91 createMarkerpoint92 point939495"/image/location.png"96id ||97 namename ''98 latitude99 longitude100 width25101 height48
  • 103 marker104}
  • hospitalData.js (模拟数据)

         "id""name""永州市中心医院""longitude""111.62852107566833""latitude""26.42142999357519"
  • }
  • 运行示例时,建议放在同一目录下.

    (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    • 推荐文章
        热点阅读