wxml

<map
id="myMap"
style="width: {{mapWidth}}rpx; height: {{mapHeight}}rpx;" latitude="{{latitude}}"
longitude="{{longitude}}"
markers="{{markers}}"
show-location
bindmarkertap="selectMarket"
include-points="{{markers}}"
bindmarkertap="toaddress"
>
</map>

js

Page({

  /**
* 页面的初始数据
*/
data: { latitude: 24.4795100000,
longitude: 118.0894800000,
markers: [
{
id: 0,
latitude: 24.4455700000,
longitude: 118.0824000000,
// alpha:0,
callout:{
content: " 厦门思明区政府 \n 12000元/㎡",
padding:10,
display:'ALWAYS',
textAlign:'center',
// borderRadius: 10,
// borderColor:'#ff0000',
// borderWidth: 2,
} },
{
id: 1,
latitude: 24.5131500000,
longitude: 118.1468600000,
callout: {
content: " 厦门湖里区政府 \n 70000元/㎡",
padding: 10,
display: 'ALWAYS',
textAlign: 'center'
} },
{
id: 2,
latitude: 24.7235700000,
longitude: 118.1517300000,
callout: {
content: " 厦门市同安区政府 \n 100",
padding: 10,
display: 'ALWAYS',
textAlign: 'center'
} },
{
id: 3,
latitude: 24.5759000000,
longitude: 118.0972700000,
callout: {
content: " 厦门市集美区政府 \n 100",
padding: 10,
display: 'ALWAYS',
textAlign: 'center'
} },
{
id: 4,
latitude: 24.4846000000,
longitude: 118.0329300000,
callout: {
content: " 厦门市海沧区政府 \n 100",
padding: 10,
display: 'ALWAYS',
textAlign: 'center'
} },
{
id: 5,
latitude: 24.6196000000,
longitude: 118.2478900000,
callout: {
content: " 厦门市翔安区政府 \n 100",
padding: 10,
display: 'ALWAYS',
textAlign: 'center'
} },
],
mapWidth:'',
mapHeight:'' },
toaddress:function(e){
console.log(e)
var id =e.markerId
console.log(id)
// wx.openLocation({
// latitude: this.data.markers[id].latitude,
// longitude: this.data.markers[id].longitude,
// })
wx.navigateTo({
url: '/pages/index/index',
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
}, /**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
var sy = wx.getSystemInfoSync(),
mapWidth = sy.windowWidth*2,
mapHeight = sy.windowHeight*2;
this.setData({
mapWidth:mapWidth,
mapHeight:mapHeight
})
},

转: https://blog.csdn.net/weixin_42274835/article/details/81707972

小程序map地图上显示多个marker的更多相关文章

  1. 微信小程序map地图的一些使用注意事项

    1.小程序组件map,在微信7.0.4以上(不包括7.0.4)层级问题官方已作更新,可在map上随意添加任何标签使用z-index即可:微信7.0.4版本以下map组件层级默认是最高的,只能使用官方提 ...

  2. 小程序map地图多点定位

    最近需求有一个类似共享单车查看附近单车的功能,看了看小程序map api对多点定位显示描述的不怎么清晰.显示定位数组添加多个时就不显示了.踩了几个坑写了几个方法.最终弄出来了.有问题建议欢迎留言. h ...

  3. 微信小程序解决地图上的层级关系

    在有带地图的手机页面上,view无法显示在地图上方,所以,在wxml中,使用: <cover-view></cover-view> 能使view显示在地图上 注: 在该标签内部 ...

  4. 小程序map地图点击makert放大效果和点击放大地图

    WXML文件和JS文件代码在下方 <view class='map'> <map id="map" longitude="{{location.lng} ...

  5. 微信小程序----map组件实现检索【定位位置】周边的POI

    效果图 实现方法 地图采用微信小程序提供的map组件: 周边的数据坐标点通过高德地图提供的API接口,获取定位位置的周边或者指定位置周边的数据. WXML <view class="m ...

  6. 支付宝小程序室内地图导航开发-支付宝小程序JS加载esmap地图

    如果是微信小程序开发,请参考微信小程序室内地图导航开发-微信小程序JS加载esmap地图文章 一.在支付宝小程序里显示室内三维地图 需要满足的两个条件 调用ESMap室内地图需要用到小程序web-vi ...

  7. OpenLayers在地图上显示统计图,饼图线状图柱状图,修复统计图跳动的问题

    环境介绍 Openlayers ol.js v5.3.0 Highcharts highcharts.js v7.0.1 jquery jquery-3.3.1.js v3.3.1 显示效果 地图放大 ...

  8. 「小程序JAVA实战」小程序页面的上拉下拉刷新(50)

    转自:https://idig8.com/2018/09/21/xiaochengxujavashizhanxiaochengxuyemiandeshanglaxialashuaxin49/ 之前已经 ...

  9. 小程序实现图片上传,预览以及图片base64位处理

    最近一段时间在做小程序项目,第一期功也完工了.需要好好总结一下经验,把项目中遇到的问题好好总结一下,遇到的问题,踩过的坑.今天写一个小程序实现图片上传,预览,以及删除,图片base64位处理.下面就是 ...

随机推荐

  1. Python学习日记(十九) 模块导入

    模块导入 当文件夹中有这样一个自定义的command模块 在它的内部写下下列代码: print('这个py文件被调用!') def fuc(): print('这个函数被调用!') 然后我们在comm ...

  2. RestTemplate的GET与POST

    发送GET请求: //设置请求头HttpHeaders headers = new HttpHeaders(); headers.add("token",PostUtils.get ...

  3. django学习记录1

    在看django的基础知识,还是按照以前一样来总结,还是晚上再统一总结好了,边看边总结好像效果不大. 第一部分是生成数据库,用python manage.migrate命令来生成django的基础架构 ...

  4. mysql:[Err] 1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

    删除主键时,出错:[Err] 1075 - Incorrect table definition; there can be only one auto column and it must be d ...

  5. java安全相关知识

    基本概念 JVM:java虚拟机,Java编译程序将生成Java虚拟机上可运行的目标代码,使得Java程序可以再不同平台不加修改的运行.JVM包含完善的硬件架构,主要分为五大模块-类装载器子系统.运行 ...

  6. vue-cli3.0 脚手架搭建项目的过程详解

    1.安装vue-cli 3.0 ? 1 2 3 npm install -g @vue/cli # or yarn global add @vue/cli 安装成功后查看版本:vue -V(大写的V) ...

  7. typescript 参数类型

    1.参数类型:在参数名称后面使用冒号来指定参数的类型 var myname:string = 'wzn' => "use strict"; var myname = 'wzn ...

  8. webpack loader和插件的编写原理

    webpack自定义loader和插件的api网址:https://www.webpackjs.com/api/loaders/ 点击顶部API,看左侧api: 1. 如何编写一个loader 实现的 ...

  9. 多线程实现的方式二实现Rannable

    package thread; class Thread2 implements Runnable{ private String name; public Thread2(String name) ...

  10. C# 异步的简单用法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...