Skip to content

Commit

Permalink
changed geocoder service url to our own service
Browse files Browse the repository at this point in the history
  • Loading branch information
p3t3r67x0 committed Dec 10, 2024
1 parent a81f261 commit c482ef9
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,38 +87,27 @@ L.tileLayer('https://tiles.oklabflensburg.de/sgm/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="dc:rights">OpenStreetMap</a> contributors'
}).addTo(map)

let geocoder = L.Control.Geocoder.nominatim()
let previousSelectedMarker = null
let dataObject = null
let cluster = null


if (typeof URLSearchParams !== 'undefined' && location.search) {
// parse /?geocoder=nominatim from URL
const params = new URLSearchParams(location.search)
const geocoderString = params.get('geocoder')

if (geocoderString && L.Control.Geocoder[geocoderString]) {
console.log('Using geocoder', geocoderString)
geocoder = L.Control.Geocoder[geocoderString]()
}
else if (geocoderString) {
console.warn('Unsupported geocoder', geocoderString)
}
}
const geocoder = L.Control.Geocoder.nominatim({
serviceUrl: 'https://nominatim.oklabflensburg.de/'
})

const osmGeocoder = new L.Control.geocoder({
query: 'Flensburg',
const control = L.Control.geocoder({
geocoder,
position: 'topright',
placeholder: 'Adresse oder Ort',
defaultMarkGeocode: false
}).addTo(map)

osmGeocoder.on('markgeocode', (e) => {
control.on('markgeocode', (e) => {
const bounds = L.latLngBounds(e.geocode.bbox._southWest, e.geocode.bbox._northEast)
map.fitBounds(bounds)
})

let previousSelectedMarker = null
let dataObject = null
let cluster = null


function addDistrictsLayer(data) {
L.geoJson(data, {
style: layerStyle.standard
Expand Down

0 comments on commit c482ef9

Please sign in to comment.