123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- <!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">
- <!-- <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" /> -->
- <style>
- * {
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
- -webkit-tap-highlight-color: transparent;
- margin: 0;
- padding: 0;
- }
- .chart {
- width: 100vw;
- height: 100vh;
- }
- #container {
- margin: 0;
- padding: 0;
- width: 100vw;
- height: 100vh;
- }
- .title {
- text-align: center;
- font-size: 16px;
- font-weight: bold;
- margin: 20px 0;
- }
- .hot {
- width: 100vw;
- height: 100vh;
- margin: 0 auto;
- position: relative;
- }
- .amap-labels {
- width: 100% !important;
- }
- .tab {
- width: 100%;
- position: absolute;
- top: 5%;
- left: 0;
- z-index: 9999;
- }
- .tabCon {
- width: 55%;
- margin: 0 auto;
- outline: none;
- text-align: center;
- height: 32px;
- line-height: 32px;
- display: flex;
- justify-content: space-around;
- }
- .tabCon text {
- font-size: 14px;
- width: 50%;
- color: #64efda;
- height: 100%;
- background-color: #fff;
- border: 1px solid #64efda;
- }
- .tabCon .active {
- background: #64efda;
- color: #fff;
- }
- .tabCon text:first-child {
- border-top-left-radius: 15px;
- border-bottom-left-radius: 15px;
- }
- .tabCon text:last-child {
- border-top-right-radius: 15px;
- border-bottom-right-radius: 15px;
- }
- .drop {
- width: 100px;
- height: 30px;
- position: absolute;
- bottom: 5%;
- right: 5%;
- z-index: 9999;
- border-radius: 15px;
- background: #64efda;
- }
- select {
- width: 100%;
- height: 100%;
- border-radius: 50%;
- font-size: 14px;
- padding-left: 15px;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- appearance: none;
- -moz-appearance: none;
- -webkit-appearance: none;
- outline: none;
- border: none;
- background: #64efda;
- color: #fff;
- }
- img {
- width: 16px;
- height: 16px;
- vertical-align: middle;
- }
- </style>
- </head>
- <body>
- <div class="chart">
- <div class="hot">
- <div class="tab">
- <div class="tabCon">
- <text class="active" id="1">扫码热力图</text>
- <text id="2">停车热力图</text>
- </div>
- </div>
- <div class="drop">
- <select id="choose"></select>
- </div>
- <div id="container"></div>
- </div>
- <!-- <div class="user">
- <div class="title">用户数据</div>
- <div id="user"></div>
- </div>
- <div class="block"></div>
- <div class="orderCount">
- <div class="title">订单数据</div>
- <div id="orderCount"></div>
- </div> -->
- </div>
- <script src="https://webapi.amap.com/maps?v=1.4.15&key=bd75d5583e6e04663da170715ff52b3d"></script>
- <script src="https://a.amap.com/jsapi_demos/static/resource/heatmapData.js"></script>
- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
- <script src="https://cdn.bootcdn.net/ajax/libs/echarts/4.7.0/echarts.js"></script>
- <script>
- // let baseUrl = "https://admin.weilaibike.dev.hanyiyun.com/app-api/" //测试
- let baseUrl = "https://admin.weilaibike.com/app-api/" //线上
- var map = new AMap.Map("container", {
- resizeEnable: true,
- center: [116.418261, 39.921984],
- zoom: 11
- });
- var heatmap;
- setTimeout(() => {
- var map = new AMap.Map("container", {
- resizeEnable: true,
- center: [116.418261, 39.921984],
- zoom: 11
- });
- map.plugin('AMap.Geolocation', function () {
- geolocation = new AMap.Geolocation({
- enableHighAccuracy: true, //是否使用高精度定位,默认:true
- timeout: 10000, //超过10秒后停止定位,默认:无穷大
- buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
- zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
- // buttonPosition: 'RB'
- });
- map.addControl(geolocation);
- geolocation.getCurrentPosition();
- AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
- AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
- function onComplete(data) {
- var str = [];
- str.push(data.position.getLat());
- str.push(data.position.getLng());
- }
- });
-
- map.plugin(["AMap.Heatmap"], function () {
- //初始化heatmap对象
- heatmap = new AMap.Heatmap(map, {
- radius: 25, //给定半径
- opacity: [0, 0.8],
- });
- });
- // var url = 'https://mp.weixin.qq.com/wxamp/user/manage?action=index&use_role=1&token=1418778091&lang=zh_CN'
- $.ajax({
- url: baseUrl + 'index',
- method: 'GET',
- data: {
- // token:'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYWRtaW4ud2VpbGFpYmlrZS5jb21cL2FwcC1hcGlcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTkwOTk0Mjg3LCJleHAiOjE1OTExNjcwODcsIm5iZiI6MTU5MDk5NDI4NywianRpIjoiaGZ4REtZZDlwMVFJVm55UyIsInN1YiI6MjYsInBydiI6ImM4MjkyMjM4MzVkMTExMzhmMDhhY2U1NmZmYTY2MjhiYzI2ODNjYjUifQ.Ai_n-Wy5r_onKdYfHghcLwaGOeWAQtRF0VbhjSaIcsA',
- token:getUrlParam('token')
- },
- success: function (res) {
- var areas = res.wx_area;
- for (var i = 0; i < areas.length; i++) {
- var $select = $("#choose");
- $select.append('<option value=' + areas[i].areaID + ' >' + areas[i].text + '</option>');
- }
- initData(areas[0].areaID);
- }
- })
- }, 3000);
- //解析定位结果
- function getUrlParam(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
- var r = window.location.search.substr(1).match(reg); //匹配目标参数
- if (r != null) return decodeURIComponent(r[2]); return null; //返回参数值
- }
- function initData(id) {
- // 热力图
- console.log('初始化')
- $.ajax({
- url: baseUrl + 'order/heatMap',
- method: 'GET',
- data: {
- area_id: id,
- // area_id: 1
- },
- success: function (res) {
- console.log(res)
- // alert(res)
- var point = res.start;
- heatmap.setDataSet({
- data: point,
- max: 100
- });
- }
- })
- }
-
- //获取区域
- //筛选区域
- $('#choose').change(function (e) {
- var id = $("#choose ").val()
- initData(id);
- })
- // tab切换
- $('text').click(function (e) {
- console.log(e)
- $(this).attr('class', 'active');
- $(this).siblings().attr("class", "")
- let cur = e.target.id;
- $.ajax({
- url: baseUrl + 'order/heatMap',
- method: 'GET',
- data: {
- area_id: $("#choose ").val()
- },
- success: function (res) {
- var point = ''
- if (cur == 1) {
- point = res.start
- } else {
- point = res.end
- }
- heatmap.setDataSet({
- data: point,
- max: 100
- });
- }
- })
- })
- </script>
- </body>
- </html>
|