-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add maplibre, custom astro components, overview section
- Loading branch information
1 parent
685bc56
commit 77c79dc
Showing
11 changed files
with
2,832 additions
and
1,289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
# End-to-End Mapping | ||
|
||
Docs for how to use HOT's tools in an End-to-End data mapping flow. | ||
|
||
## Installing Components From Other Projects | ||
|
||
- If we are using hotosm/ui to build components in other repos. | ||
- Then we can install the repo: | ||
`pnpm install git+https://github.com/hotosm/fmtm#main&path:src/frontend` | ||
- And import the components to use from that repo: | ||
`import SomeButton from 'fmtm/src/components/some-button.ts` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script> | ||
import '@hotosm/ui/dist/style.css'; | ||
import { Button } from '@hotosm/ui/dist/hotosm-ui'; | ||
|
||
const button = document.getElementById('geojsonProperties'); | ||
button?.addEventListener('click', async () => { | ||
const endpoint = 'https://api.fmtm.hotosm.org/docs#/helper/append_required_geojson_properties_helper_append_geojson_properties_post'; | ||
|
||
const geojson = { | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [125.6, 10.1] | ||
} | ||
} | ||
] | ||
}; | ||
|
||
try { | ||
const response = await fetch(endpoint, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify(geojson) | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
|
||
const data = await response.json(); | ||
console.log('Success:', data); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
} | ||
}); | ||
</script> | ||
<hot-button id="geojsonProperties" variant="primary">Append GeoJSON Properties</hot-button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
export interface Props { | ||
latitude: number | ||
longitude: number | ||
zoom: number | ||
mapstyle: string | ||
container: string | ||
/** If `false`, the map will not respond to interaction. This is a static map built with the full web map rendering API. */ | ||
interactive?: boolean | ||
containerstyle?: string | ||
} | ||
const { latitude, longitude, zoom, mapstyle, container, interactive, containerstyle} = Astro.props | ||
--- | ||
|
||
<maplibre-astro | ||
data-latitude={latitude} | ||
data-longitude={longitude} | ||
data-zoom={zoom} | ||
data-mapstyle={mapstyle} | ||
data-container={container} | ||
data-interactive={interactive} | ||
data-containerstyle={containerstyle} | ||
> | ||
<div id={container} style={containerstyle}></div> | ||
|
||
<script> | ||
import 'maplibre-gl/dist/maplibre-gl.css'; | ||
import maplibre from 'maplibre-gl'; | ||
|
||
class MapLibreMap extends HTMLElement { | ||
constructor() { | ||
super() | ||
|
||
console.log(maplibre.Map) | ||
const map = new maplibre.Map({ | ||
container: this.dataset.container, | ||
interactive: JSON.parse(this.dataset.interactive), | ||
center: [this.dataset.longitude, this.dataset.latitude], | ||
zoom: this.dataset.zoom, | ||
style: this.dataset.mapstyle | ||
}) | ||
} | ||
} | ||
|
||
window.customElements.define("maplibre-astro", MapLibreMap); | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
title: E2E Mapping Overview | ||
description: An overview of the data flow in e2e mapping. | ||
--- | ||
|
||
This is an overview of the end-to-end workflow that ties together all | ||
of HOT's tools. | ||
|
||
The end goal is to enable communities to generate their own maps for their area | ||
of interest (neighbourhood, city, region), rich in data derived from local knowledge. | ||
|
||
<!-- diagrams.net e2e diagram --> | ||
<div | ||
class="mxgraph" | ||
style="max-width:100%;border:1px solid transparent;" | ||
data-mxgraph="{"highlight":"#0000ff","lightbox":false,"nav":true,"resize":true,"toolbar":"zoom","edit":"_blank","url":"https://raw.githubusercontent.com/hotosm/docs/main/docs/diagrams/e2e-ecosystem.drawio"}" | ||
></div> | ||
<script | ||
type="text/javascript" | ||
src="https://viewer.diagrams.net/embed2.js?&fetch=https%3A%2F%2Fraw.githubusercontent.com%2Fhotosm%2Fdocs%2Fmain%2Fdocs%2Fdiagrams%2Fe2e-ecosystem.drawio" | ||
></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: E2E Mapping Preparation | ||
description: Get started with the E2E mapping workflow. | ||
--- | ||
|
||
import Map from '../../../components/map/maplibre.astro'; | ||
|
||
To create a map, the first thing you need is an area defined to map! | ||
|
||
## Select Your Area Of Interest (AOI) | ||
|
||
Here we will generate an AOI than you wish to create a map for. | ||
|
||
<Map | ||
container="maplibremap" | ||
latitude="32.795595" | ||
longitude="-117.259191" | ||
zoom="3" | ||
interactive="true" | ||
mapstyle="https://demotiles.maplibre.org/style.json" | ||
containerstyle="width: 100%; height: 70vh;" | ||
></Map> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters