This is an example script that shows how to implement geofencing using OpenLayers v4 and OpenStreetMap. In addition to showing useful debugging stats, it also shows how one might use closures to write functions that will only be called once - useful when building adventures 😉
See the Camden Adventure.
Note:
- The "Camden Town Hall" tag will appear and disappear as you enter and leave the town hall.
- The "auditorium" tag will appear once, the first time you enter the auditorium, and disappear whenever you leave it.
- The "small park" tag will appear when you enter the park for the first time, and won't disappear.
- The "Brunswick Square" tag will appear/disappear upon entering/leaving. Same as the Camden Town Hall.
The Onigo Example is a more bespoke example script for Onigo-like adventures.
The tags are as above, except the code will sequentially hide and show the tags/instructions while popping the sections so they don't get retriggered.
This code lives in the example_onigo
script.
The polygon selection tool is great for easily selecting polygons for use in geofencing. This code lives in the polygon_selection
script.