@jsm-mit/map-places-package
v0.1.0
Published
The package of map-places: address search (autocomplete) and reverse geocoding from an IC canister that holds an OpenStreetMap index.
Readme
@jsm-mit/map-places-package
The package of map-places: address search (autocomplete) and reverse geocoding from the
map-places-rust canister — an OpenStreetMap index of Nordrhein-Westfalen (© OpenStreetMap
contributors, ODbL) inside an Internet Computer canister. The canister answers anyone
(anonymous queries, no cost to the caller). Not published under this name yet: 0.1.0 was
published as @jsm-mit/tigi-geo-package.
import { errorKeyOf, isTimeoutError, MapPlacesActor } from "@jsm-mit/map-places-package";
const geo = new MapPlacesActor(canisterId); // mainnet by default
const search = await geo.searchPlacesAsyncUnsafe("Domkloster 4 Köln", {
near: position, // { lat, lng }: nearest first
limit: 5, // default 5, at most 10
lang: "pl", // "en" / "pl" names where OSM has them
timeoutMs: 3_000,
});
// search.places[i]: { label, area, location: { lat, lng }, kind } like the front's Place
// search.nearInArea === false → the rider is outside the index: ask Photon instead
const pin = await geo.reverseAsyncUnsafe(point); // { label: "Domkloster 4, Köln", area, location, kind, meters } | nullThe front falls back to Photon / Nominatim when the canister throws, when nearInArea is
false, when places is empty, or when reverseAsyncUnsafe gives null.
Errors: CanisterError with errorKeyOf(error) = NotReady (no index yet, or one of an
older format right after an upgrade), InvalidData (a point that is not on Earth);
Timeout (isTimeoutError); CriticalCanisterError (transport). A stopped canister (an
upgrade runs, IC0508/IC0509) is waited out within the time limit.
Local replica: new MapPlacesActor(localId, { host: "http://127.0.0.1:4943" }).
Scripts
npm run test-unit— no canister.npm run test-smoke— the canister from this tree on the LOCAL replica (deploys it, uploads the newestdata/*.tgiwhen the active index differs).npm run sync-declarations—declarations/map-places/from../map-places-rust.did.npm run publish-public— human-run; see the script for its refusals.
new MapPlacesActor() talks to the STAGE canister 4ogx7-4iaaa-aaaag-azhiq-cai (crafting-table slot
backend8, NRW index); give another id (and { host }) for a local replica.
