高德地图上绘制热力图的方法

news2024/11/26 18:23:29

 百度地图和高德地图的JavaScript API都提供了热力图的绘制方法,都是将热力图作为新的图层,叠加到地图上。但是百度地图的经纬度体系与我们的经纬度存在偏差,高德的与我们相符,应当使用高德地图JavaScript API。

因为是JavaScript API,所以地图展示是在网页上的。以高德地图的API使用为例:

在html文件中添加高德地图必须的script,其中第一行的key可以在高德官网免费申请。

准备-入门-教程-地图 JS API 1.4 | 高德地图API准备本章向您介绍使用高德地图JSAPI开发应用之前的一些准备工作。注册账号并申请Key1.首先,注册开发者账号,成为高德icon-default.png?t=N7T8https://lbs.amap.com/api/javascript-api/guide/abc/prepare

https://lbs.amap.com/api/javascript-api/guide/abc/prepare

   <title>热力图</title>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script src="http://webapi.amap.com/maps?v=1.3&key=    898eb************"></script>

 html源码如下:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>热力图</title>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script src="http://webapi.amap.com/maps?v=1.3&key=	898eb9*******************"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
    <script type="text/javascript" src="http://a.amap.com/jsapi_demos/static/resource/heatmapData.js"></script>
</head>
<body>
<div id="container"></div>
<div class="button-group">
    <input type="button" class="button" value="显示热力图" οnclick="heatmap.show()"/>
    <input type="button" class="button" value="关闭热力图" οnclick="heatmap.hide()"/>
