2.0.0 • Published 1 year ago

astro-geo-map v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

🚀  Astro — Geographical map embed (Leaflet)

Embed interactive geographical maps in your webpage.
Using Leaflet.js under the hood.

📦  Installation

pnpm i astro-geo-map

# Optional
pnpm i -D @types/leaflet

🛠  Usage

---
import { GeoMap } from 'astro-geo-map';
// ...
---
<!-- ... -->
<body>
  <!-- Place component inside `BODY` tag -->

  <GeoMap
    x={43.389636 /* Required */}
    y={5.3964332 /* Required */}
    z={11}
    height={'25rem' /* Required */}
    width={'25rem'}
    attribution={true}
  />

  <!-- ... -->
</body>

Vite client-side fix

You might want to add this to your astro.config:

export default defineConfig({
  /* ... */
  vite: { optimizeDeps: { include: ['leaflet'] } },
});

So client-side, third-party JS will be loaded properly, instead of getting this error:

SyntaxError: Importing binding name 'default' cannot be resolved by star

If dependency issues persists, try installing leaflet@1.9.0.

To do

  • SSR rendered placeholder, for when JS is unavailable

LIVE DEMO  🎭  DOCUMENTATION WEBSITE ⎋

Live demo website

code.juliancataldo.com


Other projects:


🔗  JulianCataldo.com