9 Star 22 Fork 6

ZJZHOME / heatmap-amap.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

高德地图JS API V1.3的热力图实现,基于第三方库heatmap.js(官网地址:http://www.patrick-wied.at/static/heatmapjs/)。

##使用方法:

  • 先后引入高德地图api和heatmap-amap.js。
<script src="http://webapi.amap.com/maps?v=1.3&key=yourkey"></script>
<script src="heatmap-amap.js"></script>
  • 初始化高德热力图对象
    /*
    * map:地图对象
    * opts:可选参数,其中
    *   radius:热力图每个点的半径
    *   visible:热力图是否显示
    *   opacity:热力图的透明度,取值范围0~100
    *   gradient:热力图的渐变区间
    * 可参考heatmap.js的文档:https://github.com/pa7/heatmap.js/blob/master/README.md
    */
    var config =  {
        radius: 30,
        visible: true,
        opacity: 40,
        gradient: { 0.45: 'rgb(0,0,255)', 0.55: 'rgb(0,255,255)', 0.65: 'rgb(0,255,0)', 0.95: 'yellow', 1.0: 'rgb(255,0,0)' }
    };
    var heatmap = new AMap.Heatmap(map, config);
  • 调用start方法
    heatmap.start();
  • 设置数据。
	var obj = {
		max: 90, //权重最大值
        //lng为精度值,lat为纬度值,count为权重
		data: [
			{lng:114.169922, lat:30.606004, count: 80},
			{lng:114.322357, lat:30.640275, count: 60},
			{lng:114.33197, lat:30.556348, count: 90},
            ...
		]
	};
    
    //调用setDataSet()方法即可显示。
    heatmap.setDataSet(obj);

效果图

Screenshot

API说明

heatmap-amap.js还暴露了一些方法。

  • setDataSet,见使用方法
  • addDataPoint(lng, lat, count),添加一组数据显示在热力图中。
  • toggle(),切换热力图的显示与隐藏。
  • clear(),清除热力图。
The MIT License (MIT) Copyright (c) 2014 ZJZHOME Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于高德地图JS API的热力图实现 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/zjzhome/heatmap-amap.js.git
git@gitee.com:zjzhome/heatmap-amap.js.git
zjzhome
heatmap-amap.js
heatmap-amap.js
master

搜索帮助