Leaflet JS Example Code

Leaflet JS is an open source JavaScript library for adding simple and interactive web maps. It can add the map data to the map layers and has features like panning, zooming, etc that most of the applications require. This is an example code for integrating Leaflet JS on your webpage.

Steps to run the app locally

Assuming you already have Git and NPM installed on your system and know how to use command prompt/terminal.

  • Open command prompt (or terminal) and change the current working directory to location where you want to clone the repository.
  • Then type: git clone https://github.com/OptimalLearner/Leaflet-JS-Example-Code.git
  • If the clone was successfully completed then a new sub directory may appear with the same name as the repository.
  • Now change the currently directory to the new sub directory.
  • Install http server using this command: npm install --global http-server (This step can be skipped if you already have http-server installed)
  • Then simply return to main directory and run the http-server using this command: http-server -p 5500
  • Now you can access the app on http://localhost:5500/
  • You can even run the application if you have WAMP or XAMPP installed on your system.