How to run OpenLayers using localhost?

I already installed Apache Tomcat and GeoServer war.

In what folder should I place all the OpenLayers file?

closed as too broad by Midavalo Feb 25 at 4:22

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Please edit your question to include details of what you've attempted and what happens when you try it – Midavalo Feb 25 at 4:23

Openlayers is Javascript library which runs within html page. If it is plain html page than you can run it from wherever you want. If you run OpenLayers within web app (written in PHP, Python or similar) than you might need a web server. Here is basic setup instructions for OpenLayers: https://openlayers.org/en/latest/doc/quickstart.html

If you have enough skills you can build OpenLayers app: https://openlayers.org/en/latest/doc/tutorials/bundle.html

Tomcat runs geoserver and geoserver serves spatial data through OGC services such as WMS, WFS which can Openlayers then serve and show within HTML page. Example of displaying WMS layer: https://openlayers.org/en/latest/examples/wms-tiled.html

Example of displaying WFS layer: https://openlayers.org/en/latest/examples/vector-wfs.html

Example of displaying GeoJSON file: https://openlayers.org/en/latest/examples/geojson.html


You can put your HTML and JavaScript pages in the www directory of your GeoServer data directory. GeoServer will then serve it at http://localhost:8080/geoserver/mypage.html (or whatever you call your page). This will avoid any cross-origin request issues and avoids the need for another server.

Not the answer you're looking for? Browse other questions tagged or ask your own question.