mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 03:17:07 +00:00
feature: add map of all people
This commit is contained in:
@@ -10,17 +10,26 @@ const marker_label_offset = 0.27 * marker_scale;
|
||||
const marker_edge_alpha = 1.0;
|
||||
const marker_edge_width = 1.0;
|
||||
|
||||
let map = null
|
||||
|
||||
// The function called when Google Maps starts up
|
||||
function initMap() {
|
||||
const centre_latlng = new google.maps.LatLng(settings.centre_lat, settings.centre_lng);
|
||||
// const centre_latlng = new google.maps.LatLng(settings.centre_lat, settings.centre_lng);
|
||||
// The map, centered at Soton
|
||||
const map = new google.maps.Map(
|
||||
document.getElementById('map'), { zoom: settings.zoom, center: centre_latlng });
|
||||
map = new google.maps.Map(
|
||||
// document.getElementById('map'), { zoom: settings.zoom, center: centre_latlng });
|
||||
document.getElementById('map'));
|
||||
|
||||
const bounds = new google.maps.LatLngBounds()
|
||||
const markers_data = JSON.parse(
|
||||
document.getElementById('map-markers').textContent
|
||||
).filter(data => data.lat !== null && data.lng !== null);
|
||||
|
||||
// For each data entry in the json...
|
||||
for (const pin_data of data) {
|
||||
for (const pin_data of markers_data) {
|
||||
// Get the lat-long position from the data
|
||||
const lat_lng = new google.maps.LatLng(pin_data.lat, pin_data.lng);
|
||||
console.log(lat_lng)
|
||||
|
||||
// Generate a new marker
|
||||
const marker = new google.maps.Marker({
|
||||
@@ -38,6 +47,10 @@ function initMap() {
|
||||
},
|
||||
});
|
||||
|
||||
console.log(marker)
|
||||
|
||||
bounds.extend(marker.position)
|
||||
|
||||
// Build the info window content to tell the user the last time it was visited.
|
||||
marker.info = new google.maps.InfoWindow({
|
||||
content: "<div id='content'>" +
|
||||
@@ -56,6 +69,25 @@ function initMap() {
|
||||
})
|
||||
}
|
||||
|
||||
map.fitBounds(bounds)
|
||||
const max_zoom = 10
|
||||
if (map.getZoom() > max_zoom) {
|
||||
map.setZoom(max_zoom)
|
||||
}
|
||||
|
||||
|
||||
// Set the last info window to null
|
||||
var last_info = null;
|
||||
|
||||
setTimeout(setMaxZoom, 100)
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom to set level if map is zoomed in more than this.
|
||||
*/
|
||||
function setMaxZoom() {
|
||||
const max_zoom = 10
|
||||
if (map.getZoom() > max_zoom) {
|
||||
map.setZoom(max_zoom)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user