123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <title data-i18n="resources.title_componentsMapV_React"></title>
- <script type="text/javascript" include="react,jquery" src="../js/include-web.js"></script>
- <script
- include="antd,iclient-mapboxgl-react,mapbox-gl-enhance,proj4,mapv"
- src="../../dist/mapboxgl/include-mapboxgl.js"
- ></script>
- <style>
- html,
- body {
- height: 100%;
- margin: 0;
- padding: 0;
- }
- #main {
- height: 100%;
- }
- </style>
- </head>
- <body>
- <div id="main"></div>
- <script type="text/babel">
- var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
- var attribution =
- "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
- " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
- " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
- var SmWebMap = SuperMap.Components.SmWebMap;
- var SmMapvLayer = SuperMap.Components.SmMapvLayer;
- var mapOptions = {
- container: 'map', // container id
- style: {
- version: 8,
- sources: {
- 'raster-tiles': {
- attribution: attribution,
- type: 'raster',
- tiles: [host + '/iserver/services/map-china400/rest/maps/ChinaDark/zxyTileImage.png?z={z}&x={x}&y={y}'],
- tileSize: 256
- }
- },
- layers: [
- {
- id: 'simple-tiles',
- type: 'raster',
- source: 'raster-tiles',
- minzoom: 0,
- maxzoom: 22
- }
- ]
- },
- center: [114.321317, 30.398428],
- zoom: 10
- };
- var lineMapvOptions = {
- strokeStyle: 'rgba(53,57,255,0.5)',
- coordType: 'bd09mc',
- shadowColor: 'rgba(53,57,255,0.2)',
- shadowBlur: 3,
- lineWidth: 3.0,
- draw: 'simple'
- };
- var pointMapvOptions = {
- fillStyle: 'rgba(255, 250, 250, 0.2)',
- coordType: 'bd09mc',
- globalCompositeOperation: 'lighter',
- size: 1.5,
- animation: {
- stepsRange: {
- start: 0,
- end: 100
- },
- trails: 3,
- duration: 5
- },
- draw: 'simple'
- };
- function addPopup(e) {
- var map = e.map;
- new mapboxgl.Popup({ closeOnClick: false })
- .setLngLat(map.getCenter())
- .setHTML(resources.text_iClient)
- .addTo(map);
- }
- $.get('../data/wuhan-car', function(rs) {
- // 构造数据
- var data = [];
- var timeData = [];
- rs = rs.split('\n');
- var maxLength = 0;
- for (var i = 0; i < rs.length; i++) {
- var item = rs[i].split(',');
- var coordinates = [];
- if (item.length > maxLength) {
- maxLength = item.length;
- }
- for (var j = 0; j < item.length; j += 2) {
- if (item.length === 1) {
- continue;
- }
- coordinates.push(proj4('EPSG:3857', 'EPSG:4326', [parseInt(item[j]), parseInt(item[j + 1])]));
- timeData.push({
- geometry: {
- type: 'Point',
- coordinates: proj4('EPSG:3857', 'EPSG:4326', [parseInt(item[j]), parseInt(item[j + 1])])
- },
- count: 1,
- time: j
- });
- }
- data.push({
- geometry: {
- type: 'LineString',
- coordinates: coordinates
- }
- });
- }
- var lineDataSet = new mapv.DataSet(data);
- var ponitDataSet = new mapv.DataSet(timeData);
- ReactDOM.render(
- <SmWebMap mapOptions={mapOptions} onLoad={addPopup}>
- <SmMapvLayer data={lineDataSet} options={lineMapvOptions} />
- <SmMapvLayer data={ponitDataSet} options={pointMapvOptions} />
- </SmWebMap>,
- document.getElementById('main')
- );
- });
- </script>
- </body>
- </html>
|