Adding a GeoServer layer as overlay

We will build a basic map with data from Google Maps API and Natural Earth Data published by GeoServer. The full code of the following example is contained in the google/geoserver_wms/index.html file from the code bundle. You can use the file as a reference; we will create it from scratch in the following steps:

  1. Open your text editor and create a new file, call it map.html and save it in the webapps/ROOT/geoserver_wms folder. The root folder is exposed, via HTTP protocol, from Tomcat. So the fastest way to publish your code is putting it there. Insert the following piece of code; it contains the basic for a static HTML page and a div element that is a reference to a map object we will create further:

Get GeoServer Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.