map地图效果  官方文档:传送门

  1. Page({
  2. data: {
  3. markers: [{
  4. iconPath: "/resources/others.png",
  5. id: 0,
  6. latitude: 23.099994,
  7. longitude: 113.324520,
  8. width: 50,
  9. height: 50
  10. }],
  11. polyline: [{
  12. points: [{
  13. longitude: 113.3245211,
  14. latitude: 23.10229
  15. }, {
  16. longitude: 113.324520,
  17. latitude: 23.21229
  18. }],
  19. color: "#FF0000DD",
  20. width: 2,
  21. dottedLine: true
  22. }],
  23. controls: [{
  24. id: 1,
  25. iconPath: '/resources/location.png',
  26. position: {
  27. left: 0,
  28. top: 300 - 50,
  29. width: 50,
  30. height: 50
  31. },
  32. clickable: true
  33. }]
  34. },
  35. regionchange(e) {
  36. console.log(e.type)
  37. },
  38. markertap(e) {
  39. console.log(e.markerId)
  40. },
  41. controltap(e) {
  42. console.log(e.controlId)
  43. }
  44. })

test.js

  1. Gary 微信小程序
  2. <map id="map" longitude="113.324520" latitude="23.099994" scale="14" controls="{{controls}}" bindcontroltap="controltap" markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" bindregionchange="regionchange" show-location style="width: 100%; height: 400px;">
  3. </map>

test.wxml

  1. {
  2. "pages":[
  3. "pages/test/test",
  4. "pages/index/index",
  5. "pages/logs/logs"
  6. ],
  7. "window":{
  8. "backgroundTextStyle":"light",
  9. "navigationBarBackgroundColor": "#fff",
  10. "navigationBarTitleText": "WeChat",
  11. "navigationBarTextStyle":"black"
  12. }
  13. }

app.json

实现过程

  添加map地图组件

  1. <map id="map" longitude="113.324520" latitude="23.099994" scale="14" controls="{{controls}}" bindcontroltap="controltap" markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" bindregionchange="regionchange" show-location style="width: 100%; height: 400px;">
  2. </map>

  

   id:在控件点击事件回调会返回此id
      markers标记点用于在地图上显示标记的位置

        longitude :经度

          latitude: 纬度
   scale:缩放级别,取值范围为5-18
   controls:控件名称
   bindcontroltap: 点击控件时触发,会返回control的id
   markers:标记点
   bindmarkertap:点击标记点时触发,会返回marker的id
   polyline:路线
   bindregionchange: 视野发生变化时触发
   show-location:显示带有方向的当前定位点

  

  初始化地图路线、路线

  1. data: {
  2. markers: [{
  3. iconPath: "/resources/others.png",
  4. id: 0,
  5. latitude: 23.099994,
  6. longitude: 113.324520,
  7. width: 50,
  8. height: 50
  9. }],
  10. polyline: [{
  11. points: [{
  12. longitude: 113.3245211,
  13. latitude: 23.10229
  14. }, {
  15. longitude: 113.324520,
  16. latitude: 23.21229
  17. }],
  18. color: "#FF0000DD",
  19. width: 2,
  20. dottedLine: true
  21. }],
  22. controls: [{
  23. id: 1,
  24. iconPath: '/resources/location.png',
  25. position: {
  26. left: 0,
  27. top: 300 - 50,
  28. width: 50,
  29. height: 50
  30. },
  31. clickable: true
  32. }]
  33. },

