Compare commits
5 Commits
1374c1bc9d
...
068fc0fddd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
068fc0fddd
|
||
|
|
0631c710d2
|
||
|
|
0e9aa5a27f
|
||
|
|
481b80e0e7
|
||
|
|
b20634462e
|
BIN
data/van-100px.png
Normal file
BIN
data/van-100px.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
214
geo/poi.json
214
geo/poi.json
@@ -1,18 +1,200 @@
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start in Genoa"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
8.918618,
|
||||
44.407408
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start in Genoa"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
8.918618,
|
||||
44.407408
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Borgonovo"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
9.378806,
|
||||
44.391897
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Parma"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
10.327455,
|
||||
44.804661
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Legnago"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
11.311988,
|
||||
45.192941
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Treviso"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
12.245634,
|
||||
45.666013
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Udine"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
13.235893,
|
||||
46.064534
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Villach"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
13.843945,
|
||||
46.615745
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Bad Mitterndorf"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
13.931899,
|
||||
47.555034
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Fuschl am See"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
13.29709,
|
||||
47.802267
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Halfing"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
12.276169,
|
||||
47.951902
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in München"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
11.574704,
|
||||
48.137281
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Regensburg"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
12.094785,
|
||||
49.020419
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Rothenburg o. d. Tauber"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
10.179171,
|
||||
49.376898
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Start/Finish in Karlsruhe"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
8.404369,
|
||||
49.013486
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "Finish in Straßbourg"
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
7.767981,
|
||||
48.598389
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
312542
geo/route.json
312542
geo/route.json
File diff suppressed because it is too large
Load Diff
@@ -5,9 +5,11 @@
|
||||
<!-- <link rel="icon" type="image/x-icon" href="https://openlayers.org/favicon.ico" /> -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Road2Bitcoin Live Map</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
<div id="map"><div id="popup"></div></div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script type="module" src="./main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
107
main.js
107
main.js
@@ -1,9 +1,11 @@
|
||||
import './style.css';
|
||||
import {Map, View} from 'ol';
|
||||
import Feature from 'ol/Feature';
|
||||
import GeoJSON from 'ol/format/GeoJSON';
|
||||
import {Map, View} from 'ol';
|
||||
import Overlay from 'ol/Overlay';
|
||||
import Point from 'ol/geom/Point';
|
||||
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer';
|
||||
import {Icon, Stroke, Style} from 'ol/style';
|
||||
import {Circle as CircleStyle, Fill, Icon, Stroke, Style} from 'ol/style';
|
||||
import {OSM, Vector as VectorSource} from 'ol/source';
|
||||
import {useGeographic} from 'ol/proj';
|
||||
import geojsonRoute from './geo/route.json'
|
||||
@@ -33,9 +35,31 @@ const styles = {
|
||||
anchorYUnits: 'pixels',
|
||||
src: 'data/icon.png',
|
||||
}),
|
||||
}),
|
||||
iconVan: new Style({
|
||||
image: new Icon({
|
||||
anchor: [0.5, 16],
|
||||
anchorXUnits: 'fraction',
|
||||
anchorYUnits: 'pixels',
|
||||
src: 'data/van-100px.png',
|
||||
}),
|
||||
}),
|
||||
circleBlack: new Style({
|
||||
image: new CircleStyle({
|
||||
radius: 7,
|
||||
fill: new Fill({color: '#FF9900'}),
|
||||
stroke: new Stroke({
|
||||
color: 'white',
|
||||
width: 2,
|
||||
}),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
//
|
||||
// Route
|
||||
//
|
||||
|
||||
const lastStageFinished = 4;
|
||||
const stagesCompleted = geojsonRoute.features.slice(0, lastStageFinished);
|
||||
const stagesAhead = geojsonRoute.features.slice(lastStageFinished);
|
||||
@@ -59,18 +83,40 @@ const stagesAheadLayer = new VectorLayer({
|
||||
style: styles.lineGrey
|
||||
});
|
||||
|
||||
//
|
||||
// Points of Interest
|
||||
//
|
||||
|
||||
const vectorSourcePOI = new VectorSource({
|
||||
features: new GeoJSON().readFeatures(geojsonPOI),
|
||||
});
|
||||
|
||||
const poiLayer = new VectorLayer({
|
||||
source: vectorSourcePOI,
|
||||
style: styles.iconStop,
|
||||
style: styles.circleBlack,
|
||||
});
|
||||
|
||||
const vectorSourceVan = new VectorSource();
|
||||
|
||||
const vanFeature= new Feature({
|
||||
geometry: new Point([ 12.498556, 45.780383 ]),
|
||||
name: 'Support Van'
|
||||
});
|
||||
|
||||
vectorSourceVan.addFeature(vanFeature);
|
||||
|
||||
const vanLayer = new VectorLayer({
|
||||
source: vectorSourceVan,
|
||||
style: styles.iconVan
|
||||
});
|
||||
|
||||
//
|
||||
// Map initialization
|
||||
//
|
||||
|
||||
const view = new View({
|
||||
center: [10.6, 46.5],
|
||||
zoom: 6
|
||||
center: [10.6, 46.9],
|
||||
zoom: 6.6
|
||||
})
|
||||
|
||||
const map = new Map({
|
||||
@@ -81,7 +127,56 @@ const map = new Map({
|
||||
}),
|
||||
stagesCompletedLayer,
|
||||
stagesAheadLayer,
|
||||
poiLayer
|
||||
poiLayer,
|
||||
vanLayer
|
||||
],
|
||||
view: view
|
||||
});
|
||||
|
||||
//
|
||||
// Popups
|
||||
//
|
||||
const popupEl = document.getElementById('popup');
|
||||
|
||||
const popup = new Overlay({
|
||||
element: popupEl,
|
||||
positioning: 'bottom-center',
|
||||
stopEvent: false,
|
||||
});
|
||||
map.addOverlay(popup);
|
||||
|
||||
let popover;
|
||||
function disposePopover() {
|
||||
if (popover) {
|
||||
popover.dispose();
|
||||
popover = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// display popup on click
|
||||
map.on('click', function (evt) {
|
||||
const feature = map.forEachFeatureAtPixel(evt.pixel, function (feature) {
|
||||
return feature;
|
||||
});
|
||||
disposePopover();
|
||||
if (!feature) {
|
||||
return;
|
||||
}
|
||||
popup.setPosition(evt.coordinate);
|
||||
popover = new bootstrap.Popover(popupEl, {
|
||||
placement: 'top',
|
||||
html: true,
|
||||
content: feature.get('name'),
|
||||
});
|
||||
popover.show();
|
||||
});
|
||||
|
||||
// change mouse cursor when over marker
|
||||
map.on('pointermove', function (evt) {
|
||||
map.getTargetElement().style.cursor = map.hasFeatureAtPixel(evt.pixel)
|
||||
? 'pointer'
|
||||
: '';
|
||||
});
|
||||
|
||||
// Close the popup when the map is moved
|
||||
map.on('movestart', disposePopover);
|
||||
|
||||
Reference in New Issue
Block a user