</div>
<script>
    var map = new AMap.Map("container", {
        resizeEnable:false,
        center: [121.196087,31.05471],   //华政经纬度
        zoom: 11
    });
    if (!isSupportCanvas()) {
        alert('热力图仅对支持canvas的浏览器适用,您所使用的浏览器不能使用热力图功能,请换个浏览器试试~')
    }
     var points =[
{"lat":31.05471,"lng":121.196087,"count":1},
{"lat":31.955631,"lng":121.457741,"count":1},
{"lat":31.993408,"lng":121.45536,"count":1},
{"lat":31.994091,"lng":121.454597,"count":1},
{"lat":31.994202,"lng":121.454788,"count":1},
{"lat":31.894291,"lng":121.46257,"count":1},
{"lat":31.892929,"lng":121.463181,"count":1},
{"lat":31.89317,"lng":121.462479,"count":1},
{"lat":31.969528,"lng":121.372078,"count":1},
{"lat":31.994122,"lng":121.45446,"count":1},
{"lat":31.993881,"lng":121.455231,"count":1},
{"lat":31.005829,"lng":121.452492,"count":1},
{"lat":32.020748,"lng":121.451881,"count":1},
{"lat":31.969421,"lng":121.372124,"count":1},
{"lat":31.994221,"lng":121.45443,"count":1},
{"lat":31.993809,"lng":121.455597,"count":1},
{"lat":31.993809,"lng":121.455597,"count":1},
{"lat":31.994202,"lng":121.454327,"count":1},
{"lat":31.99324,"lng":121.454758,"count":1},
{"lat":31.994221,"lng":121.454338,"count":1},
{"lat":31.992321,"lng":121.456612,"count":1},
{"lat":31.993241,"lng":121.454319,"count":1},
{"lat":31.89801,"lng":121.413247,"count":1},
{"lat":31.898361,"lng":121.415947,"count":1},
{"lat":31.897999,"lng":121.413278,"count":1},
{"lat":31.99371,"lng":121.454964,"count":1},
{"lat":31.993169,"lng":121.454559,"count":1},
{"lat":31.992512,"lng":121.454826,"count":1},
{"lat":31.993889,"lng":121.455231,"count":1},
{"lat":31.99318,"lng":121.455032,"count":1},
{"lat":31.895111,"lng":121.462273,"count":1},
{"lat":31.913422,"lng":121.415283,"count":1},
{"lat":31.993832,"lng":121.455311,"count":1},
{"lat":31.993649,"lng":121.454674,"count":1},
{"lat":31.951908,"lng":121.445137,"count":1},
{"lat":31.912979,"lng":121.415421,"count":1},
{"lat":31.993299,"lng":121.454857,"count":1},
{"lat":31.991989,"lng":121.454826,"count":1},
{"lat":31.912971,"lng":121.415466,"count":1},
{"lat":31.913052,"lng":121.415482,"count":1},
{"lat":31.912979,"lng":121.417778,"count":1},
{"lat":31.891682,"lng":121.463417,"count":1},
{"lat":31.894798,"lng":121.462471,"count":1},
{"lat":31.908428,"lng":121.427,"count":1},
{"lat":31.992981,"lng":121.454773,"count":1},
{"lat":31.99323,"lng":121.455132,"count":1},
{"lat":31.993591,"lng":121.455513,"count":1},
{"lat":31.89323,"lng":121.462997,"count":1},
{"lat":31.89323,"lng":121.462997,"count":1},
{"lat":32.249329,"lng":121.366669,"count":1},
{"lat":32.24934,"lng":121.366768,"count":1},
{"lat":31.991982,"lng":121.454826,"count":1},
{"lat":31.97134,"lng":121.45507,"count":1},
{"lat":31.999599,"lng":121.313296,"count":1},
{"lat":31.993131,"lng":121.454681,"count":1},
{"lat":31.993291,"lng":121.454437,"count":1},
{"lat":31.991989,"lng":121.454826,"count":1},
{"lat":31.890659,"lng":121.463791,"count":1},
{"lat":31.89325,"lng":121.463322,"count":1},
{"lat":31.894981,"lng":121.462181,"count":1},
{"lat":31.891472,"lng":121.463547,"count":1},
{"lat":31.99374,"lng":121.455177,"count":1},
{"lat":31.994202,"lng":121.454613,"count":1},
{"lat":31.977379,"lng":121.437683,"count":1},
{"lat":31.949791,"lng":121.462158,"count":1},
{"lat":31.895088,"lng":121.462219,"count":1},
{"lat":31.993192,"lng":121.455353,"count":1},
{"lat":31.993698,"lng":121.454941,"count":1},
{"lat":31.9921,"lng":121.454437,"count":1},
{"lat":31.89389,"lng":121.462334,"count":1},
{"lat":31.89238,"lng":121.463188,"count":1},
{"lat":31.99419,"lng":121.454514,"count":1},
{"lat":31.993328,"lng":121.455078,"count":1},
{"lat":31.993752,"lng":121.454773,"count":1},
{"lat":31.984779,"lng":121.467529,"count":1},
{"lat":31.890961,"lng":121.463692,"count":1},
{"lat":31.993858,"lng":121.455131,"count":1},
{"lat":31.99202,"lng":121.4552,"count":1},
{"lat":31.993729,"lng":121.455231,"count":1},
{"lat":31.994282,"lng":121.453819,"count":1},
{"lat":31.992649,"lng":121.455009,"count":1},
{"lat":31.99379,"lng":121.45462,"count":1},
{"lat":31.872292,"lng":121.316347,"count":1},
{"lat":31.870731,"lng":121.388618,"count":1},
{"lat":31.864349,"lng":121.377289,"count":1},
{"lat":31.719238,"lng":121.331802,"count":1},
{"lat":30.43782,"lng":121.455002,"count":1},
{"lat":30.03352,"lng":121.715134,"count":1},
{"lat":29.836868,"lng":121.090286,"count":1},
{"lat":30.246021,"lng":121.31308,"count":1},
{"lat":30.815498,"lng":121.230698,"count":1},
{"lat":31.99254,"lng":118.57972,"count":1},
{"lat":31.14229,"lng":121.38549,"count":1},
{"lat":31.993161,"lng":121.454727,"count":1},
{"lat":31.993118,"lng":121.455597,"count":1},
{"lat":31.946231,"lng":121.450321,"count":1},
{"lat":31.932121,"lng":121.45546,"count":1},
{"lat":31.99323,"lng":121.453157,"count":1},
{"lat":31.99295,"lng":121.455719,"count":1},
{"lat":31.99184,"lng":121.454819,"count":1},
{"lat":31.993241,"lng":121.454681,"count":1},
{"lat":31.99287,"lng":121.454742,"count":1},
{"lat":31.9931,"lng":121.455,"count":1},
{"lat":31.992741,"lng":121.455673,"count":1},
{"lat":31.994141,"lng":121.45491,"count":1},
{"lat":31.992229,"lng":121.454903,"count":1},
{"lat":31.99369,"lng":121.455383,"count":1},
{"lat":31.969921,"lng":121.49221,"count":1},
{"lat":31.997921,"lng":121.38343,"count":1},
{"lat":31.992619,"lng":121.453873,"count":1},
{"lat":31.992069,"lng":121.454826,"count":1},
{"lat":31.993679,"lng":121.454529,"count":1},
{"lat":32.065201,"lng":121.432068,"count":1},
{"lat":31.992149,"lng":121.454521,"count":1},
{"lat":31.99315,"lng":121.454559,"count":1},
{"lat":31.993851,"lng":121.45472,"count":1},
{"lat":31.993759,"lng":121.454529,"count":1},
{"lat":31.991508,"lng":121.45636,"count":1},
{"lat":31.993858,"lng":121.454979,"count":1},
{"lat":31.967789,"lng":121.452217,"count":1},
{"lat":31.99387,"lng":121.455193,"count":1},
{"lat":31.994179,"lng":121.454727,"count":1},
{"lat":31.992538,"lng":121.456459,"count":1},
{"lat":31.99382,"lng":121.454651,"count":1},
{"lat":31.994221,"lng":121.454872,"count":1},
{"lat":31.951038,"lng":121.471687,"count":1},
{"lat":31.99416,"lng":121.454552,"count":1},
{"lat":32.005821,"lng":121.457581,"count":1},
{"lat":31.97131,"lng":121.455131,"count":1},
{"lat":31.992691,"lng":121.456352,"count":1},
{"lat":31.99379,"lng":121.455048,"count":1},
{"lat":31.99328,"lng":121.454681,"count":1},
{"lat":31.893532,"lng":121.462914,"count":1},
{"lat":31.994129,"lng":121.455147,"count":1},
{"lat":31.99292,"lng":121.455643,"count":1},
{"lat":31.99292,"lng":121.455643,"count":1},
{"lat":31.99366,"lng":121.454567,"count":1},
{"lat":32.008179,"lng":121.460098,"count":1},
{"lat":31.993721,"lng":121.454727,"count":1},
{"lat":32.044231,"lng":121.280792,"count":1},
{"lat":31.971821,"lng":121.37314,"count":1},
{"lat":31.969509,"lng":121.370231,"count":1},
{"lat":31.993831,"lng":121.454659,"count":1},
{"lat":31.89526,"lng":121.466301,"count":1},
{"lat":31.894329,"lng":121.462463,"count":1},
{"lat":31.893089,"lng":121.46302,"count":1},
{"lat":31.894791,"lng":121.46228,"count":1},
{"lat":31.994221,"lng":121.454521,"count":1},
{"lat":31.89296,"lng":121.463112,"count":1},
{"lat":31.97855,"lng":121.369019,"count":1},
{"lat":31.99416,"lng":121.454102,"count":1},
{"lat":31.99411,"lng":121.454422,"count":1},
{"lat":31.894711,"lng":121.46257,"count":1},
{"lat":31.890781,"lng":121.463707,"count":1},
{"lat":31.994129,"lng":121.454422,"count":1}];
    //详细的参数,可以查看heatmap.js的文档 http://www.patrick-wied.at/static/heatmapjs/docs.html
    //参数说明如下:
    /* visible 热力图是否显示,默认为true
     * opacity 热力图的透明度,分别对应heatmap.js的minOpacity和maxOpacity
     * radius 势力图的每个点的半径大小   
     * gradient  {JSON} 热力图的渐变区间 . gradient如下所示
     * {
     .2:'rgb(0, 255, 255)',
     .5:'rgb(0, 110, 255)',
     .8:'rgb(100, 0, 255)'
     }
     其中 key 表示插值的位置, 0-1 
     value 为颜色值 
     */
    var heatmap;
    map.plugin(["AMap.Heatmap"], function() {
        //初始化heatmap对象
        heatmap = new AMap.Heatmap(map, {
            radius: 15, //给定半径
            opacity: [0, 0.8]
            /*,gradient:{
             0.5: 'blue',
             0.65: 'rgb(121,211,248)',
             0.7: 'rgb(0, 255, 0)',
             0.9: '#ffea00',
             1.0: 'red'
             }*/
        });
        //设置数据集
        heatmap.setDataSet({
            data: points,
            max: 5
        });
    });
    //判断浏览区是否支持canvas
    function isSupportCanvas() {
        var elem = document.createElement('canvas');
        return !!(elem.getContext && elem.getContext('2d'));
    }
