微信小程序开发学习之--地图绘制行政区域图

不知道大家有没有感觉就是在做微信小程序地图功能时刚刚接触时候真的感觉好迷茫呀,文档看不懂,资料找不到,就很难受呀,比如我现在的功能就想想绘制出一个区域的轮廓图,主要是为了显眼,效果图如下:就是绘画出北京的轮廓图,蛋黄酥一样的这块。说清楚了我功能之后就开始说怎么实现了(源码码估计会放在程序的最后一段)。

开发思路

1.首先查看官方文档(点进去看就可以了好多配置,不一一细说)

微信小程序地图开发文档

2.看了官方文档后我还是不知道怎么弄,但是我确定用“polygon”这个东西来绘画出轮廓,这个参数大概的意思就是指定一系列坐标点,根据 points 坐标数据生成闭合多边形,我理解的意思就是你要用很多点,用点成线的形式在地图上描点。出线。

3.知道怎么绘画出轮廓之后,又迷茫了我怎么才能得到点,百度很久后有个大神给出方案

数据可视化平台 点进去看到自己想要的城市,导出点,把点加工下,得到轮廓数据,比如我是用的北京的\后期贴代码上来,直接看就ok。

4.有数据 后就开始写代码,直接上代码 (源码地址就在下一行)微信小程序绘制行政区轮廓图小程序: 用微信小程序内部的map来绘制行政区轮廓范围

(1)html 代码,很简单没啥子东西,就配置配置参数,不懂的话就去看官方文档

<map id="mapId"class="map"latitude="{{latitude}}"longitude="{{longitude}}"bindmarkertap="onMarkerTap"bindcallouttap="onCalloutTap"bindlabeltap="onLabelTap"scale='7.5'polygons="{{polygon}}"
></map><view class="btn-area service"><button bindtap="removeMarkers">移除参与聚合点的marker</button><button bindtap="addMarkers">添加聚合点marker</button>
</view>

(2)css代码

.map {width: 100%;height: 300px;
}.btn-area {margin: 10px;display: flex;flex-wrap: wrap;border: 1px solid #ccc;
}button {display: inline-block;margin: 10px 5px;
}

(3)js代码这块比较重要呀(给自己看,太简单了哈哈哈哈哈哈哈哈哈,不过我就想一个人自娱自乐)

