[GIS] Tips for learning to work with geoserver in Javascript

geoserverhtmljavascript

After succesfully being able to work with the ArcGIS Javascript API in a webpage I want to learn to work with Geoserver. I have downloaded Geoserver and uploaded one shapefile. Now I am trying to call this shapefile from a Javascript/HTML script. For the ArcGIS Javascript API there is a lot of documentation. For geoserver a lot less is to be found. All I found is this: http://docs.geoserver.org/2.6.x/en/user/community/scripting/js/api/index.html#geoserver-javascript-api-documentation

I am not succeeding with just that. Could any of you give me a source or advise to learn more about working with geoserver in a webpage?

Best Answer

It depends on the javascript client you are using (e.g. Leaflet, OpenLayers, Google Maps API, ESRI javascript API, etc.), and what you are trying to publish (WFS, WMS, etc.).

For OpenLayers, you can preview the layer through the admin UI and get a good idea of how it works (view the page source after the preview loads): http://docs.geoserver.org/stable/en/user/webadmin/layerpreview/index.html

For Leaflet, here is a small code sample to show how you might publish a WMS layer:

var map = L.map('map').setView([51.505, -0.09], 8);
var forest2000 = L.tileLayer.wms("http://138.26.24.157:8080/geoserver/tiger/wms",{
    layers: 'forest2000',
    format: 'image/png',
    transparent: true,    
    opacity: 0.7       
}).addTo(map);