mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
fix: change default map location to Null Island
Apply sensible default zoom Distinguish people and orgs on map
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
const marker_fill_alpha = 1.0;
|
const marker_fill_alpha = 1.0;
|
||||||
const marker_edge_colour = 'white';
|
const marker_edge_colour = 'white';
|
||||||
const marker_fill_colour = 'gray';
|
|
||||||
|
|
||||||
// Size of the arrow markers used on the map
|
// Size of the arrow markers used on the map
|
||||||
const marker_scale = 7;
|
const marker_scale = 7;
|
||||||
@@ -36,13 +35,15 @@ function createMarker(map, marker_data) {
|
|||||||
strokeColor: marker_edge_colour,
|
strokeColor: marker_edge_colour,
|
||||||
strokeWeight: marker_edge_width,
|
strokeWeight: marker_edge_width,
|
||||||
strokeOpacity: marker_edge_alpha,
|
strokeOpacity: marker_edge_alpha,
|
||||||
fillColor: marker_fill_colour,
|
fillColor: marker_data.type === 'Organisation' ? '#669933' : '#0099cc',
|
||||||
fillOpacity: marker_fill_alpha,
|
fillOpacity: marker_fill_alpha,
|
||||||
scale: marker_scale,
|
scale: marker_scale,
|
||||||
labelOrigin: new google.maps.Point(0, -marker_label_offset)
|
labelOrigin: new google.maps.Point(0, -marker_label_offset)
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
marker.type = marker_data.type;
|
||||||
|
|
||||||
marker.info = new google.maps.InfoWindow({
|
marker.info = new google.maps.InfoWindow({
|
||||||
content: "<div id='content'>" +
|
content: "<div id='content'>" +
|
||||||
"<h3><a href=" + marker_data.url + ">" + marker_data.name.replace(''', "'") + "</a></h3>" +
|
"<h3><a href=" + marker_data.url + ">" + marker_data.name.replace(''', "'") + "</a></h3>" +
|
||||||
@@ -72,11 +73,12 @@ function initMap() {
|
|||||||
const markers_data = JSON.parse(
|
const markers_data = JSON.parse(
|
||||||
document.getElementById('map-markers').textContent)
|
document.getElementById('map-markers').textContent)
|
||||||
|
|
||||||
|
let markers_loaded = false
|
||||||
|
|
||||||
// For each data entry in the json...
|
// For each data entry in the json...
|
||||||
for (const marker_data of markers_data) {
|
for (const marker_data of markers_data) {
|
||||||
try {
|
try {
|
||||||
const marker = createMarker(map, marker_data);
|
const marker = createMarker(map, marker_data);
|
||||||
marker.type = marker_data.type;
|
|
||||||
markers.push(marker);
|
markers.push(marker);
|
||||||
|
|
||||||
bounds.extend(marker.position);
|
bounds.extend(marker.position);
|
||||||
@@ -85,16 +87,18 @@ function initMap() {
|
|||||||
selected_marker = marker;
|
selected_marker = marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
markers_loaded = true
|
||||||
|
|
||||||
} catch (exc) {
|
} catch (exc) {
|
||||||
// Just skip and move on to next
|
// Just skip and move on to next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
map.fitBounds(bounds)
|
map.fitBounds(bounds)
|
||||||
const max_zoom = 10
|
if (!markers_loaded) {
|
||||||
if (map.getZoom() > max_zoom) {
|
map.panTo({lat: 0, lng: 0})
|
||||||
map.setZoom(max_zoom)
|
|
||||||
}
|
}
|
||||||
|
setMaxZoom()
|
||||||
|
|
||||||
setTimeout(setMaxZoom, 100)
|
setTimeout(setMaxZoom, 100)
|
||||||
|
|
||||||
@@ -105,8 +109,8 @@ function initMap() {
|
|||||||
* Zoom to set level if map is zoomed in more than this.
|
* Zoom to set level if map is zoomed in more than this.
|
||||||
*/
|
*/
|
||||||
function setMaxZoom() {
|
function setMaxZoom() {
|
||||||
const max_zoom = 10
|
const max_zoom = 4
|
||||||
if (map.getZoom() > max_zoom) {
|
const min_zoom = 2
|
||||||
map.setZoom(max_zoom)
|
const zoom = Math.min(Math.max(min_zoom, map.getZoom()), max_zoom)
|
||||||
}
|
map.setZoom(zoom)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user