|
| 1 | +<!--******************************************************************** |
| 2 | +* Copyright© 2000 - 2019 SuperMap Software Co.Ltd. All rights reserved. |
| 3 | +*********************************************************************--> |
| 4 | +<!DOCTYPE html> |
| 5 | +<html> |
| 6 | + <head> |
| 7 | + <meta charset="UTF-8" /> |
| 8 | + <title data-i18n="resources.title_widgetsHeatmap_Vue"></title> |
| 9 | + <script type="text/javascript" include="vue,jquery,papaparse" src="../js/include-web.js"></script> |
| 10 | + <script include="iclient9-mapboxgl-widgets-vue" src="../../dist/mapboxgl/include-mapboxgl.js"></script> |
| 11 | + <style> |
| 12 | + #main { |
| 13 | + margin: 0 auto; |
| 14 | + width: 100%; |
| 15 | + height: 100%; |
| 16 | + } |
| 17 | + </style> |
| 18 | + </head> |
| 19 | + |
| 20 | + <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;"> |
| 21 | + <div id="main"> |
| 22 | + <sm-map :map-options="mapOptions"> |
| 23 | + <sm-heatmap-layer :data="data" :paint="paint"></sm-heatmap-layer> |
| 24 | + </sm-map> |
| 25 | + </div> |
| 26 | + <script> |
| 27 | + var heatFeatures = [], |
| 28 | + heatMapSource, |
| 29 | + paint; |
| 30 | + $.get('../data/chinaEarthquake.csv', function(csvstr) { |
| 31 | + var data = Papa.parse(csvstr, { skipEmptyLines: true, header: true }).data; |
| 32 | + for (var i = 0; i < data.length; i += 6) { |
| 33 | + if (data[i].Y <= 85) { |
| 34 | + heatFeatures.push({ |
| 35 | + geometry: { |
| 36 | + coordinates: [parseFloat(data[i].X), parseFloat(data[i].Y)], |
| 37 | + type: 'Point', |
| 38 | + }, |
| 39 | + properties: { value: data[i].level / 50, id: i }, |
| 40 | + type: 'Feature', |
| 41 | + }); |
| 42 | + } |
| 43 | + } |
| 44 | + paint = { |
| 45 | + 'heatmap-intensity': ['interpolate', ['linear'], ['zoom'], 0, 1, 9, 3], |
| 46 | + 'heatmap-color': [ |
| 47 | + 'interpolate', |
| 48 | + ['linear'], |
| 49 | + ['heatmap-density'], |
| 50 | + 0, |
| 51 | + 'rgba(33,102,172,0)', |
| 52 | + 0.2, |
| 53 | + 'rgb(103,169,207)', |
| 54 | + 0.4, |
| 55 | + 'rgb(209,229,240)', |
| 56 | + 0.6, |
| 57 | + 'rgb(253,219,199)', |
| 58 | + 0.8, |
| 59 | + 'rgb(239,138,98)', |
| 60 | + 1, |
| 61 | + 'rgb(178,24,43)', |
| 62 | + ], |
| 63 | + 'heatmap-radius': ['interpolate', ['linear'], ['zoom'], 0, 2, 9, 20], |
| 64 | + 'heatmap-opacity': ['interpolate', ['linear'], ['zoom'], 7, 1, 9, 0], |
| 65 | + }; |
| 66 | + new Vue({ |
| 67 | + el: '#main', |
| 68 | + data() { |
| 69 | + var host = window.isLocal ? window.server : 'http://support.supermap.com.cn:8090'; |
| 70 | + var attribution = |
| 71 | + "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" + |
| 72 | + " with <span>© <a href='http://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" + |
| 73 | + " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> "; |
| 74 | + return { |
| 75 | + data: { |
| 76 | + type: 'FeatureCollection', |
| 77 | + features: heatFeatures, |
| 78 | + }, |
| 79 | + paint: paint, |
| 80 | + mapOptions: { |
| 81 | + container: 'map', // container id |
| 82 | + style: { |
| 83 | + version: 8, |
| 84 | + sources: { |
| 85 | + 'raster-tiles': { |
| 86 | + attribution: attribution, |
| 87 | + type: 'raster', |
| 88 | + tiles: [ |
| 89 | + host + |
| 90 | + '/iserver/services/map-china400/rest/maps/ChinaDark/zxyTileImage.png?z={z}&x={x}&y={y}', |
| 91 | + ], |
| 92 | + tileSize: 256, |
| 93 | + }, |
| 94 | + }, |
| 95 | + layers: [ |
| 96 | + { |
| 97 | + id: 'simple-tiles', |
| 98 | + type: 'raster', |
| 99 | + source: 'raster-tiles', |
| 100 | + minzoom: 0, |
| 101 | + maxzoom: 22, |
| 102 | + }, |
| 103 | + ], |
| 104 | + }, |
| 105 | + center: [120.143, 30.236], |
| 106 | + zoom: 3, |
| 107 | + }, |
| 108 | + }; |
| 109 | + }, |
| 110 | + }); |
| 111 | + }); |
| 112 | + </script> |
| 113 | + </body> |
| 114 | +</html> |
0 commit comments