• Stars
    star
    184
  • Rank 209,187 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is the leaflet plugin for GeoServer. Using this plugin user can have access to wms and wfs request easily.

Documentation leaflet-geoserver-request

DOI Build Status GitHub release (latest by date) GitHub file size in bytes npm

This is the plugin for Geoserver various kind of requests. Using this plugin, we can make WMS, WFS, getLegendGraphic, WMS-Image request.

demo

Video tutorial

Youtube Video

Installation and setup

  • using NPM:
npm install leaflet-geoserver-request
  • Quick use :
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="[path to js]/L.Geoserver.js"></script>

Web-Map-Service (WMS) Request

WMS request will provides georeferenced map image.

var wmsLayer = L.Geoserver.wms("http://localhost:8080/geoserver/wms", {
  layers: "topp:tasmania_roads",
});
wmsLayer.addTo(map);
WMS options
Option Type Default Description
layers string undefined This is required filed. If you have multiple layers, you can add them in a comma seperated values: "workspace:layer1,workspace:layer2"
format string image/png formate of the wms request. It may be image/jpeg, image/tiff, application/openlayers
transparent boolean true transparent of the map
CQL_FILTER string INCLUDE To filter the layer based on their attribute. read more about this
zIndex integer 1000 zIndex of the layer
attribution string layer attribution of the layer. It will be added at the bottom-left cornor of the map
style string undefined style file associated with that layer. If you didn't provide the style field, it will take default style of the layer

Web-Feature-Service (WFS) Request

In WFS request, you need to enable the jsonp for GeoServer. By default, jsonp for GeoServer was desabled. open $GEOSERVER_HOME\webapps\geoserver\WEB-INF\web.xml file and uncomment following line,

<context-param>
    <param-name>ENABLE_JSONP</param-name>
    <param-value>true</param-value>
</context-param>

Note: WFS request only applicable for vector layer, not for raster

