Adding a KML layer
The arrival of Google Maps led to an explosion in the world of GIS and web mapping. Google introduced not only an API but also certain file formats.
The Keyhole Markup Language (KML) has become one of the most extensively-used formats, and it has become an OGC standard. For some more details on the KML standard, refer to https://en.wikipedia.org/wiki/Keyhole_Markup_Language. The following screenshot shows how to create vector layers from a KML file:
This recipe (found in ch03/ch03-kml-layer/
) will show you how easy it is to add features from a KML file. You can find the necessary files in the KML format attached to the source code of this book and available on the Packt Publishing website.
How to do it…
In order to import features from KML format into the map, follow these instructions:
- Create an HTML file that includes the OpenLayers dependencies and insert a
div
to contain the map:<div id="js-map"></div>
- Create the JavaScript file and initialize...