微信小程序_(map)简单的小地图的更多相关文章

  1. 微信小程序_(视图)简单的swiper容器

    swiper容器效果 官方文档:传送门 swiper容器可实现简单的轮播图效果 结构程序 Page({ /** * 页面的初始数据 */ data: { }, /** * 生命周期函数--监听页面加载 ...

  2. 微信小程序_(视图)简单的scroll-view容器

    scroll-view容器效果 官方文档:传送门 scroll-view 可滚动视图区域 scroll-x Boolean false 允许横向滚动 scroll-y Boolean false 允许 ...

  3. 微信小程序_(案例)简单中国天气网首页

    Demo:简单中国天气网首页 Page({ data:{ name:"CynicalGary", temp:"4", low:"-1°C", ...

  4. 微信小程序_(校园视)开发用户注册登陆

    微信小程序_(校园视) 开发用户注册登陆 传送门 微信小程序_(校园视) 开发上传视频业务 传送门 微信小程序_(校园视) 开发视频的展示页-上 传送门 微信小程序_(校园视) 开发视频的展示页-下 ...

  5. 微信小程序 wxs的简单应用

    Demo地址:微信小程序wxs的简单应用 案例分析 张三.李四.王五,各自分别都有数量不等的车,现在需要列表显示名字及他们拥有车的数量, list数据结构如下,当我们使用wx:for进行显示时,发现个 ...

  6. 微信小程序_(校园视)开发视频的展示页_下

    微信小程序_(校园视) 开发用户注册登陆 传送门 微信小程序_(校园视) 开发上传视频业务 传送门 微信小程序_(校园视) 开发视频的展示页-上 传送门 微信小程序_(校园视) 开发视频的展示页-下 ...

  7. 微信小程序_(校园视)开发上传视频业务

    微信小程序_(校园视) 开发用户注册登陆 传送门 微信小程序_(校园视) 开发上传视频业务 传送门 微信小程序_(校园视) 开发视频的展示页-上 传送门 微信小程序_(校园视) 开发视频的展示页-下 ...

  8. 微信小程序_(校园视)开发视频的展示页_上

    微信小程序_(校园视) 开发用户注册登陆 传送门 微信小程序_(校园视) 开发上传视频业务 传送门 微信小程序_(校园视) 开发视频的展示页-上 传送门 微信小程序_(校园视) 开发视频的展示页-下 ...

  9. 微信小程序_简单组件使用与数据绑定

    简单的数据传值 官方文档:传送门 点击"按钮"测试后,按钮文本改变,下方text文本改变,通过console.log()在输出台中打印按钮文本信息 程序结构 Page({ //页面 ...

随机推荐

  1. leetcode中等题

    # Title Solution Acceptance Difficulty Frequency     1 Two Sum       44.5% Easy     2 Add Two Number ...

  2. GoAccess操作手册

    名字 GoAccess - 可视化 Web 日志分析工具. 语法 goaccess [filename] [ options ... ] [-c][-M][-H][-q][-d][...] 描述 Go ...

  3. MySQL性能优化(二):优化数据库的设计

    原文:MySQL性能优化(二):优化数据库的设计 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.n ...

  4. 剑指offer-构建乘积数组-数组-python

    题目描述 给定一个数组A[0,1,...,n-1],请构建一个数组B[0,1,...,n-1],其中B中的元素B[i]=A[0]*A[1]*...*A[i-1]*A[i+1]*...*A[n-1].不 ...

  5. windows下一步到位搭建pycharm的开发环境

    pycharm的开发环境主要涉及到以下三个方面 pycharm的激活 这里采用破解的方式来达到永久激活的目的,因为激活码用着用着就过期的你,会发现不厌其烦的 通过测试,这个破解包适用于2017-201 ...

  6. SQL学习(二)之四大查询语句以及标准写法

    SQL四大查询语句——增删改查 增-INSERT INSERT INTO 表 (字段列表) VALUES(值列表) INSERT INTO `user_table` (`ID`, `username` ...

  7. 098、Swarm 如何实现 Failover (Swarm05)

    参考https://www.cnblogs.com/CloudMan6/p/7898245.html   故障是在所难免的,容器可能崩溃,Docker Host 可能宕机,不过幸运的是,Swarm 已 ...

  8. springboot的一些注解

    springboot注解以及一些晦涩难理解的点介绍 @Validated 用于注入数值校验的注解(JSR303数据校验) @PropertySource 用于加载指定的配置文件,例如@Property ...

  9. Axure(一)

    axure1.原型工具 2.软件开发 1.可行性分析2.需求分析    产品经理(和甲方对接需求,)    乙方     --   甲方 ps(专业性强,精美)  设计师        html(可变 ...

  10. 转载:JavaWeb 文件上传下载

    转自:https://www.cnblogs.com/aaron911/p/7797877.html 1. 文件上传下载概述 1.1. 什么是文件上传下载 所谓文件上传下载就是将本地文件上传到服务器端 ...