Simply map.js

This commit is contained in:
Edward Betts 2021-05-09 23:41:39 +02:00
parent 662df3dde2
commit 470a206138

View file

@ -91,9 +91,7 @@ function add_to_feature_group(qid, thing) {
if (items[qid].group === undefined) items[qid].group = L.featureGroup(); if (items[qid].group === undefined) items[qid].group = L.featureGroup();
var group = items[qid].group; var group = items[qid].group;
thing.addTo(group); thing.addTo(group);
return group; return group;
} }
@ -110,21 +108,19 @@ function update_wikidata() {
var osm_list = osm_objects[qid]; var osm_list = osm_objects[qid];
var item = wikidata_items[qid]; var item = wikidata_items[qid];
if (!item) {
osm_list.forEach((osm) => {
osm.marker.setIcon(osmOrangeMarker);
});
continue;
}
if (item.lines === undefined) item.lines = []; osm_list.forEach((osm) => {
osm.marker.setIcon(item ? osmYellowMarker : osmOrangeMarker);
});
if (!item) continue;
item.markers.forEach((marker_data) => { item.markers.forEach((marker_data) => {
marker_data.marker.setIcon(greenMarker); marker_data.marker.setIcon(greenMarker);
osm_list.forEach((osm) => { osm_list.forEach((osm) => {
var path = [osm.centroid, marker_data]; var path = [osm.centroid, marker_data];
var polyline = L.polyline(path, { color: "green" }); var polyline = L.polyline(path, { color: "green" });
add_to_feature_group(qid, polyline); add_to_feature_group(qid, polyline);
item.lines.push(polyline);
}); });
}); });
} }
@ -316,13 +312,8 @@ function load_wikidata_items() {
if (osm.type != "node" && osm.geojson) { if (osm.type != "node" && osm.geojson) {
var mapStyle = { fillOpacity: 0 }; var mapStyle = { fillOpacity: 0 };
var geojson = L.geoJSON(null, { style: mapStyle }); var geojson = L.geoJSON(null, { style: mapStyle });
add_to_feature_group(qid, geojson);
geojson.addData(osm.geojson); geojson.addData(osm.geojson);
add_to_feature_group(qid, geojson);
if (items[qid] === undefined) items[qid] = {};
if (items[qid].geojson === undefined) items[qid].geojson = [];
items[qid].geojson.push(geojson);
} }
}); });