1
0
Fork 0

Merge pull request #1275 from myxor/osm_searchbox

OpenStreepMap custom: Add leaflet geosearch control
master
Gordon Williams 2022-01-12 13:58:38 +00:00 committed by GitHub
commit 1f744e8949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,7 @@
<head> <head>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" /> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
<link rel="stylesheet" href="../../css/spectre.min.css"> <link rel="stylesheet" href="../../css/spectre.min.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet-geosearch@3.6.0/dist/geosearch.css"/>
</head> </head>
<style> <style>
body { body {
@ -44,6 +45,7 @@
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="../../core/lib/heatshrink.js"></script> <script src="../../core/lib/heatshrink.js"></script>
<script src="../../core/lib/imageconverter.js"></script> <script src="../../core/lib/imageconverter.js"></script>
<script src="https://unpkg.com/leaflet-geosearch@3.6.0/dist/bundle.min.js"></script>
<script> <script>
/* /*
@ -79,6 +81,19 @@ TODO:
}); });
// Could optionally overlay trails: https://wiki.openstreetmap.org/wiki/Tiles // Could optionally overlay trails: https://wiki.openstreetmap.org/wiki/Tiles
// Search box:
const searchProvider = new window.GeoSearch.OpenStreetMapProvider();
const searchControl = new GeoSearch.GeoSearchControl({
provider: searchProvider,
style: 'button',
updateMap: true,
autoClose: true,
showMarker: false,
keepResult: true,
autoComplete: false
});
map.addControl(searchControl);
function onInit(device) { function onInit(device) {
if (device && device.info && device.info.g) { if (device && device.info && device.info.g) {
// On 3 bit devices, don't even offer the option. 3 bit is the only way // On 3 bit devices, don't even offer the option. 3 bit is the only way