Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin

- `type` query parameter to filter collections based on their type (`Function` or `Table`)
- fixed a small bug in the `tipg_properties` SQL function where the bounds property was not properly transformed to 4326 (author @RemcoMeeuwissen, https://github.com/developmentseed/tipg/pull/87)
- added popups to leaflet maps on `items` and `item` page. (author @krishnaglodha, https://github.com/developmentseed/tipg/pull/91)

## [0.2.0] - 2023-06-22

Expand Down
18 changes: 17 additions & 1 deletion tipg/templates/item.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,23 @@ <h2>Properties</h2>
attribution: 'Map data &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
}
));
var features = L.geoJSON(geojson).addTo(map);
function addPopup(feature, layer) {
if (feature.properties) {
//popup HTML
var HTMLContent = '<div style="overflow-x:scroll">'
Object.keys(geojson.properties).map(prop => {
HTMLContent += `<b>${prop}</b> : ${geojson.properties[prop]} <br>`

})
HTMLContent += `</div>`

layer.bindPopup(HTMLContent);
}
}
var features = L.geoJSON(geojson, {
onEachFeature: addPopup
}).addTo(map);

map.fitBounds(features.getBounds());
</script>

Expand Down
9 changes: 8 additions & 1 deletion tipg/templates/items.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ <h1>Collection Items: {{ response.title or response.id }}</h1>
</div>

<script>
var currentURL = "{{ template.api_root }}/collections/{{ response.id }}/items"
function changePageSize() {
var url = "{{ template.api_root }}/collections/{{ response.id }}/items?";
url += "limit=" + $("#limit").val();
Expand All @@ -95,7 +96,13 @@ <h1>Collection Items: {{ response.title or response.id }}</h1>
attribution: 'Map data &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
}
));
var features = L.geoJSON(geojson).addTo(map);
function addPopup(feature, layer) {
HTMLContent = `<a target="_blank" href="${currentURL}/${feature.id}">${feature.id}</a>`
layer.bindPopup(HTMLContent);
}
var features = L.geoJSON(geojson, {
onEachFeature: addPopup
}).addTo(map);
map.fitBounds(features.getBounds());

//
Expand Down