Skip to content

Commit

Permalink
feat: ❇️ popup info windows on map
Browse files Browse the repository at this point in the history
  • Loading branch information
qthequartermasterman committed Dec 15, 2023
1 parent 2e15b13 commit e90ae81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
26 changes: 25 additions & 1 deletion render_map/map_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,37 @@
<script type="text/javascript">
let markers = [];
function addMarker(mapMarker, map){
const title = mapMarker.name;
let marker = new google.maps.Marker({
position: {lat: mapMarker.latitude, lng: mapMarker.longitude},
map: map,
title: mapMarker.title,
title: title,
icon: {url: mapMarker.icon, scaledSize: new google.maps.Size(20, 20)},
});
markers.push(marker);

const infoWindowContent = `
<div class="info-window">
<h3>${title}</h3>
</div>
`;
let infoWindow = new google.maps.InfoWindow({
content: infoWindowContent,
});

function openInfoWindow() {
infoWindow.open(map, marker);
setTimeout(closeInfoWindow, 3000)
}

function closeInfoWindow() {
infoWindow.close();
}

marker.addListener('click', openInfoWindow);
marker.addListener('mouseover', openInfoWindow);
infoWindow.addListener('closeclick', closeInfoWindow);
marker.addListener('mouseout', closeInfoWindow);
}

async function initMap() {
Expand Down
4 changes: 2 additions & 2 deletions render_map/render_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from render_map import map_style, map_icons
from bs4 import BeautifulSoup

# Sample Geo links
# Sample Deprecated Geo links
# [Foo Place](geo:-100.392,90)
# [Foo Place](geo:90.100, 93.00)
# [Foo Place](geo: 90.100, 93.00)
# [Foo Place](geo: 90.100, 93.00, VAULT)
DEPRECATED_GEO_LINKS_REGEX = re.compile(r"\[(?P<name>.*)\]\(geo:\s*(?P<lat>-?\d+\.?\d*),\s*(?P<lon>-?\d+\.?\d*)(?:,\s*(.*))?\)")
REPLACE_DEPRECATED_GEO_LINKS_WITH = """<geotag
latitude=$2
Expand Down

0 comments on commit e90ae81

Please sign in to comment.