Skip to content

Commit a9b15b4

Browse files
committed
整合并增加了mapboxgl和leaflet中echarts的示例 reviewBy caoxinke
1 parent 2ff7ef6 commit a9b15b4

32 files changed

+1543
-59
lines changed

dist/iclient9-leaflet.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-leaflet.js

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59760,7 +59760,7 @@ var EchartsLayer = exports.EchartsLayer = _leaflet2["default"].Layer.extend({
5976059760
_echartsOptions: null,
5976159761

5976259762
options: {
59763-
attribution: "© 2017 百度 ECharts with <span>© <a href='http://iclient.supermapol.com' target='_blank'>SuperMap iClient</a></span>",
59763+
attribution: "© 2017 百度 ECharts with <span>© <a href='http://iclient.supermap.io/' target='_blank'>SuperMap iClient</a></span>",
5976459764
loadWhileAnimating: true
5976559765
},
5976659766

@@ -59933,13 +59933,64 @@ LeafletMapCoordSys.prototype.getBMap = function () {
5993359933
return this._LeafletMap;
5993459934
};
5993559935

59936+
LeafletMapCoordSys.prototype.prepareCustoms = function (data) {
59937+
var zrUtil = _echarts2["default"].util;
59938+
59939+
var rect = this.getViewRect();
59940+
return {
59941+
coordSys: {
59942+
// The name exposed to user is always 'cartesian2d' but not 'grid'.
59943+
type: 'leaflet',
59944+
x: rect.x,
59945+
y: rect.y,
59946+
width: rect.width,
59947+
height: rect.height
59948+
},
59949+
api: {
59950+
coord: zrUtil.bind(this.dataToPoint, this),
59951+
size: zrUtil.bind(dataToCoordSize, this)
59952+
}
59953+
};
59954+
59955+
function dataToCoordSize(dataSize, dataItem) {
59956+
dataItem = dataItem || [0, 0];
59957+
return zrUtil.map([0, 1], function (dimIdx) {
59958+
var val = dataItem[dimIdx];
59959+
var halfSize = dataSize[dimIdx] / 2;
59960+
var p1 = [];
59961+
var p2 = [];
59962+
p1[dimIdx] = val - halfSize;
59963+
p2[dimIdx] = val + halfSize;
59964+
p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
59965+
return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
59966+
}, this);
59967+
}
59968+
};
59969+
5993659970
LeafletMapCoordSys.prototype.dataToPoint = function (data) {
59971+
//处理数据中的null值
59972+
if (data[1] === null) {
59973+
data[1] = 85.4;
59974+
}
59975+
59976+
data[1] = this.fixLat(data[1]);
59977+
5993759978
var point = new _leaflet2["default"].latLng(data[1], data[0]);
5993859979
var px = this._LeafletMap.latLngToLayerPoint(point);
5993959980
var mapOffset = this._mapOffset;
5994059981
return [px.x - mapOffset[0], px.y - mapOffset[1]];
5994159982
};
5994259983

59984+
LeafletMapCoordSys.prototype.fixLat = function (lat) {
59985+
if (lat >= 90) {
59986+
return 89.99999999999999;
59987+
}
59988+
if (lat <= -90) {
59989+
return -89.99999999999999;
59990+
}
59991+
return lat;
59992+
};
59993+
5994359994
LeafletMapCoordSys.prototype.pointToData = function (pt) {
5994459995
var mapOffset = this._mapOffset;
5994559996
var point = this._LeafletMap.layerPointToLatLng([pt[0] + mapOffset[0], pt[1] + mapOffset[1]]);
@@ -90971,7 +91022,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9097191022
}
9097291023

9097391024
function Promise(fn) {
90974-
if (!(this instanceof Promise)) throw new TypeError('Promises must be constructed via new');
91025+
if (_typeof(this) !== 'object') throw new TypeError('Promises must be constructed via new');
9097591026
if (typeof fn !== 'function') throw new TypeError('not a function');
9097691027
this._state = 0;
9097791028
this._handled = false;
@@ -91095,9 +91146,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9109591146
};
9109691147

9109791148
Promise.all = function (arr) {
91149+
var args = Array.prototype.slice.call(arr);
91150+
9109891151
return new Promise(function (resolve, reject) {
91099-
if (!arr || typeof arr.length === 'undefined') throw new TypeError('Promise.all accepts an array');
91100-
var args = Array.prototype.slice.call(arr);
9110191152
if (args.length === 0) return resolve([]);
9110291153
var remaining = args.length;
9110391154

@@ -95904,7 +95955,7 @@ exports.names = ["Van_der_Grinten_I", "VanDerGrinten", "vandg"];
9590495955
/* 545 */
9590595956
/***/ (function(module, exports) {
9590695957

95907-
module.exports = {"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inBundle":false,"_integrity":"sha1-WtBui8owvg/6OJpJ5FZfUfBtCJ4=","_location":"/proj4","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"proj4@2.3.15","name":"proj4","escapedName":"proj4","rawSpec":"2.3.15","saveSpec":null,"fetchSpec":"2.3.15"},"_requiredBy":["/"],"_resolved":"http://registry.npm.taobao.org/proj4/download/proj4-2.3.15.tgz","_shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","_spec":"proj4@2.3.15","_where":"E:\\git\\iClient9","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"bundleDependencies":false,"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"~0.0.2"},"deprecated":false,"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","name":"proj4","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"}
95958+
module.exports = {"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inBundle":false,"_integrity":"sha1-WtBui8owvg/6OJpJ5FZfUfBtCJ4=","_location":"/proj4","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"proj4@2.3.15","name":"proj4","escapedName":"proj4","rawSpec":"2.3.15","saveSpec":null,"fetchSpec":"2.3.15"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz","_shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","_spec":"proj4@2.3.15","_where":"G:\\iClient9","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"bundleDependencies":false,"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"~0.0.2"},"deprecated":false,"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","name":"proj4","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"}
9590895959

9590995960
/***/ }),
9591095961
/* 546 */

dist/iclient9-leaflet.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/include-leaflet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
inputScript("https://cdn.bootcss.com/Turf.js/4.6.1/turf.min.js");
4747
}
4848
if (inArray(includes, 'echarts')) {
49-
inputScript("http://cdn.bootcss.com/echarts/3.6.2/echarts.min.js");
49+
inputScript("http://cdn.bootcss.com/echarts/3.8.0/echarts.min.js");
5050
}
5151
if (inArray(includes, 'd3')) {
5252
inputScript("https://cdn.bootcss.com/d3/4.10.2/d3.min.js");

examples/leaflet/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ var exampleConfig = {
560560
name_en: "ECharts",
561561
content: [
562562
{
563-
name: "散点地图",
563+
name: "全国空气质量图",
564564
name_en: "scatter",
565565
thumbnail: "l_echartsEffectScatter.png",
566566
fileName: "echartsEffectScatter"
@@ -612,6 +612,12 @@ var exampleConfig = {
612612
name_en: "pie chart",
613613
thumbnail: "l_echartsPie.png",
614614
fileName: "echartsPie"
615+
},
616+
{
617+
name: "世界飞机航线图",
618+
name_en: "Airplane route map",
619+
thumbnail: "l_echartsLinesAirline.png",
620+
fileName: "echartsLinesAirline"
615621
}
616622
]
617623

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>世界飞机航线图 with Leaflet</title>
6+
<script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
7+
</head>
8+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
9+
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
10+
<script type="text/javascript" include="echarts" src="../../dist/include-leaflet.js"></script>
11+
<script type="text/javascript">
12+
var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
13+
var tileURL = host + "/iserver/services/map-china400/rest/maps/ChinaDark";
14+
map = L.map('map', {
15+
crs: L.CRS.EPSG4326,
16+
center: [0, 0],
17+
maxZoom: 18,
18+
zoom: 2
19+
});
20+
L.supermap.tiledMapLayer(tileURL, {prjCoordSys: {"epsgCode": 4326}}).addTo(map);
21+
22+
$.get('../data/flights.json', function (data) {
23+
24+
function getAirportCoord(idx) {
25+
return [data.airports[idx][3], data.airports[idx][4]];
26+
}
27+
28+
var routes = data.routes.map(function (airline) {
29+
return [
30+
getAirportCoord(airline[1]),
31+
getAirportCoord(airline[2])
32+
];
33+
});
34+
35+
option = {
36+
title: {
37+
text: 'World Flights',
38+
left: 'center',
39+
textStyle: {
40+
color: '#eee'
41+
}
42+
},
43+
tooltip: {
44+
formatter: function (param) {
45+
var route = data.routes[param.dataIndex];
46+
return data.airports[route[1]][1] + ' > ' + data.airports[route[2]][1];
47+
}
48+
},
49+
50+
series: [{
51+
type: 'lines',
52+
coordinateSystem: 'leaflet',
53+
data: routes,
54+
large: true,
55+
largeThreshold: 100,
56+
lineStyle: {
57+
normal: {
58+
opacity: 0.05,
59+
width: 0.5,
60+
curveness: 0.3
61+
}
62+
},
63+
// 设置混合模式为叠加
64+
blendMode: 'lighter'
65+
}]
66+
};
67+
L.supermap.echartsLayer(option).addTo(map);
68+
});
69+
</script>
70+
</body>
71+
</html>
30.7 KB
Loading

examples/mapboxgl/01_measure_area.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@
5353

5454
function measureArea(e) {
5555
if (!e.features) {
56-
widgets.alert.showAlert
57-
alert("没有获取到数据,请重新绘制");
58-
return;
56+
widgets.alert.showAlert("没有获取到数据,请重新绘制", false);
5957
}
6058
var param = new SuperMap.MeasureParameters(e.features[0]);
6159
new mapboxgl.supermap.MeasureService(url).measureArea(param, function (serviceResult) {
6260
var area = serviceResult.result.area;
6361
var rounded_area = Math.round(area * 100) / 100;
64-
widgets.alert.showAlert(rounded_area + "平方米");
62+
widgets.alert.showAlert(rounded_area + "平方米", true);
6563
});
6664
}
6765

@@ -71,8 +69,6 @@
7169

7270
map.on('draw.create', measureArea);
7371
map.on('draw.delete', removeMsg);
74-
75-
7672
</script>
7773
</body>
7874
</html>

examples/mapboxgl/01_measure_distance.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
</head>
77
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
88
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
9-
<script type="text/javascript" include="bootstrap,jquery" src="../js/include-web.js"></script>
9+
<script type="text/javascript" include="bootstrap,jquery,widgets.alert" src="../js/include-web.js"></script>
1010
<script type="text/javascript" include="draw" src="../../dist/include-mapboxgl.js"></script>
1111
<script type="text/javascript">
1212
mapboxgl.accessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
13-
var alertDiv,
14-
host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
13+
var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
1514
var url = host + "/iserver/services/map-world/rest/maps/World";
1615
var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
1716
"| Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> " + " with <span>© <a href='http://iclient.supermap.io' target='_blank'>SuperMap iClient</a></span>";
@@ -56,13 +55,12 @@
5655

5756
function measureDistance(e) {
5857
if (!e.features) {
59-
alert("没有获取到数据,请重新绘制");
60-
return;
58+
widgets.alert.showAlert("没有获取到数据,请重新绘制", false);
6159
}
6260
var param = new SuperMap.MeasureParameters(e.features[0]);
6361
new mapboxgl.supermap.MeasureService(url).measureDistance(param, function (serviceResult) {
6462
var distance = serviceResult.result.distance;
65-
widgets.alert.showAlert(distance + "米");
63+
widgets.alert.showAlert(distance + "米", true);
6664
});
6765
}
6866

0 commit comments

Comments
 (0)