Skip to content

Commit

Permalink
update to index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
jjimenezshaw committed Jan 6, 2024
1 parent 2b7053d commit 56736de
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,37 @@ <h2>Content</h2>
style: style
});

var singleFeatureSource = new ol.source.Vector({});

var styleSingleFeature = new ol.style.Style({
stroke : new ol.style.Stroke(
{
color : 'rgba(255, 0, 0, 1)',
width : 3
}),
fill : new ol.style.Fill(
{
color : 'rgba(255, 0, 0, 0.1)'
})
});

var singleFeatureLayer = new ol.layer.Vector({
source: singleFeatureSource,
style: styleSingleFeature
});

function updateSingleFeatureLayer(geometry) {
singleFeatureSource.clear();

if (geometry) {
var json = new ol.format.GeoJSON();
var feature = new ol.Feature({
geometry: json.readGeometry(geometry)
});
singleFeatureSource.addFeature(feature);
}
}

function agencies_selector(checked) {
list_agencies.forEach(function(id){
document.getElementById('id_checkbox_' + id).checked = checked;
Expand Down Expand Up @@ -303,7 +334,8 @@ <h2>Content</h2>
var map = new ol.Map({
layers: [
new ol.layer.Tile({source: new ol.source.OSM()}),
featureLayer],
featureLayer,
singleFeatureLayer],
renderer: 'canvas',
target: 'map',
overlays: [overlay],
Expand Down Expand Up @@ -335,7 +367,11 @@ <h2>Content</h2>
var props = feature.getProperties();

details_innerHTML += '<hr>';
details_innerHTML += '<p><a href="' + props.name + '">' + props.name + '</a>: '
var writer = new ol.format.GeoJSON();
var geoJson = props.geometry ? writer.writeGeometry(props.geometry) : '';
details_innerHTML += '<p onmouseout="updateSingleFeatureLayer()" ';
details_innerHTML += " onmouseover='updateSingleFeatureLayer(" + geoJson + ")'>"; // geoJson contains double quotes
details_innerHTML += '<a href="' + props.name + '">' + props.name + '</a>: '
if( props.area_of_use ) {
details_innerHTML += props.area_of_use + ', ';
}
Expand Down

0 comments on commit 56736de

Please sign in to comment.