Skip to content

Commit

Permalink
Fix issue in some cases where focused area name doesn't appear
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Jul 31, 2024
1 parent feb285b commit 14aca2f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ var focusAreaGeoJsonBuffered;
var focusAreaBoundingBox;

function buildFocusAreaGeoJson() {
if (!focusedEntityInfo) return null
var id = omtId(focusedEntityInfo.id, focusedEntityInfo.type)
if (!focusedEntityInfo) return null;
var id = omtId(focusedEntityInfo.id, focusedEntityInfo.type);
var results = map.querySourceFeatures('openmaptiles', {
filter: [
"==", ["id"], id,
Expand All @@ -264,7 +264,16 @@ function buildFocusAreaGeoJson() {
sourceLayer: "landcover",
});
}
return compositeGeoJson(results);
var geoJson = compositeGeoJson(results);
if (!geoJson.properties.name) {
// park names are on a different layer for some reason
var poiResults = map.querySourceFeatures('openmaptiles', {
filter: ["==", ["id"], id],
sourceLayer: "poi",
});
if (poiResults.length) geoJson.properties = poiResults[0].properties;
}
return geoJson;
}
function loadFocusArea() {
focusAreaGeoJson = buildFocusAreaGeoJson();
Expand Down

0 comments on commit 14aca2f

Please sign in to comment.