WebGIS Leaflet
WebGIS Leaflet
Leaflet
Leaflet
Leaflet is the leading open-source JavaScript library for mobile-
friendly interactive maps.
Weighing just about 42 KB of JS, it has all the mapping features
most developers ever need
Leaflet is designed with simplicity, performance and usability in
mind.
It works efficiently across all major desktop and mobile platforms,
can be extended with lots of plugins, has a beautiful, easy to use
and well-documented API and a simple, readable source code that
is a joy to contribute to.
Version
Version Description
Stable version, released on MAY 18,
Leaflet 1.9.4
2023.
Previous stable version, released on
Leaflet 1.8.0
April 18, 2022.
In-progress version, developed on
Leaflet 2.0-dev
the main branch.
map.addLayer(layer);
!DOCTYPE html>
<html>
<head>
<title>Leaflet sample</title>
<link rel = "stylesheet" href = "http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/>
<script src = "http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
</head> <body>
<div id = "map" style = "width: 900px; height: 580px"></div>
<script>
// Creating map options
var mapOptions = {
center: [18.5204, 73.8567],
zoom: 10
}
// Creating a map object
var map = new L.map('map', mapOptions);
// Creating a Layer object
Creating a Layer object for layer from
geoserver
var layer1 = new
L.tileLayer.wms("http://localhost:8080/geoserver/ows?",{layers:'
rkd:IND_rails',transparent: true}).addTo(map);
Map providers
We can load the layers of various service providers such as
like open street map, Open Topo, Thunder forest, Hydda,
ESRI, Open weather, NASA GIBS, etc.
To do so, you need to pass their respective URL while creating
the TileLayer object:
http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png
Black And White
DE http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/ {y}.png
France http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png
Hot http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png
BZH http://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png
Markers
To mark a single location on the map, leaflet provides markers.
These markers use a standard symbol and these symbols can be
customized
How to add Marker?
Instantiate the Marker class by passing a latlng object
representing the position to be marked, as shown below.
var marker = L.marker([20.5937, 78.9629]);
marker.addTo(map)
Popups to the marker
To bind a simple popup displaying a message to a marker: