Advertisement
fdevibe

react-leaflet CDN issue

Jan 11th, 2025
375
0
169 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.41 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.   <head>
  4.     <meta charset="utf-8" />
  5.     <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
  6.     <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
  7.     <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
  8.  
  9.     <style>
  10.       #root {
  11.           height: 500px;
  12.           width: 100%;
  13.       }
  14.  
  15.       .leaflet-container {
  16.           width: 100%;
  17.           height: 100%;
  18.       }
  19.     </style>
  20.   </head>
  21.   <body>
  22.     <div id="root"></div>
  23.  
  24. <script type="text/babel" data-type="module">
  25.   import React from "https://esm.sh/react@19/?dev"
  26.   import ReactDOMClient from "https://esm.sh/react-dom@19/client?dev"
  27.   import {
  28.     MapContainer,
  29.     TileLayer,
  30.     Marker,
  31.     Popup,
  32.   } from 'https://cdn.esm.sh/react-leaflet@5.0.0'
  33.   const rootElement = ReactDOMClient.createRoot(document.getElementById('root'));
  34.   const position = [51.505, -0.09]
  35.   rootElement.render(
  36. <MapContainer center={position} zoom={13} scrollWheelZoom={false}>
  37.     <TileLayer
  38.      attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  39.       url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
  40.     />
  41.     <Marker position={position}>
  42.       <Popup>
  43.         A pretty CSS3 popup. <br /> Easily customizable.
  44.       </Popup>
  45.     </Marker>
  46. </MapContainer>,);
  47. </script>
  48.   </body>
  49. </html>
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement