added open new tab on marker click

This commit is contained in:
fklinck 2019-05-29 15:48:38 +02:00
parent f4187a3385
commit 56ef2654a5
No known key found for this signature in database
GPG key ID: C0B6C62B8313F2A1
2 changed files with 9 additions and 5 deletions

View file

@ -32,16 +32,19 @@ let marker_icon = L.icon({
}); });
let callback = function OSMCallBack(location, data) { let callback = function OSMCallBack(location, data) {
var lat, lon; let lat, lon;
if (data.features.length >= 1) { if (data.features.length >= 1) {
var place = data.features[0].properties; let place = data.features[0].properties;
lat = data.features[0].geometry.coordinates[1]; lat = data.features[0].geometry.coordinates[1];
lon = data.features[0].geometry.coordinates[0]; lon = data.features[0].geometry.coordinates[0];
let marker = L.marker([lat, lon], { let marker = L.marker([lat, lon], {
icon: marker_icon icon: marker_icon
}).addTo(map) }).addTo(map)
.bindPopup(location.name + ', ' + location.address, {offset: new L.Point(0, -16)}); .bindPopup(location.name + ', ' + location.address, {offset: new L.Point(0, -16)}).on('click', function () {
let win = window.open(location.url, '_blank');
win.focus();
});
marker.on('mouseover', function(env) { marker.on('mouseover', function(env) {
marker.openPopup(); marker.openPopup();
@ -58,5 +61,5 @@ function loadmap(locations) {
for (let loc of locations) { for (let loc of locations) {
let request_uri = "https://photon.komoot.de/api/?limit=1&q=" + loc.address; let request_uri = "https://photon.komoot.de/api/?limit=1&q=" + loc.address;
performRequest(request_uri, loc, callback); performRequest(request_uri, loc, callback);
}; }
} }

View file

@ -27,7 +27,8 @@
{% if loc.address %} {% if loc.address %}
loc = { loc = {
"address": "{{loc.address}}", "address": "{{loc.address}}",
"name": "{{loc.name}}" "name": "{{loc.name}}",
"url": "{{ url_for('location', id=loc.id) }}"
}; };
locations.push(loc); locations.push(loc);