Skip to content

Commit

Permalink
Created buffer around trace extent, improved stroke
Browse files Browse the repository at this point in the history
jeffyactive committed Aug 28, 2024
1 parent a4fac5a commit bf42e6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions common/js/treknav.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,11 @@ const vectorSource = new ol.source.Vector({});
const vectorLayer = new ol.layer.Vector({ source: vectorSource,
style: setFeatureStyle });

// Constants
const TRACE_WIDTH = 12;
const TRACE_COLOUR = ol.color.asArray([ 0, 0, 0, 0.5 ]);
const EXTENSION_FACTOR = 0.25;

let sections;

// Retrieve the trek sections for navigation
@@ -69,10 +74,11 @@ function updateMap(json) {

let extent = vectorSource.getExtent();
let center = ol.extent.getCenter(extent);
let extension = ol.extent.getWidth(extent) * EXTENSION_FACTOR;
let view = new ol.View({
projection: 'EPSG:4326',
showFullExtent: true,
extent: extent,
extent: ol.extent.buffer(extent, extension),
center: center,
zoom: 6
});
@@ -82,5 +88,6 @@ function updateMap(json) {

// Set the style of the feature (simply increasing stroke width for visibility)
function setFeatureStyle(feature) {
return new ol.style.Style({ stroke: new ol.style.Stroke({ width: 3 }) });
let stroke = new ol.style.Stroke({ width: TRACE_WIDTH, color: TRACE_COLOUR });
return new ol.style.Style({ stroke: stroke });
}

0 comments on commit bf42e6a

Please sign in to comment.