Skip to content

Commit f43bd58

Browse files
committed
Basic OpenIndexMap support
Closes #8
1 parent 3c02a57 commit f43bd58

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ <h1>OpenGeoMetadata Viewer Preview</h1>
117117
>
118118
Temperature (Points, GeoJSON)
119119
</button>
120+
<button
121+
data-record-url="https://raw.githubusercontent.com/OpenGeoMetadata/edu.stanford.purl/b74664cbb36fb985fe2ebee8d0d6d9657f06ada1/metadata-aardvark/zy/089/tj/2215/geoblacklight.json"
122+
>
123+
Peatland (Index Map, Polygons)
124+
</button>
125+
<button data-record-url="https://gist.githubusercontent.com/thatbudakguy/dcf881807aea33739a8cbb8fcefa42d0/raw/67b80876bdd17c21d654024bc77a1e4ece8a7fb6/hopkins.json">
126+
Hopkins (Index Map, Points)
127+
</button>
120128
<button
121129
data-record-url="https://raw.githubusercontent.com/OpenGeoMetadata/edu.stanford.purl/b74664cbb36fb985fe2ebee8d0d6d9657f06ada1/metadata-aardvark/cg/357/zz/0321/geoblacklight.json"
122130
>

src/lib/sources.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const getRecordSource = async (record: OgmRecord): Promise<AddSourceObject | und
112112
// Methods that create new sources are added here in order of preference
113113
// The first one that returns a valid source will be used
114114
await recordPMTilesSource(record),
115+
recordIndexMapGeoJSONSource(record),
115116
recordGeoJSONSource(record),
116117
recordWMSSource(record),
117118
recordTMSSource(record),
@@ -172,6 +173,23 @@ const recordGeoJSONSource = (record: OgmRecord): AddSourceObject | undefined =>
172173
};
173174
};
174175

176+
// Given a record, create a MapLibre GeoJSON source from an index map URL, if possible
177+
const recordIndexMapGeoJSONSource = (record: OgmRecord): AddSourceObject | undefined => {
178+
// If no index map reference, nothing to do
179+
const indexMapUrl = record.references.indexMapUrl;
180+
if (!indexMapUrl) return;
181+
182+
// Create a GeoJSON source with the record's ID and attribution
183+
return {
184+
id: record.id,
185+
source: {
186+
type: 'geojson',
187+
data: indexMapUrl,
188+
attribution: record.attribution,
189+
},
190+
};
191+
};
192+
175193
// Given a record, create a PMTiles source, if possible
176194
const recordPMTilesSource = async (record: OgmRecord): Promise<AddSourceObject | undefined> => {
177195
// If no PMTiles reference, nothing to do

0 commit comments

Comments
 (0)