new example
This commit is contained in:
1 parent
f16482b420
commit
6640d2d069
3 files changed
+94
No files matched your search
@@ -0,0 +1 @@
|
||||
{"message":"accurate","cod":"200","count":50,"list":[{"id":4337845,"name":"Port Fourchon","coord":{"lat":29.1058,"lon":-90.1945},"main":{"temp":299.63,"feels_like":299.63,"temp_min":299.63,"temp_max":299.63,"pressure":993,"humidity":92,"sea_level":993,"grnd_level":993},"dt":1630275030,"wind":{"speed":29.47,"deg":214},"sys":{"country":"US"},"rain":{"1h":5.62},"snow":null,"clouds":{"all":95},"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}]},{"id":4330751,"name":"Leeville","coord":{"lat":29.248,"lon":-90.2076},"main":{"temp":297.6,"feels_like":298.5,"temp_min":297.6,"temp_max":298.16,"pressure":988,"humidity":92,"sea_level":988,"grnd_level":988},"dt":1630275028,"wind":{"speed":31.43,"deg":213},"sys":{"country":"US"},"rain":{"1h":6.48},"snow":null,"clouds":{"all":88},"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}]},{"id":4323131,"name":"Dulac","coord":{"lat":29.3888,"lon":-90.714},"main":{"temp":297.59,"feels_like":298.47,"temp_min":297.59,"temp_max":297.59,"pressure":983,"humidity":91,"sea_level":983,"grnd_level":983},"dt":1630275025,"wind":{"speed":21.65,"deg":268},"sys":{"country":"US"},"rain":{"1h":8.65},"snow":null,"clouds":{"all":100},"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}]},{"id":4325859,"name":"Golden Meadow","coord":{"lat":29.3791,"lon":-90.2601},"main":{"temp":297.66,"feels_like":298.57,"temp_min":297.04,"temp_max":298.15,"pressure":982,"humidity":92,"sea_level":982,"grnd_level":982},"dt":1630275026,"wind":{"speed":27.31,"deg":210},"sys":{"country":"US"},"rain":{"1h":27.34},"snow":null,"clouds":{"all":93},"weather":[{"id":503,"main":"Rain","description":"very heavy rain","icon":"10d"}]},{"id":4319668,"name":"Chauvin","coord":{"lat":29.4386,"lon":-90.5954},"main":{"temp":297.59,"feels_like":298.52,"temp_min":297.59,"temp_max":297.6,"pressure":979,"humidity":93,"sea_level":979,"grnd_level":979},"dt":1630275025,"wind":{"speed":19.89,"deg":256},"sys":{"country":"US"},"rain":{"1h":11.53},"snow":null,"clouds":{"all":100},"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}]},{"id":4325424,"name":"Galliano","coord":{"lat":29.4422,"lon":-90.2992},"main":{"temp":297.63,"feels_like":298.56,"temp_min":297.04,"temp_max":298.15,"pressure":979,"humidity":93,"sea_level":979,"grnd_level":979},"dt":1630275026,"wind":{"speed":23.92,"deg":211},"sys":{"country":"US"},"rain":{"1h":31.58},"snow":null,"clouds":{"all":97},"weather":[{"id":503,"main":"Rain","description":"very heavy rain","icon":"10d"}]},{"id":4333695,"name":"Montegut","coord":{"lat":29.4744,"lon":-90.557},"main":{"temp":297.59,"feels_like":298.52,"temp_min":297.15,"temp_max":297.6,"pressure":977,"humidity":93,"sea_level":977,"grnd_level":977},"dt":1630275170,"wind":{"speed":18.27,"deg":252},"sys":{"country":"US"},"rain":{"1h":2.65},"snow":null,"clouds":{"all":100},"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}]},{"id":4343313,"name":"Terrebonne Parish","coord":{"lat":29.3766,"lon":-90.8501},"main":{"temp":297.59,"feels_like":298.47,"temp_min":297.59,"temp_max":297.59,"pressure":987,"humidity":91,"sea_level":987,"grnd_level":987},"dt":1630275031,"wind":{"speed":21.22,"deg":278},"sys":{"country":"US"},"rain":{"1h":9.99},"snow":null,"clouds":{"all":100},"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}]},{"id":4326198,"name":"Grand Isle","coord":{"lat":29.2366,"lon":-89.9873},"main":{"temp":298.16,"feels_like":299.14,"temp_min":298.16,"temp_max":298.16,"pressure":993,"humidity":93,"sea_level":993,"grnd_level":993},"dt":1630275026,"wind":{"speed":30.22,"deg":192},"sys":{"country":"US"},"rain":{"1h":6.48},"snow":null,"clouds":{"all":100},"weather":[{"id":502,"main":"Rain","description":"heavy intensity rain","icon":"10d"}]},{"id":4317709,"name":"Bourg","coord":{"lat":29.5536,"lon":-90.6023},"main":{"temp":297.57,"feels_like":298.57,"temp_min":297.04,"temp_max":298.15,"pressure":976,"humidity":96,"sea_level":976,"grnd_level":976},"dt":1630274970,"wind":{"speed":12.98,"deg":268},"sys":{"country":"US"},"rain":{"1h":0.15},"snow":null,"clouds":{"all":100},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}]},{"id":4321399,"name":"Cut Off","coord":{"lat":29.5427,"lon":-90.3381},"main":{"temp":297.6,"feels_like":298.56,"temp_min":297.04,"temp_max":298.15,"pressure":976,"humidity":94,"sea_level":976,"grnd_level":976},"dt":1630274970,"wind":{"speed":17.22,"deg":205},"sys":{"country":"US"},"rain":{"1h":17.76},"snow":null,"clouds":{"all":100},"weather":[{"id":503,"main":"Rain","description":"very heavy rain","icon":"10d"}]},{"id":4330185,"name":"Lafourche Parish","coord":{"lat":29.5669,"lon":-90.3834},"main":{"temp":297.59,"feels_like":298.6,"temp_min":297.04,"temp_max":298.15,"pressure":975,"humidity":96,"sea_level":975,"grnd_level":975},"dt":1630275170,"wind":{"speed":13.65,"deg":210},"sys":{"country":"US"},"rain":{"1h":2.69},Line truncated
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
layout: example.html
|
||||
title: Wind Arrows
|
||||
shortdesc: Example of Wind Arrows styled using Regular Shapes.
|
||||
docs: >
|
||||
This example shows wind arrows styled using regular shapes for the
|
||||
arrow shaft and head. The shaft is scaled based on the wind speed
|
||||
and a corresponding displacement is used to position the unscaled
|
||||
arrow head at the end of the scaled shaft.
|
||||
The weather data is provided by <a href="https://openweathermap.org/current">OpenWeather</a>.
|
||||
tags: "vector, symbol, regularshape, style, arrow"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
@@ -0,0 +1,80 @@
|
||||
import Feature from '../src/ol/Feature.js';
|
||||
import Map from '../src/ol/Map.js';
|
||||
import OSM from '../src/ol/source/OSM.js';
|
||||
import Point from '../src/ol/geom/Point.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import {Fill, RegularShape, Stroke, Style} from '../src/ol/style.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
|
||||
const shaft = new RegularShape({
|
||||
points: 2,
|
||||
radius: 20,
|
||||
stroke: new Stroke({
|
||||
width: 2,
|
||||
color: 'rgba(0,0,0,0.5)',
|
||||
}),
|
||||
rotateWithView: true,
|
||||
});
|
||||
|
||||
const head = new RegularShape({
|
||||
points: 3,
|
||||
radius: 10,
|
||||
fill: new Fill({
|
||||
color: 'rgba(0,0,0,0.5)',
|
||||
}),
|
||||
rotateWithView: true,
|
||||
});
|
||||
|
||||
const styles = [new Style({image: shaft}), new Style({image: head})];
|
||||
|
||||
const source = new VectorSource();
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new OSM(),
|
||||
}),
|
||||
new VectorLayer({
|
||||
source: source,
|
||||
style: function (feature) {
|
||||
const wind = feature.get('wind');
|
||||
// rotate arrow away from wind origin
|
||||
const angle = ((wind.deg - 180) * Math.PI) / 180;
|
||||
const scale = wind.speed / 10;
|
||||
shaft.setScale([1, scale]);
|
||||
shaft.setRotation(angle);
|
||||
head.setDisplacement([
|
||||
0,
|
||||
head.getRadius() / 2 + shaft.getRadius() * scale,
|
||||
]);
|
||||
head.setRotation(angle);
|
||||
return styles;
|
||||
},
|
||||
}),
|
||||
],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
zoom: 2,
|
||||
}),
|
||||
});
|
||||
|
||||
fetch('data/openweather/weather.json')
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
const features = [];
|
||||
data.list.forEach(function (report) {
|
||||
const feature = new Feature(
|
||||
new Point(fromLonLat([report.coord.lon, report.coord.lat]))
|
||||
);
|
||||
feature.setProperties(report);
|
||||
features.push(feature);
|
||||
});
|
||||
source.addFeatures(features);
|
||||
map.getView().fit(source.getExtent());
|
||||
});
|
||||
Reference in new issue
Block a user