var wfsLayer = L.Geoserver.wfs("http://localhost:8080/geoserver/wfs", {
  layers: "topp:tasmania_roads",
});
wfsLayer.addTo(map);
WFS options
Options Type Default Description
layers string undefined This is required filed. If you have multiple layers, you can add them in a comma seperated values: "workspace:layer1,workspace:layer2"
style js object/function null The style file can be in form of javascript oject or function. eg `style = {color: "black",fillOpacity: "0", opacity: "0.5" }
onEachFeature function null Common region to add this feature is to add popup when the layer cicked. more detail
CQL_FILTER string INCLUDE To filter the layer based on their attribute. read more about this
fitLayer boolean true The map automatically zoomed into the loaded data region

Web-Mapping-Service-Image (WMSImage) request

This is the custom request naming by me. It will generate the image which will zoomed to the desired location. The main different between wms and wmsImage request is, it can be zoomed to the desired location based on vector layer.

There are certain convention for this request. Please read carefully

  • The first layer must be vector layer in option wmsLayers. Rest of other layers can be vector or raster

  • You need to provide the same number of data list in wmsLayers, wmsCQL_FILTER & wmsStyle fields

  • The map will zoomed to the first parameter of wmsCQL_FILTER region

  • The default value for the style and cql_filter will be include

  • The wmsLayers and wmsId fields are required field

<img src="" id="wmsImage" />
<!-- The id field is required. This id will used in js script option "wmsId"-->
L.Geoserver.wmsImage("http://localhost:8080/geoserver/wms", {
  wmsLayers: [
    "workspace:first_layer",
    "workspace:second_layer",
    "workspace:third_layer",
  ],
  wmsCQL_FILTER: ["district=='Syangja'", "INCLUDE", "INCLUDE"],
  wmsStyle: ["style1", "style2", "INCLUDE"],
  format: "image/png",
  wmsId: "wmsImage",
  width: 300,
  height: 300,
});

Legend Request

The legend request will provide the crossponding legend of the layer to the bottom-left position of the map. In case of not providing style parameter, it will take the default style from GeoServer.

var layerLegend = L.Geoserver.legend("http://localhost:8080/geoserver/wms", {
  layers: "topp:tasmania_roads",
  style: `stylefile`,
});

layerLegend.addTo(map);

Advance WFS request demo

var wfsLayerAdvance = L.Geoserver.wfs("http://localhost:8080/geoserver/wms", {
  layers: "topp:tasmania_roads",
  style: {
    color: "black",
    fillOpacity: "0",
    opacity: "0.5",
  },
  onEachFeature: function (feature, layer) {
    layer.bindPopup("this is popuped");
  },
  CQL_FILTER: "district='Syangja'",
});

map.fitBounds(wfsLayerAdvance.getBounds());
wfsLayerAdvance.addTo(map);

Contribution:

Would โค๏ธ to see any contributions.

Appreciate:

If you liked my work, show some โค๏ธ by โญ repo.

Also you can appreciate by

Buy Me A Coffee PayPal Logo

More Repositories

1

Leaflet-Basic

This contains basic codes on leaflet programming. It includes some important plugins of leaflet & some other different technique for analysis the map.
JavaScript
156
star
2

deep-learning-for-earth-observation

Application of deep learning for earth observation.
Jupyter Notebook
69
star
3

geodjango-from-dev-to-deployment

This is the repo for the course: "Web mapping and Web-GIS from Dev to Deploy 2021: GeoDjango".
JavaScript
50
star
4

leaflet-geojson-vt

Open-source library for loading the geojson vector tiles.
JavaScript
41
star
5

geotile

GeoTile is the python library for tiling the geographic raster data (eg. Tiff etc)
Python
36
star
6

awesome-geospatial-data-download-sites

This is the repo for open source geospatial data download sites.
30
star
7

landslide4sense-solution

This repo is the solution for landslide4Sense challenge.
Jupyter Notebook
27
star
8

geospatial-data-analysis-python

This repo contain the most common tools used in geospatial analysis using python!
Jupyter Notebook
24
star
9

geospatial-machine-learning

Machine learning in geospatial data
Jupyter Notebook
16
star
10

pySLD

The library is useful for generating the SLD file for raster as well as vector datasets. The package can generate 4 types of styles, Simple style, Categorized style, Classified style, Raster style.
Python
15
star
11

Deep-learning-for-satellite-imagery

This repo contains the code for satellite image analysis using deep learning.
Jupyter Notebook
15
star
12

DL-for-LULC-prediction

This is the ResNet50 implementation of the Eurosat dataset.
Jupyter Notebook
14
star
13

geodjango-udemy

This is the repo for udemy geodjango tutorial: Course link, https://www.udemy.com/course/introduction-to-web-mapping-and-web-gis-2020-geodjango/?referralCode=72E09BDD6D9C8ECE2169
JavaScript
12
star
14

GIS-portal

This is the repo for the Web GIS development 2021 course on udemy. Check out the course here: https://www.udemy.com/course/web-gis-development-2021/?referralCode=488F271341990F62FD05
JavaScript
11
star
15

geodjango-app

This is the simple geodjango app, in which user can add the locational information from django-admin and the location information will be shown in the homepage.
Python
10
star
16

leaflet-training

The leaflet part website is hosted here: https://iamtekson.github.io/leaflet-training/index.html
JavaScript
9
star
17

iamtekson

5
star
18

deep-housing-webGIS

This is our final year project named as "Web-GIS Based Utility Management System". The static page related to this project is find here:
TSQL
5
star
19

Geo-Cooker

ESRI Hackathon 2023
JavaScript
4
star
20

Online-house-purchasing-website

Django Real State website
CSS
4
star
21

WRC-webmap

JavaScript
4
star
22

json2Geojson

JavaScript
3
star
23

Web-GIS

This Web-GIS is hosted at
HTML
3
star
24

visit-nepal-2020

This repo is the initiation promotion of #Visit-Nepal-2020. I am trying to develop the tourism friendly web-app which will be helpful for making there plans.
JavaScript
2
star
25

simple-website-Geomapping

You can show the live preview of this page at:
HTML
2
star
26

map-generator

This is the simple choropleth map generator function using php and javascript.
JavaScript
2
star
27

My-protofolio-website

v1.0.0 note: This is just static website about myself. HTML, CSS, JS, Bootstrap is used for this project. v2.0.0 note: This is the website made by using JS and PHP (MySQL database).
PHP
2
star
28

geoserver-training

This repo contain the code during GeoServer training session 3 organized by GESAN and OSGeo Nepal
JavaScript
1
star
29

GLOF-simulation

The repository contain the GLOF methodology, code, literature review and steps to produce a result.
Jupyter Notebook
1
star
30

postgres-helper

Python
1
star
31

GESAN-Website

This is just a static website of "Geomatics Engineering Students' Association Nepal" made by using HTML, CSS, Js and Bootstrap.
CSS
1
star
32

web-map-template-for-utility-management

The following code is hosted at:
HTML
1
star