Planning to create a hybrid app? Plan to use a GPS in it? Then this template is for you!
The webinterface folder is created automatically by qgis2web plug-in of qgis. If you create a new map and use the qgis2web plugin, this template is very compatible. Although I did some changes inside the qgis2web.js in order to cater manual mode (setting the gps coordinate manually) so keep that in mind when changing webinterface content.
This template doesnt search or compare coordinate locations, but you can make your own one. Just use this Javascript methods to get your current location.
I think OpenLayers (The one that made this template possible) has its own method of comparing coordinates, you can use that too!
if (typeof(geolocation.getPosition()) === "undefined" && manualmode == false) {
return false;
}
if (manualmode) {
coords = manualcoords;
}
else {
coords = geolocation.getPosition();
}
// Assume that we have a list of coordinates (objects that contain
// x and y values). We compare each one of them using the classic
// formula of [distance between two points]
// (http://www.mathwarehouse.com/algebra/distance_formula/index.php)
// then push it to an array called selected
for (var i = 0; i < list.length; i++) {
var icon = list[i];
var dist = Math.sqrt(Math.pow((coords[0] - icon.x), 2) + Math.pow((coords[1] - icon.y), 2));
// If distance is close to the 2500m radius, then it is included
if (dist <= 2500) {
selected.push(icon);
}
}
A preview of this template: click here to redirect