Posts

Showing posts from December, 2023

Hello world, leafletjs

In this post we'll explore a "hello world" using the open source leafletjs library. Step by Step: Include Leaflet: The HTML code includes the Leaflet CSS and JavaScript files from a CDN. Create a Map: The JavaScript code creates a map instance and sets its initial view using  L.map('map').setView([latitude, longitude], zoom) . Add Tile Layer: The  L.tileLayer  method adds a tile layer to the map, which provides the base map imagery. In this case, we're using OpenStreetMap tiles. Add a Marker: The  L.marker  method creates a marker at a specified location ( [51.5020469956198, -0.14175590508964123] ) and adds it to the map. Add a Popup: The  bindPopup  method attaches a popup to the marker, which will appear when the marker is clicked. Remember: Replace the coordinates in  setView  and  L.marker  with your desired locations. Explore Leaflet's extensive documentation for more features and cu...