</script>
</body>
</html>

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

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

相关文章

一个人被锁死在公司底层的根本原因

一、现代社会对员工角色的认知 随着经济全球化和科技进步,现代社会对员工的认知发生了深刻的变化。传统上,员工被视为公司的执行者和生产者,承担着重复性、机械性的工作。然而,随着知识经济和服务型经济的兴起,员工角色逐渐从“执行者”转变为“创造者”和“合作者”。员…

python-分享篇-五子棋

文章目录 代码效果 代码 """五子棋之人机对战"""import sys import random import pygame from pygame.locals import * import pygame.gfxdraw from checkerboard import Checkerboard, BLACK_CHESSMAN, WHITE_CHESSMAN, offset, PointSIZE 3…

CSRNET图像修复,DNN

CSRNET图像修复 CSRNET图像修复&#xff0c;只需要OPENCV的DNN

Momentum2

攻击机 192.168.223.128 目标机 192.168.223.147 主机发现 nmap -sP 192.168.223.0/24 端口扫描 nmap -sV -A -p- 192.168.223.147 开启了22 80 端口 看一下web界面 源码&#xff0c;robots.txt ,url都观察了一下好像没什么有用信息 扫一下目录 gobuster dir -u http:…

H5 树叶飘动二次元引导页源码

H5 树叶飘动二次元引导页源码 源码介绍&#xff1a;一款H5 树叶飘动二次元引导页源码&#xff0c;带有很多可选跳转按钮。 下载地址&#xff1a; https://www.changyouzuhao.cn/10386.html

