微信小程序之地图功能

本文详细介绍了微信小程序中地图模块的使用,包括markers、polyline、circles、controls的添加和事件绑定,以及遇到的经纬度类型问题。此外,还对比了百度、高德和腾讯地图API在小程序中的应用。
摘要由CSDN通过智能技术生成

转载请注明出处:http://blog.csdn.net/crazy1235/article/details/55004841


本篇blog主要介绍微信小程序中的地图模块相关功能。

基本使用

地图组件使用起来也很简单。

.wxml

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

参数列表及说明如下:

这里写图片描述

除了显示基本地图,还可以在地图上添加markers–标注,polyline–折线,circles–圆形,controls–控件。

markers

这里写图片描述

data: {
    //
    markers: [{
      iconPath: "../../img/marker_red.png",
      id: 0,
      latitude: 40.002607,
      longitude: 116.487847,
      width: 35,
      height: 45
    }],
    ... //省略代码
    }

在data中定义markers变量来表示覆盖物

然后map控件引入即可:

<map id="map" longitude="{
   {longitude}}"  markers="{
   {markers}}" style="width: 100%; height: 350px;" ...//省略代码>
</map> 

效果如下:

  • 28
    点赞
  • 197
    收藏
    觉得还不错? 一键收藏
  • 22
    评论
评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值