mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
refactor: clean up unused bits of map.js
This commit is contained in:
@@ -1,14 +1,6 @@
|
|||||||
const marker_main_alpha_never = 1.0;
|
const marker_fill_alpha = 1.0;
|
||||||
const marker_main_alpha_future = 1.0;
|
|
||||||
const marker_main_alpha = 1.0;
|
|
||||||
|
|
||||||
const marker_main_colour_never = 'grey';
|
|
||||||
const marker_main_colour_future = 'white';
|
|
||||||
|
|
||||||
const marker_edge_colour = 'white';
|
const marker_edge_colour = 'white';
|
||||||
const marker_edge_colour_never = 'white';
|
const marker_fill_colour = 'gray';
|
||||||
const marker_edge_colour_future = 'black';
|
|
||||||
|
|
||||||
|
|
||||||
// Size of the arrow markers used on the map
|
// Size of the arrow markers used on the map
|
||||||
const marker_scale = 9;
|
const marker_scale = 9;
|
||||||
@@ -22,22 +14,6 @@ const settings = {
|
|||||||
zoom: 5
|
zoom: 5
|
||||||
}
|
}
|
||||||
|
|
||||||
// const data = [
|
|
||||||
// {lat: 0, lng: 0, name: 'a'},
|
|
||||||
// {lat: 1, lng: 1, name: 'b'},
|
|
||||||
// {lat: 2, lng: 2, name: 'c'},
|
|
||||||
// ]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Pull settings from the settings var
|
|
||||||
// const time_after = filters.time_after;
|
|
||||||
// const time_before = filters.time_before;
|
|
||||||
// Set up a colour scale that goes from blue to red via yellow, over time_limit days
|
|
||||||
// const visitedColour = d3.scaleSequential(d3.interpolateRdYlBu)
|
|
||||||
// .domain([filters.time_after, filters.time_before]);
|
|
||||||
|
|
||||||
|
|
||||||
// The function called when Google Maps starts up
|
// The function called when Google Maps starts up
|
||||||
function initMap() {
|
function initMap() {
|
||||||
const centre_latlng = new google.maps.LatLng(0, 0);
|
const centre_latlng = new google.maps.LatLng(0, 0);
|
||||||
@@ -46,31 +22,30 @@ function initMap() {
|
|||||||
document.getElementById('map'), { zoom: settings.zoom, center: centre_latlng });
|
document.getElementById('map'), { zoom: settings.zoom, center: centre_latlng });
|
||||||
|
|
||||||
// For each data entry in the json...
|
// For each data entry in the json...
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (const pin_data of data) {
|
||||||
// Get the lat-long position from the data
|
// Get the lat-long position from the data
|
||||||
var lat_lng = new google.maps.LatLng(data[i].lat, data[i].lng);
|
const lat_lng = new google.maps.LatLng(pin_data.lat, pin_data.lng);
|
||||||
|
|
||||||
// Generate a new marker
|
// Generate a new marker
|
||||||
var marker = new google.maps.Marker({
|
const marker = new google.maps.Marker({
|
||||||
position: lat_lng, map: map,
|
position: lat_lng,
|
||||||
|
map: map,
|
||||||
icon: {
|
icon: {
|
||||||
path: google.maps.SymbolPath.BACKWARD_CLOSED_ARROW,
|
path: google.maps.SymbolPath.BACKWARD_CLOSED_ARROW,
|
||||||
strokeColor: edgeColourByTime(data[i]),
|
strokeColor: marker_edge_colour,
|
||||||
strokeWeight: marker_edge_width,
|
strokeWeight: marker_edge_width,
|
||||||
strokeOpacity: marker_edge_alpha,
|
strokeOpacity: marker_edge_alpha,
|
||||||
fillColor: mainColourByTime(data[i]),
|
fillColor: marker_fill_colour,
|
||||||
fillOpacity: alphaByTime(data[i]),
|
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)
|
||||||
},
|
},
|
||||||
label: (data[i].type === 'school' ? '🎓' : '')
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Build the info window content to tell the user the last time it was visited.
|
// Build the info window content to tell the user the last time it was visited.
|
||||||
marker.info = new google.maps.InfoWindow({
|
marker.info = new google.maps.InfoWindow({
|
||||||
content: "<div id='content'>" +
|
content: "<div id='content'>" +
|
||||||
"<h3><a href=" + data[i].url + ">" + data[i].name.replace(''', "'") + "</a></h3>" +
|
"<h3><a href=" + pin_data.url + ">" + pin_data.name.replace(''', "'") + "</a></h3>" +
|
||||||
(data[i].hasOwnProperty('lastvisit') ? "<p>Last visited " + data[i].lastvisit + "</p>" : "<p>Never visited</p>") +
|
|
||||||
"</div>"
|
"</div>"
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,40 +63,3 @@ function initMap() {
|
|||||||
// Set the last info window to null
|
// Set the last info window to null
|
||||||
var last_info = null;
|
var last_info = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function mainColourByTime(d) {
|
|
||||||
if (!d.hasOwnProperty('time')) {
|
|
||||||
return marker_main_colour_never;
|
|
||||||
} else if (d.time > time_after) {
|
|
||||||
return visitedColour(time_after);
|
|
||||||
} else if (d.time < time_before) {
|
|
||||||
return marker_main_colour_future;
|
|
||||||
} else {
|
|
||||||
return visitedColour(d.time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edgeColourByTime(d) {
|
|
||||||
if (!d.hasOwnProperty('time')) {
|
|
||||||
return marker_edge_colour_never;
|
|
||||||
} else if (d.time > time_after) {
|
|
||||||
return marker_edge_colour;
|
|
||||||
} else if (d.time < time_before) {
|
|
||||||
return marker_edge_colour_future;
|
|
||||||
} else {
|
|
||||||
return marker_edge_colour;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function alphaByTime(d) {
|
|
||||||
if (!d.hasOwnProperty('time')) {
|
|
||||||
return marker_main_alpha_never;
|
|
||||||
} else if (d.time > time_after) {
|
|
||||||
return marker_main_alpha;
|
|
||||||
} else if (d.time < time_before) {
|
|
||||||
return marker_main_alpha_future;
|
|
||||||
} else {
|
|
||||||
return marker_main_alpha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user