【C语言】指针的入门篇2,深入理解指针和数组的关系

欢迎来CILMY23的博客喔&#xff0c;本期系列为【C语言】指针的入门篇2&#xff0c;深入理解指针和数组的关系&#xff0c;图文讲解指针和数组关系的知识&#xff0c;带大家理解指针和数组的关系&#xff0c;以及指针数组的用法&#xff0c;感谢观看&#xff0c;支持的可以给个赞…

投资理财的正确方式,实现个人的财富积累

一、教程描述 本套理财教程&#xff0c;大小18.98G&#xff0c;共有16个文件。 二、教程目录 第01课&#xff1a;记账为什么能帮月薪3000的你&#xff0c;省20%&#xff1f;.mp4 第02课&#xff1a;玩转信用卡&#xff0c;银行帮你越刷越有钱.mp4 第03课&#xff1a;巧用公…

代码+视频基于R语言进行K折交叉验证

我们在建立数据模型后通常希望在外部数据验证模型的检验能力。然而当没有外部数据可以验证的时候&#xff0c;交叉验证也不失为一种方法。交叉验验证&#xff08;交叉验证&#xff0c;&#xff23;&#xff36;&#xff09;则是一种评估模型泛化能力的方法&#xff0c;广泛应用…

30、二维数组/字符串操作相关练习20240214

一、编程实现二维数组的杨辉三角。 代码&#xff1a; #include<stdlib.h> #include<string.h> #include<stdio.h>int main(int argc, const char *argv[]) {int n;printf("please enter n:");scanf("%d",&n);int arr[n][n];for(in…

Django学习全纪录:Django开发环境的搭建

导言 对于Django&#xff0c;它是Python的一个开发框架&#xff0c;之前系统地学习过。遗憾的是&#xff0c;对于一些遇到的问题&#xff0c;没有及时地记录下来。因此&#xff0c;我将它重新捡起&#xff0c;进行学习和实践。从搭建环境开始&#xff0c;重新去学习它&#xff…

