123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <html>
- <head>
- <meta charset='utf-8'/>
- <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
- <title data-i18n="resources.title_GraphBar"></title>
- <style>
- body {
- margin: 0;
- padding: 0;
- }
- #map {
- position: absolute;
- top: 0;
- bottom: 0;
- width: 100%;
- }
- </style>
- </head>
- <body>
- <div id='map'></div>
- <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
- <script type="text/javascript" include="echarts" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
- <script type="text/javascript">
- var data;
- 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>" +
- " Image <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a> | </span>" +
- " <a href='https://echarts.baidu.com' target='_blank'>© 2018 " + resources.title_3baidu + " ECharts</a>";
- var host = window.isLocal ? window.server : "https://iserver.supermap.io";
- var tileURL = host + '/iserver/services/map-world/rest/maps/世界地图_Gray/zxyTileImage.png?prjCoordSys='+encodeURIComponent('{"epsgCode":3857}')+'&z={z}&x={x}&y={y}';
- var url = host + "/iserver/services/map-china400/rest/maps/China_4326";
- var chart, div, popup = '';
- var map = new mapboxgl.Map({
- container: 'map',
- style: {
- "version": 8,
- "sources": {
- "raster-tiles": {
- "attribution": attribution,
- "type": "raster",
- "tiles": [tileURL],
- "tileSize": 256,
- },
- },
- "layers": [{
- "id": "simple-tiles",
- "type": "raster",
- "source": "raster-tiles",
- "minzoom": 0,
- "maxzoom": 18
- }]
- },
- center: [120.14322240845, 30.236064370321],
- zoom: 5
- });
- map.addControl(new mapboxgl.NavigationControl(), 'top-left');
- map.loadImage('../img/marker-icon.png', function (error, image) {
- if (error) throw error;
- map.addImage('positionPoint', image);
- });
- option = {
- legend: {
- data: [resources.text_rainfall, resources.text_runoff],
- align: 'left'
- },
- toolbox: {
- feature: {
- magicType: {
- type: ['stack', 'tiled']
- },
- saveAsImage: {
- pixelRatio: 2
- }
- }
- },
- tooltip: {},
- xAxis: {
- data: [resources.text_monday, resources.text_tuesday, resources.text_wednesday, resources.text_thursday, resources.text_friday, resources.text_saturday, resources.text_sunday],
- silent: false,
- splitLine: {
- show: false
- }
- },
- yAxis: {},
- series: [{
- name: 'bar',
- type: 'bar',
- animationDelay: function (idx) {
- return idx * 10;
- }
- }, {
- name: 'bar2',
- type: 'bar',
- animationDelay: function (idx) {
- return idx * 10 + 100;
- }
- }],
- animationEasing: 'elasticOut',
- animationDelayUpdate: function (idx) {
- return idx * 5;
- }
- };
- div = document.createElement('div');
- chart = echarts.init(div, '', {
- width: 500,
- height: 300
- });
- chart.setOption(option);
- query();
- function query() {
- var sqlParam = new SuperMap.QueryBySQLParameters({
- queryParams: [{
- name: "China_ProCenCity_pt@China",
- attributeFilter: "1 = 1"
- }, {
- name: "China_Capital_pt@China",
- attributeFilter: "1 = 1"
- }]
- });
- queryService = new mapboxgl.supermap.QueryService(url).queryBySQL(sqlParam, function (serviceResult) {
- var recordsets = serviceResult && serviceResult.result && serviceResult.result.recordsets;
- features = recordsets && recordsets[0] && recordsets[0].features;
- map.addLayer({
- "id": "points",
- "type": "symbol",
- "layout": {
- "icon-image": "positionPoint",
- "icon-size": 0.8,
- "icon-offset": [0, -15] //设置偏移量
- },
- "source": {
- "type": "geojson",
- "data": features
- }
- });
- map.on('click', 'points', function (e) {
- popup = new mapboxgl.Popup({maxWidth: 'none'});
- popup.setLngLat(e.lngLat.toArray())
- .setDOMContent(div) // sets a popup on this marker
- .addTo(map);
- var data1 = [];
- var data2 = [];
- for (var i = 0; i < 7; i++) {
- var data = Math.random().toFixed(2);
- data1.push(data);
- data2.push(data * (Math.random() + 1.5));
- }
- chart.setOption({
- title: {
- text: e.features[0].properties.NAME,
- subtext: resources.text_fictitiouData
- },
- series: [
- {
- name: resources.text_rainfall,
- data: data1
- },
- {
- name: resources.text_runoff,
- data: data2
- }
- ]
- });
- });
- });
- }
- </script>
- </body>
- </html>
|