1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| <!DOCTYPE html> <html> <head> <title>风场测试</title> <meta charset="utf-8"/> <link rel="stylesheet" href="../lib/ol/ol.css" type="text/css"> <script src="../lib/ol/ol.js"></script> <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> <style> body,html{ width:100%; margin:0; padding:0; height: 100%; position:absolute; } .map{ width:100%; height:100%; position:absolute; } .save{ position: absolute; left: 200px; z-index: 10; } </style> </head> <body> <canvas id="canvas" style="position: absolute; z-index: 10; pointer-events: none;left: 0;top:0;bottom: 0;right: 0;"></canvas> <div class="map" id="map"></div> <script src="./js/windy.js"></script> <script> var asideVue={ projection: "EPSG:3857" } var DARK_BLUE = new ol.source.XYZ({ url: "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}" });
var basicMap = new ol.layer.Tile({source: DARK_BLUE}); var projection = "EPSG:3857"; var center = new ol.proj.fromLonLat([110, 24], projection); var mapExtent = ol.proj.transformExtent([-180, -85, 180, 85],'EPSG:4326', projection); var monitorMap = new ol.Map({ controls: ol.control.defaults({ attributionOptions: ({ collapsible: false }) }), layers:[basicMap], target: 'map', view: new ol.View({ projection: projection, center: center, extent: mapExtent, zoom: 4, maxZoom: 15, minZoom: 3, }) });
$.ajax({ url:"./gfs.json", success:function(data){ var canvas=monitorMap.getTargetElement().querySelector(".ol-unselectable"); var windy = new Windy({ canvas:document.getElementById('canvas'), data: data });
var mapSize = monitorMap.getSize(); var width = mapSize[0]; var height = mapSize[1]; var extent = monitorMap.getView().calculateExtent(mapSize); extent = new ol.proj.transformExtent(extent,asideVue.projection, 'EPSG:4326' ); windy.start( [[0,0],[width, height]], width, height, [[extent[0], extent[1]],[extent[2], extent[3]]] ); }, error:function(err){ console.log(err); } }) </script> </body> </html>
|