Leaflet - gher-uliege/Documentation GitHub Wiki

Leaflet is an open-source JavaScript library for mobile-friendly interactive maps.

Base layers

Issue a command such as:

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

Available layers (simply copy the javascript code corresponding to the layer):
https://leaflet-extras.github.io/leaflet-providers/preview/

More info:
http://leafletjs.com/reference-1.0.3.html#tilelayer

WMS

Straightforward if you have a Web Map Service.
Example with SOCIB salinity from operational model

var wmopWMS = "http://thredds.socib.es/thredds/wms/operational_models/oceanographical/hydrodynamics/model_run_aggregation/wmop/wmop_best.ncd";
var wmopTemperatureLayer = L.tileLayer.wms(wmopWMS, {
				layers: 'salt',
}).addTo(map)

More info:
http://leafletjs.com/reference-1.0.3.html#tilelayer-wms

GeoJSON layers

From shape files

  • Download files from GADM
  • Open the shape file with QGIS
  • Click on Layer / Save as... and in the window chose EPSG:4326 (WGS84) as the Selected CRS.

qgisconversion