Merge pull request #118 from ZeusWPI/feature/popup-link
added open new tab on marker click
This commit is contained in:
commit
2cd5fca66b
2 changed files with 9 additions and 5 deletions
|
@ -32,16 +32,19 @@ let marker_icon = L.icon({
|
|||
});
|
||||
|
||||
let callback = function OSMCallBack(location, data) {
|
||||
var lat, lon;
|
||||
let lat, lon;
|
||||
if (data.features.length >= 1) {
|
||||
var place = data.features[0].properties;
|
||||
let place = data.features[0].properties;
|
||||
lat = data.features[0].geometry.coordinates[1];
|
||||
lon = data.features[0].geometry.coordinates[0];
|
||||
|
||||
let marker = L.marker([lat, lon], {
|
||||
icon: marker_icon
|
||||
}).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.openPopup();
|
||||
|
@ -58,5 +61,5 @@ function loadmap(locations) {
|
|||
for (let loc of locations) {
|
||||
let request_uri = "https://photon.komoot.de/api/?limit=1&q=" + loc.address;
|
||||
performRequest(request_uri, loc, callback);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
{% if loc.address %}
|
||||
loc = {
|
||||
"address": "{{loc.address}}",
|
||||
"name": "{{loc.name}}"
|
||||
"name": "{{loc.name}}",
|
||||
"url": "{{ url_for('location', id=loc.id) }}"
|
||||
};
|
||||
locations.push(loc);
|
||||
|
||||
|
|
Loading…
Reference in a new issue