Time for action – extending ol.control.Control to make your own control
Let's get started. Contrary to most examples, it will need more code than usual. So, to keep things simple, we will explain how to build the sample by retrieving the various code files instead of inlining it. After these operations, we will focus on the important parts of the code to understand them:
- Go to the samples directory and retrieve all the
css
class with theexport-geojson
string fromassets/css/samples.css
and copy paste them in your ownsamples.css
file. Next, retrieve a new JavaScript file from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js into a new subdirectory,assets/js
. - If you don't already have it from Chapter 8, Interacting with Your Map ...
Get OpenLayers 3 : Beginner's Guide now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.