大家一直期待會有下一代出現
但除了Google與Esri合作的 Desktop 版之外
到目前為止仍沒有Web版的替代方案
於是有需求的人都轉向open source去了
接下來介紹這個 WebGL Earth http://www.webglearth.org/
由javascript所構成
官方網站上也有一些example可以看 http://examples.webglearth.com/
接下來我們就來初體驗一下吧
Hello word
指定寬高的div圖台
- <!DOCTYPE HTML>
- <html>
- <head>
- <script src="http://www.webglearth.com/v2/api.js"></script>
- <script>
- function initialize() {
- var options = {
- zoom: 3.0,
- position: [24.176899, 120.651872]
- };
- var earth = new WE.map('earth_div', options);
- WE.tileLayer('http://data.webglearth.com/natural-earth-color/{z}/{x}/{y}.jpg', {
- tileSize: 256,
- tms: true
- }).addTo(earth);
- }
- </script>
- </head>
- <body onload="initialize()">
- <h1>WebGL Earth API: Hello World</h1>
- <div id="earth_div" style="width:1024px;height:768px;border:1px solid gray; padding:2px;"></div>
- </body>
- </html>
全螢幕的圖台
- <!DOCTYPE HTML>
- <html>
- <head>
- <script src="http://www.webglearth.com/v2/api.js"></script>
- <script>
- function initialize() {
- var options = { zoom: 10.0, position: [24.176899, 120.651872] };
- var earth = new WE.map('earth_div', options);
- WE.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
- attribution: '© OpenStreetMap contributors'
- }).addTo(earth);
- }
- </script>
- <style>
- html,
- body {
- padding: 0;
- margin: 0;
- }
- #earth_div {
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- position: absolute !important;
- }
- </style>
- <title>WebGL Earth API: Hello World2</title>
- </head>
- <body onload="initialize()">
- <div id="earth_div"></div>
- </body>
- </html>
套疊多個底圖
- <!DOCTYPE HTML>
- <html>
- <head>
- <script src="http://www.webglearth.com/v2/api.js"></script>
- <script>
- function initialize() {
- var options = { zoom: 10.0, position: [24.176899, 120.651872] };
- var earth = new WE.map('earth_div', options);
- WE.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
- attribution: '© OpenStreetMap contributors'
- }).addTo(earth);
- /*
- WE.tileLayer('http://data.webglearth.com/natural-earth-color/{z}/{x}/{y}.jpg', {
- tileSize: 256,
- tms: true
- }).addTo(earth);
- */
- var toner = WE.tileLayer('http://tile.stamen.com/toner/{z}/{x}/{y}.png', {
- attribution: 'Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.',
- opacity: 0.6
- });
- toner.addTo(earth);
- }
- </script>
- <style>
- html,
- body {
- padding: 0;
- margin: 0;
- }
- #earth_div {
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- position: absolute !important;
- }
- </style>
- <title>WebGL Earth API: Overlays</title>
- </head>
- <body onload="initialize()">
- <div id="earth_div"></div>
- </body>
- </html>
Markers
劃設點位- <!DOCTYPE HTML>
- <html>
- <head>
- <script src="http://www.webglearth.com/v2/api.js"></script>
- <script>
- function initialize() {
- var options = { zoom: 15.0, position: [24.176899, 120.651872] };
- var earth = new WE.map('earth_div', options);
- WE.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
- attribution: '© OpenStreetMap contributors'
- }).addTo(earth);
- var marker1 = WE.marker([24.176899, 120.651872]).addTo(earth);
- marker1.bindPopup("<b>Marker!</b><br>I am a popup.<br /><span style='font-size:10px;color:#999'>Tip: 逢甲大學..</span>", {maxWidth: 150, closeButton: true}).openPopup();
- var marker2 = WE.marker([24.172357, 120.645607], 'marker.png', 24, 34).addTo(earth);
- marker2.bindPopup("<table><tr><td><b>沒有Close的Marker</b></td></tr><tr><td>我在西屯路</td></tr><tr><td><img src='test.jpg'></td></tr></table>", {maxWidth: 120, closeButton: false});
- }
- </script>
- <style>
- html,
- body {
- padding: 0;
- margin: 0;
- }
- #earth_div {
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- position: absolute !important;
- }
- </style>
- <title>WebGL Earth API: Markers</title>
- </head>
- <body onload="initialize()">
- <div id="earth_div"></div>
- </body>
- </html>
劃設Polygon
- <!DOCTYPE HTML>
- <html>
- <head>
- <script src="http://www.webglearth.com/v2/api.js"></script>
- <script>
- function initialize() {
- var options = { zoom: 15.0, position: [24.176899, 120.651872] };
- var earth = new WE.map('earth_div', options);
- WE.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
- attribution: '© OpenStreetMap contributors'
- }).addTo(earth);
- var polygonA = WE.polygon([[24.176233, 120.651915], [24.176194, 120.658825],
- [24.174941, 120.659812], [24.171770, 120.661056], [24.169656, 120.656207], [24.173219, 120.655563]]
- );
- polygonA.addTo(earth);
- var polygonB = WE.polygon([[24.172475, 120.645521], [24.171718, 120.647055],
- [24.171241, 120.647540], [24.171963, 120.648408], [24.171276, 120.649199], [24.170333, 120.649671],
- [24.169565, 120.649161], [24.168482, 120.647566], [24.168901, 120.647004], [24.169926, 120.645945],
- [24.171369, 120.644248]], {
- color: '#f0f',
- opacity: 1,
- fillColor: '#0f0',
- fillOpacity: 0.5,
- editable: true,
- weight: 2
- }).addTo(earth);
- }
- </script>
- <style>
- html,
- body {
- padding: 0;
- margin: 0;
- }
- #earth_div {
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- position: absolute !important;
- }
- </style>
- <title>WebGL Earth API: Polygon</title>
- </head>
- <body onload="initialize()">
- <div id="earth_div"></div>
- </body>
- </html>
目前所提供的功能都還算是陽春
沒辦法直接套疊shape file或kml
Point或Polygon都要轉成json才能套疊
提供有興趣的人參考看看
沒有留言:
張貼留言