| <!DOCTYPE html> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| <script src="data/map/encode.js"></script> |
| <script src="lib/simpleRequire.js"></script> |
| <script src="lib/config.js"></script> |
| <script src="lib/jquery.min.js"></script> |
| <script src="lib/facePrint.js"></script> |
| <script src="lib/testHelper.js"></script> |
| <!-- <script src="ut/lib/canteen.js"></script> --> |
| <link rel="stylesheet" href="lib/reset.css" /> |
| </head> |
| <body> |
| <style> |
| h1 { |
| line-height: 60px; |
| height: 60px; |
| background: #aaa; |
| text-align: center; |
| font-weight: bold; |
| color: #eee; |
| font-size: 14px; |
| } |
| |
| .chart { |
| width: 260px; |
| height: 150px; |
| display: inline-block; |
| } |
| </style> |
| |
| |
| <h1>Different Geometries</h1> |
| <div id="geometries"></div> |
| |
| |
| |
| <script> |
| function createGeoJSONFromGeo(name, geo) { |
| return { |
| type: 'FeatureCollection', |
| features: [{ |
| geometry: geo, |
| properties: { |
| name |
| } |
| }] |
| } |
| } |
| </script> |
| |
| |
| |
| <script> |
| require([ |
| 'echarts', |
| ], function (echarts) { |
| |
| function cloneJSON(json) { |
| return JSON.parse(JSON.stringify(json)); |
| } |
| function prepareAndRegisterMap(name, json) { |
| echarts.registerMap(name, createGeoJSONFromGeo(name, cloneJSON(json))); |
| echarts.registerMap(name + 'Compressed', encode(createGeoJSONFromGeo(name + 'Compressed', cloneJSON(json)))); |
| } |
| prepareAndRegisterMap('Polygon', { |
| "type": "Polygon", |
| "coordinates": [ |
| [[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]] |
| ] |
| }); |
| prepareAndRegisterMap('MultiPolygon', { |
| "type": "MultiPolygon", |
| "coordinates": [ |
| [ |
| [[30, 20], [45, 40], [10, 40], [30, 20]] |
| ], |
| [ |
| [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]] |
| ] |
| ] |
| }); |
| prepareAndRegisterMap('LineString', { |
| "type": "LineString", |
| "coordinates": [ |
| [30, 10], [10, 30], [40, 40] |
| ] |
| }); |
| prepareAndRegisterMap('MultiLineString', { |
| "type": "MultiLineString", |
| "coordinates": [ |
| [[10, 10], [20, 20], [10, 40]], |
| [[40, 40], [30, 30], [40, 20], [30, 10]] |
| ] |
| }); |
| prepareAndRegisterMap('HoleyMultiPolygon', { |
| "type": "MultiPolygon", |
| "coordinates": [ |
| [ |
| [[40, 40], [20, 45], [45, 30], [40, 40]] |
| ], |
| [ |
| [[20, 35], [10, 30], [10, 10], [30, 5], [45, 20], [20, 35]], |
| [[30, 20], [20, 15], [20, 25], [30, 20]] |
| ] |
| ] |
| }); |
| ['Polygon', 'MultiPolygon', 'LineString', 'MultiLineString', 'HoleyMultiPolygon'].forEach(map => { |
| ['', 'Compressed'].forEach(isCompressed => { |
| const dom = document.createElement('div'); |
| dom.className = 'chart'; |
| document.querySelector('#geometries').appendChild(dom); |
| const chart = echarts.init(dom); |
| chart.setOption({ |
| title: { |
| text: map + isCompressed, |
| textStyle: { |
| fontSize: 14 |
| } |
| }, |
| series: [{ |
| type: 'map', |
| map: map |
| }] |
| }); |
| }) |
| }); |
| }); |
| </script> |
| </body> |
| </html> |
| |