https://i.sstatic.net/uJiKZ.png
After testing the code below on your platform, I confirm that it is functioning as expected. Feel free to replace your current app.js code with the provided code snippet.
var map;
var markers = [];
/* MAP FILTER */
// Capture click on the input
jQuery(function () {
jQuery('input[name=filter]').change(function () {
var filterClickId = jQuery(this).attr('id');
MarkersFilter(filterClickId);
});
});
// Show or hide marker based on input state
function MarkersFilter(category){
if (document.getElementById(category).checked === false) { // Hide the marker
for (var i=0;i<markers.length;i++) {
if (markers[i].properties == category) {
markers[i].setVisible(false);
}
}
} else { // Show the marker
for (var i=0;i<markers.length;i++) {
if (markers[i].properties == category) {
markers[i].setVisible(true);
}
}
}
}
/* END OF MAP FILTER */
/* ICONS FOR DIFFERENT TYPES */
var iconBase = '/mapshapes/';
var icons = {
schools: {
icon :{
url: iconBase + 'schools_maps.svg',
scaledSize: new google.maps.Size(35, 35),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(0, 0)
}
},
commerce: {
icon: {
url: iconBase + 'commerce_maps.svg',
scaledSize: new google.maps.Size(35, 35),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(0, 0)
}
},
culture: {
icon:{
url: iconBase + 'culture_maps.svg',
scaledSize: new google.maps.Size(35, 35),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(0, 0)
}
},
health: {
icon:{
url : iconBase + 'health_maps.svg',
scaledSize: new google.maps.Size(35, 35),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(0, 0)
}
},
sports: {
icon:{
url: iconBase + 'sports_maps.svg',
scaledSize: new google.maps.Size(35, 35),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(0, 0)
}
},
safety: {
icon:{
url: iconBase + 'safety_maps.svg',
scaledSize: new google.maps.Size(35, 35),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(0, 0)
}
},
hospitality: {
icon:{
url: iconBase + 'hospitality_maps.svg',
scaledSize: new google.maps.Size(35, 35),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(0, 0)
}
},
publictransport: {
icon:{
url: iconBase + 'publictransport_maps.svg',
scaledSize: new google.maps.Size(35, 35),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(0, 0)
}
},
libris: {
icon:{
url: iconBase + 'libris.png',
scaledSize: new google.maps.Size(70, 70),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(0, 0)
}
}
};
function loadMarkers(map) {
var infoWindow = new google.maps.InfoWindow();
geojson_url = '/project.geojson';
jQuery.getJSON(geojson_url, function(result) {
data = result['locations'];
jQuery.each(data, function(key, val) {
var point = new google.maps.LatLng(parseFloat(val['geometry']['coordinates'][0]), parseFloat(val['geometry']['coordinates'][1]));
var titleText = val['properties']['name'];
var address = val['geometry']['address'];
var marker = new google.maps.Marker({
position: point,
title: titleText,
icon: icons[val['type']].icon,
map: map,
properties: val['type']
});
var markerInfo = "<div><h3>" + titleText + "</h3> " + address + "</div>";
marker.addListener('click', function() {
infoWindow.close();
infoWindow.setContent(markerInfo);
infoWindow.open(map, marker);
});
markers.push(marker);
});
var Marker = new MarkerClusterer(map, markers, {imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
Marker.addMarkers(markers);
});
}
/* CREATE MAP */
function initMap() {
map_options = {
zoom: 16,
center: {lat: 50.808757, lng: 4.314472},
styles: [
{
"featureType": "administrative",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#444444"
}
]
},
{
"featureType": "landscape",
"elementType": "all",
"stylers": [
{
"color": "#f2f2f2"
}
]
},
{
"featureType": "poi",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "road",
"elementType": "all",
"stylers": [
{
"saturation": -100
},
{
"lightness": 45
}
]
},
{
"featureType": "road.highway",
"elementType": "all",
"stylers": [
{
"visibility": "simplified"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "transit",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "water",
"elementType": "all",
"stylers": [
{
"color": "#46bcec"
},
{
"visibility": "on"
}
]
}
]
}
map_document = document.getElementById('projectmap');
map = new google.maps.Map(map_document,map_options);
loadMarkers(map);
}
google.maps.event.addDomListener(window, 'load', initMap);
https://i.sstatic.net/LmOd7.png