const app = getApp()
const img = '../image/location.png'Page({data: {//中心经度	latitude: 40.2,//中心纬度	longitude: 116.324520,//polygons 多边形polygon:[{  points: [{longitude:116.6212, latitude:41.0283},{longitude:116.6157, latitude:41.053},{longitude:116.6309, latitude:41.0608},{longitude:116.6896, latitude:41.0445},{longitude:116.6988, latitude:41.0208},{longitude:116.6777, latitude:40.9715},{longitude:116.7224, latitude:40.9273},{longitude:116.7134, latitude:40.9103},{longitude:116.7796, latitude:40.8771},{longitude:116.8047, latitude:40.8409},{longitude:116.8207, latitude:40.8483},{longitude:116.8762, latitude:40.8212},{longitude:116.8925, latitude:40.7803},{longitude:116.9251, latitude:40.7729},{longitude:116.9266, latitude:40.7449},{longitude:116.9696, latitude:40.7064},{longitude:117.0311, latitude:40.6921},{longitude:117.1107, latitude:40.7082},{longitude:117.2071, latitude:40.695},{longitude:117.3179, latitude:40.6578},{longitude:117.4092, latitude:40.6873},{longitude:117.5143, latitude:40.6611},{longitude:117.5004, latitude:40.6362},{longitude:117.462, latitude:40.6531},{longitude:117.4489, latitude:40.6515},{longitude:117.4482, latitude:40.6278},{longitude:117.4212, latitude:40.6354},{longitude:117.4218, latitude:40.5694},{longitude:117.3877, latitude:40.5608},{longitude:117.3502, latitude:40.5822},{longitude:117.3118, latitude:40.578},{longitude:117.2495, latitude:40.5482},{longitude:117.2629, latitude:40.513},{longitude:117.2187, latitude:40.5143},{longitude:117.2085, latitude:40.5009},{longitude:117.2354, latitude:40.4575},{longitude:117.2641, latitude:40.4415},{longitude:117.2341, latitude:40.4172},{longitude:117.2407, latitude:40.3944},{longitude:117.2243, latitude:40.3709},{longitude:117.2428, latitude:40.3698},{longitude:117.2749, latitude:40.3326},{longitude:117.2955, latitude:40.2782},{longitude:117.3317, latitude:40.2897},{longitude:117.3455, latitude:40.2349},{longitude:117.39, latitude:40.228},{longitude:117.3784, latitude:40.2103},{longitude:117.3933, latitude:40.2036},{longitude:117.3805, latitude:40.1963},{longitude:117.4069, latitude:40.1858},{longitude:117.3517, latitude:40.1732},{longitude:117.3606, latitude:40.157},{longitude:117.3473, latitude:40.1356},{longitude:117.3117, latitude:40.1394},{longitude:117.2744, latitude:40.1058},{longitude:117.2493, latitude:40.1165},{longitude:117.2112, latitude:40.0966},{longitude:117.1992, latitude:40.0673},{longitude:117.1855, latitude:40.085},{longitude:117.1803, latitude:40.0695},{longitude:117.1564, latitude:40.0787},{longitude:117.1392, latitude:40.0641},{longitude:117.0856, latitude:40.0751},{longitude:117.0218, latitude:40.0296},{longitude:116.9304, latitude:40.0553},{longitude:116.8707, latitude:40.0411},{longitude:116.8502, latitude:40.055},{longitude:116.8227, latitude:40.0465},{longitude:116.82, latitude:40.0283},{longitude:116.7778, latitude:40.0324},{longitude:116.7572, latitude:39.9633},{longitude:116.7826, latitude:39.9476},{longitude:116.7871, latitude:39.8868},{longitude:116.8041, latitude:39.8779},{longitude:116.8123, latitude:39.8897},{longitude:116.9002, latitude:39.8316},{longitude:116.9028, latitude:39.8483},{longitude:116.9174, latitude:39.8469},{longitude:116.9363, latitude:39.7951},{longitude:116.9536, latitude:39.7876},{longitude:116.8995, latitude:39.7587},{longitude:116.9167, latitude:39.7314},{longitude:116.8828, latitude:39.7186},{longitude:116.9065, latitude:39.6776},{longitude:116.8499, latitude:39.6676},{longitude:116.8512, latitude:39.6523},{longitude:116.8269, latitude:39.6382},{longitude:116.8354, latitude:39.617},{longitude:116.79, latitude:39.6105},{longitude:116.7851, latitude:39.5935},{longitude:116.7254, latitude:39.6242},{longitude:116.7006, latitude:39.621},{longitude:116.7263, latitude:39.5978},{longitude:116.7106, latitude:39.588},{longitude:116.694, latitude:39.6017},{longitude:116.6205, latitude:39.6017},{longitude:116.6079, latitude:39.6247},{longitude:116.5659, latitude:39.6198},{longitude:116.5623, latitude:39.6017},{longitude:116.5244, latitude:39.5965},{longitude:116.5274, latitude:39.5732},{longitude:116.5085, latitude:39.5511},{longitude:116.4709, latitude:39.5546},{longitude:116.4772, latitude:39.5344},{longitude:116.4368, latitude:39.5264},{longitude:116.4438, latitude:39.5099},{longitude:116.4017, latitude:39.528},{longitude:116.4229, latitude:39.4966},{longitude:116.4125, latitude:39.4817},{longitude:116.4441, latitude:39.4822},{longitude:116.4561, latitude:39.4589},{longitude:116.4344, latitude:39.4428},{longitude:116.3367, latitude:39.4561},{longitude:116.3056, latitude:39.4895},{longitude:116.2579, latitude:39.5005},{longitude:116.2462, latitude:39.5572},{longitude:116.204, latitude:39.5888},{longitude:116.1541, latitude:39.586},{longitude:116.1304, latitude:39.5677},{longitude:116.1014, latitude:39.5801},{longitude:116.0353, latitude:39.5718},{longitude:116.0164, latitude:39.5881},{longitude:115.9952, latitude:39.5771},{longitude:115.9784, latitude:39.5957},{longitude:115.9793, latitude:39.5724},{longitude:115.9575, latitude:39.5609},{longitude:115.9102, latitude:39.6008},{longitude:115.9117, latitude:39.5695},{longitude:115.8904, latitude:39.5686},{longitude:115.8877, latitude:39.5507},{longitude:115.8555, latitude:39.555},{longitude:115.8192, latitude:39.5308},{longitude:115.8287, latitude:39.507},{longitude:115.7521, latitude:39.5117},{longitude:115.7385, latitude:39.5463},{longitude:115.6921, latitude:39.5658},{longitude:115.6893, latitude:39.599},{longitude:115.6672, latitude:39.6156},{longitude:115.6573, latitude:39.6001},{longitude:115.5799, latitude:39.5895},{longitude:115.5452, latitude:39.6186},{longitude:115.5145, latitude:39.5918},{longitude:115.5224, latitude:39.64},{longitude:115.4782, latitude:39.6523},{longitude:115.5001, latitude:39.6909},{longitude:115.4924, latitude:39.7387},{longitude:115.4399, latitude:39.7521},{longitude:115.4249, latitude:39.7745},{longitude:115.4832, latitude:39.7987},{longitude:115.5071, latitude:39.7837},{longitude:115.5522, latitude:39.7947},{longitude:115.5693, latitude:39.8138},{longitude:115.5143, latitude:39.8377},{longitude:115.5292, latitude:39.8755},{longitude:115.509, latitude:39.8842},{longitude:115.5205, latitude:39.9022},{longitude:115.4807, latitude:39.9358},{longitude:115.4262, latitude:39.9504},{longitude:115.4545, latitude:40.0297},{longitude:115.5522, latitude:40.0792},{longitude:115.5576, latitude:40.0951},{longitude:115.5907, latitude:40.0964},{longitude:115.5991, latitude:40.12},{longitude:115.7411, latitude:40.1322},{longitude:115.777, latitude:40.1776},{longitude:115.8066, latitude:40.1533},{longitude:115.8519, latitude:40.148},{longitude:115.8481, latitude:40.184},{longitude:115.8721, latitude:40.1872},{longitude:115.8981, latitude:40.2364},{longitude:115.9689, latitude:40.2639},{longitude:115.9228, latitude:40.3247},{longitude:115.9183, latitude:40.3539},{longitude:115.8593, latitude:40.3624},{longitude:115.8604, latitude:40.3757},{longitude:115.7708, latitude:40.4426},{longitude:115.7822, latitude:40.4921},{longitude:115.736, latitude:40.5038},{longitude:115.7532, latitude:40.5388},{longitude:115.7906, latitude:40.5609},{longitude:115.8198, latitude:40.5593},{longitude:115.8277, latitude:40.5873},{longitude:115.8854, latitude:40.5952},{longitude:115.9078, latitude:40.6173},{longitude:115.9668, latitude:40.6063},{longitude:115.9834, latitude:40.5788},{longitude:116.0256, latitude:40.6067},{longitude:116.03, latitude:40.5974},{longitude:116.1217, latitude:40.6292},{longitude:116.1106, latitude:40.6469},{longitude:116.1349, latitude:40.6671},{longitude:116.1646, latitude:40.6634},{longitude:116.1779, latitude:40.7079},{longitude:116.2338, latitude:40.7591},{longitude:116.2476, latitude:40.7918},{longitude:116.2734, latitude:40.7629},{longitude:116.3089, latitude:40.7519},{longitude:116.3295, latitude:40.7738},{longitude:116.4617, latitude:40.7698},{longitude:116.4572, latitude:40.7983},{longitude:116.3344, latitude:40.9046},{longitude:116.3342, latitude:40.9213},{longitude:116.3703, latitude:40.9437},{longitude:116.3985, latitude:40.906},{longitude:116.4742, latitude:40.8961},{longitude:116.4475, latitude:40.9538},{longitude:116.4562, latitude:40.9813},{longitude:116.5163, latitude:40.9752},{longitude:116.5633, latitude:40.9936},{longitude:116.5988, latitude:40.9747},{longitude:116.6145, latitude:40.9833},{longitude:116.6212, latitude:41.0283}],fillColor: "#4F94CD33",fillColor: "#ffff0033",strokeColor: "#FFF",strokeWidth: 2,zIndex: 5,}]	},onLoad: function () {this.mapCtx = wx.createMapContext('mapId')this.setData({polygon: this.data.polygon,});},
})

get

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/16901.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

一些学习资源

AI 00 前言 - AI-EDU|openAI 趣味编程 Coding Games and Programming Challenges to Code Better UI设计 创造狮 创意工作者导航 Java Java 技术书籍大全 GitHub - fenixsoft/jvm_book: 《深入理解Java虚拟机&#xff08;第3版&#xff09;》样例代码&勘误 OpenJDK …

【入门SpringCloud(一)】什么是SpringCloud?

一、概述 集群&#xff08;Cluster&#xff09;&#xff1a;同一种软件服务的多个服务节点共同为系统提供服务过程&#xff0c;称之为该软件服务集群。 分布式&#xff08;Distribute&#xff09;&#xff1a;分布式是一种系统架构&#xff0c;是将系统中的不同组件分布在不同…

Mac 安装配置adb命令环境(详细步骤)

一、注意&#xff1a;前提要安装java环境。 因为android sdk里边开发的一些包都是依赖java语言的&#xff0c;所以&#xff0c;首先要确保已经配置了java环境。 二、在Mac下配置android adb命令环境&#xff0c;配置方式如下&#xff1a; 1、下载并安装IDE &#xff08;andr…

springboot + (mysql/pgsql) + jpa 多数据源(不同类数据源)

配置文件&#xff1a; spring:datasource:primary:jdbc-url: jdbc:mysql://host:3306/数据库?useUnicodetrue&characterEncodingUTF-8&autoReconnecttrue&failOverReadOnlyfalse&serverTimezoneAsia/Shanghai&zeroDateTimeBehaviorconvertToNullusername…

LLaMA系列 | LLaMA和LLaMA-2精简总结

文章目录 1、LLaMA1.1、模型结构1.2、训练方式1.3、结论 2、LLaMA-22.1、相比LLaMA1的升级2.3、模型结构2.3.1、MHA, MQA, GQA区别与联系 2.4、训练方式 1、LLaMA &#x1f525; 纯基座语言模型 《LLaMA: Open and Efficient Foundation Language Models》&#xff1a;https:/…

Unity3d C#快速打开萤石云监控视频流(ezopen)支持WebGL平台,替代UMP播放视频流的方案(含源码)

前言 Universal Media Player算是视频流播放功能常用的插件了&#xff0c;用到现在已经不知道躺了多少坑了&#xff0c;这个插件虽然是白嫖的&#xff0c;不过被甲方和领导吐槽的就是播放视频流的速度特别慢&#xff0c;可能需要几十秒来打开监控画面&#xff0c;等待的时间较…

机器学习笔记 - 什么是keras-core?

一、keras-core 简而言之,Keras Core 是 Keras API 的新多后端实现,支持 TensorFlow、JAX 和 PyTorch。 可以使用如下命令简单安装 pip install keras-core Keras 是一个用 Python 编写的用于深度学习的用户友好工具。它旨在与 AI 领域的另一个主要参与者TensorFlow一起使用…

Spring学习笔记之spring概述

文章目录 Spring介绍Spring8大模块Spring特点 Spring介绍 Spring是一个轻量级的控制反转和面向切面的容器框架 Spring最初的出现是为了解决EJB臃肿的设计&#xff0c;以及难以测试等问题。 Spring为了简化开发而生&#xff0c;让程序员只需关注核心业务的实现&#xff0c;尽…

SpringBoot启动流程及自动配置

SpringBoot启动流程源码&#xff1a; 1、启动SpringBoot启动类SpringbootdemoApplication中的main方法。 SpringBootApplication public class SpringbootdemoApplication {public static void main(String[] args) {SpringApplication.run(SpringbootdemoApplication.class, …

ubuntu 配置NAT配置内网网关服务器

本次完全参考 Ubuntu20.04服务器开启路由转发让局域网内其他电脑通过该服务器连接外网 ubuntu 官方防火墙文档 Security - Firewall 本人从前的操作 Ubuntu 18.04 通过 ufw route 配置网关服务器 网关 配置内网DNS 服务器 背景知识 从前总认为既然UFW简化了 iptables &…

Eureka 学习笔记2:客户端 DiscoveryClient

版本 awsVersion ‘1.11.277’ DiscoveryClient # cacheRefreshTask // 配置shouldFetchRegistry if (clientConfig.shouldFetchRegistry()) {// 配置client.refresh.intervalint registryFetchIntervalSeconds clientConfig.getRegistryFetchIntervalSeconds();// 配置expB…

深入理解Zookeeper分布式锁的概念及原理

深入理解Zookeeper分布式锁的概念及原理 1. 引言 在分布式系统中&#xff0c;锁是一种重要的机制&#xff0c;用于协调多个节点之间的并发访问。在大规模分布式系统中&#xff0c;实现高效且可靠的分布式锁是一个挑战。本篇博客将深入探讨Zookeeper分布式锁的概念及其原理&am…

HTML+CSS+JavaScript:轮播图的自动播放、手动播放、鼠标悬停暂停播放

一、需求 昨天我们做了轮播图的自动播放&#xff0c;即每隔一秒自动切换一次 今天我们增加两个需求&#xff1a; 1、鼠标点击向右按钮&#xff0c;轮播图往后切换一次&#xff1b;鼠标点击向左按钮&#xff0c;轮播图往前切换一次 2、鼠标悬停在轮播图区域中时&#xff0c;…

Verilog语法学习——LV5_位拆分与运算

LV5_位拆分与运算 题目来源于牛客网 [牛客网在线编程_Verilog篇_Verilog快速入门 (nowcoder.com)](https://www.nowcoder.com/exam/oj?page1&tabVerilog篇&topicId301) 题目 题目描述&#xff1a; 现在输入了一个压缩的16位数据&#xff0c;其实际上包含了四个数据…

Layui网页模板

<!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>会员管理</title><link href"layui/c…

JAVA IO 的 Windows、Linux文件路径差异

因为文件路径是字符串拼接的&#xff0c;所以之前的路径是这样 D:\pics/bankslip/2023/08/01\fe68a2c16ecb498f89a88f9472a1361e.png /root/temp/bankslip/2023/08/01\fe68a2c16ecb498f89a88f9472a1361e.png 左斜杠、右斜杠都有的情况 那么在windows中这样的路径是正常的&#…

ComPDFKit 转档SDK OCR表格识别功能

我们非常高兴地宣布&#xff0c;适用于 Windows、iOS、Android 和服务器的 ComPDFKit 转档SDK 1.8.0 现已发布&#xff01;在该版本中&#xff0c;OCR 功能支持了表格识别&#xff0c;优化了OCR文字识别率。PDF to HTML 优化了html 文件结构&#xff0c;使转换后的 HTML 文件容…

css 四角边框移动效果

块是长宽相等的正方形&#xff0c;大小浏览器分辨率变化而变化利用平移变化translate来时实现边框到达鼠标划到的块&#xff0c;坐标是鼠标滑到块的offsetLeft和offsetTop <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8&quo…

誉天程序员-SpringMVC回顾:五种接参方式

1、GET查询串传参&#xff1a; 2、RESTFul形式传参&#xff08;参数少&#xff09; 3、form表单传参 4、混合传参&#xff0c;查询串表单 5、终极王者&#xff0c;json传参&#xff08;参数多&#xff09; package com.book.admin.controller;import com.book.admin.entity.Us…

从互联网到云时代,Apache RocketMQ 是如何演进的?

作者&#xff1a;隆基 2022 年&#xff0c;RocketMQ 5.0 的正式版发布。相对于 4.0 版本而言&#xff0c;架构走向云原生化&#xff0c;并且覆盖了更多业务场景。 消息队列演进史 操作系统、数据库、中间件是基础软件的三驾马车&#xff0c;而消息队列属于最经典的中间件之一…