【从Python基础到深度学习】4. Linux常用命令(进阶)

接上篇 【从Python基础到深度学习】4. Linux 常用命令-CSDN博客 1.文件查找 - find 命令 find [搜索路径] [搜索条件] [操作]1.1 常用选项和参数 -name&#xff1a;按文件名搜索。 find 命令的 -name 选项可以接受通配符来匹配文件名。通配符可以帮助你更灵活地搜索文件名&a…

第13章 网络 Page724 asio定时器

程序代码&#xff1a; 11行&#xff0c;声明一个ios对象 13行&#xff0c;使用ios对象作为参数声明一个定时器&#xff0c;此时&#xff0c;定时器和ios完成了关联&#xff0c;后面定时器如果有任务的话&#xff0c;就可以将任务交给ios 16行&#xff0c;为定时器设置一个定…

MySQL数据库基础(一):数据库概述

文章目录 数据库概述 一、数据库介绍 二、数据库分类 1、关系型数据库 2、非关系型数据库NoSQL 三、常见数据库介绍 1、关系型数据库 2、非关系型数据库 数据库概述 一、数据库介绍 数据库就是存储数据的仓库&#xff0c;其本质是一个文件系统&#xff0c;按照特定的…

【Pygame手册01/20】最简应用:窗口

目录 一、说明 二、pygame是什么&#xff1f; 2.1 为游戏开发设计 2.2 版本发展史 2.3 特点 三、pygame安装要点 四、入门知识 4.1 初始使用 4.2 要更改 pygame 窗口的外观 4.3 完整窗口程序 4.4 窗口对象接口示例 五、隐形窗口和显性窗口 六、结论 一、说明 为什…

EasyRecovery专业版2024最新版本数据恢复软件

EasyRecovery专业版2024是一款功能强大的数据恢复软件&#xff0c;专为满足专业用户的需求而设计。它支持恢复各种类型的数据&#xff0c;包括文档、图片、视频、音频等&#xff0c;且可以恢复的数据存储介质也非常多样化&#xff0c;如硬盘、U盘、移动硬盘、数码相机、手机等。…

如何流畅进入Github

前言 以下软件是免费的&#xff0c;放心用 一、进入右边的下载链接https://steampp.net/ 二、点击下载 三、点击接受并下载 四、随便选一个下载链接进行下载 五、软件安装好打开后&#xff0c;找到Github 六、点击全部启用 七、再点击左上角的一键加速 八、这个时候你再进Git…

java的面向对象编程(oop)——认识泛型

前言&#xff1a; 打好基础&#xff0c;daydayup! 泛型 1&#xff0c;认识泛型&#xff1a; 定义类&#xff0c;接口&#xff0c;方法时&#xff0c;同时声明了一个或多个类型变量&#xff08;例&#xff1a;<E>&#xff09;,称为泛型&#xff0c;泛型接口&#xff0c;泛…

error MSB8008: 指定的平台工具集(v143)未安装或无效。请确保选择受支持的 PlatformToolset 值解决办法

右击解决方案&#xff0c;选择属性 将工具集为143的修改为其他&#xff0c;如图 重新编译即可运行

应用进程跨越网络的通信

目录 1 系统调用和应用编程接口 应用编程接口 API 几种应用编程接口 API 套接字的作用 几种常用的系统调用 1. 连接建立阶段 2. 传送阶段 3. 连接释放阶段 1 系统调用和应用编程接口 大多数操作系统使用系统调用 (system call ) 的机制在应用程序和操作系统之间传递控制…

AI:127-基于卷积神经网络的交通拥堵预测

🚀点击这里跳转到本专栏,可查阅专栏顶置最新的指南宝典~ 🎉🎊🎉 你的技术旅程将在这里启航! 从基础到实践,深入学习。无论你是初学者还是经验丰富的老手,对于本专栏案例和项目实践都有参考学习意义。 ✨✨✨ 每一个案例都附带有在本地跑过的关键代码,详细讲解供…