google.maps.event.addDomListener(window, 'load', init);
var map;
function init() {
var mapOptions = {
center: new google.maps.LatLng(51.527528,-0.081033),
zoom: 15,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.DEFAULT,
},
disableDoubleClickZoom: true,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
},
scaleControl: true,
scrollwheel: true,
panControl: true,
streetViewControl: true,
draggable : true,
overviewMapControl: true,
overviewMapControlOptions: {
opened: false,
},
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [
{
"stylers": [
{ "visibility": "on" },
{ "saturation": -100 },
{ "gamma": 0.54 }
]
},{
"featureType": "road",
"elementType": "labels.icon",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "water",
"stylers": [
{ "color": "#4d4946" }
]
},{
"featureType": "poi",
"elementType": "labels.icon",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "poi",
"elementType": "labels.text",
"stylers": [
{ "visibility": "simplified" }
]
},{
"featureType": "road",
"elementType": "geometry.fill",
"stylers": [
{ "color": "#ffffff" }
]
},{
"featureType": "road.local",
"elementType": "labels.text",
"stylers": [
{ "visibility": "simplified" }
]
},{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [
{ "color": "#ffffff" }
]
},{
"featureType": "transit.line",
"elementType": "geometry",
"stylers": [
{ "gamma": 0.48 }
]
},{
"featureType": "transit.station",
"elementType": "labels.icon",
"stylers": [
{ "visibility": "off" }
]
},{
"featureType": "road",
"elementType": "geometry.stroke",
"stylers": [
{ "gamma": 7.18 }
]
}
],
}
var mapElement = document.getElementById('nnp');
var map = new google.maps.Map(mapElement, mapOptions);
var locations = [
['New North Press', 'undefined', 'undefined', 'undefined', 'undefined', 51.5270676, -0.0821046999999453, 'https://new-north-press.co.uk/wp-content/uploads/2018/09/nnp-map-marker1.png'],['Old Street Station', 'undefined', 'undefined', 'undefined', 'undefined', 51.5256774, -0.08750310000004902, 'https://new-north-press.co.uk/wp-content/uploads/2018/09/nnp-map-marker2.png'],['Hoxton Station', 'undefined', 'undefined', 'undefined', 'undefined', 51.53151, -0.075649999999996, 'https://mapbuildr.com/assets/img/markers/solid-pin-black.png'],['Shoreditch High Street Station', 'undefined', 'undefined', 'undefined', 'undefined', 51.52327409999999, -0.07537430000002132, 'https://new-north-press.co.uk/wp-content/uploads/2018/09/nnp-map-marker2.png']
];
for (i = 0; i < locations.length; i++) {
if (locations[i][1] =='undefined'){ description ='';} else { description = locations[i][1];}
if (locations[i][2] =='undefined'){ telephone ='';} else { telephone = locations[i][2];}
if (locations[i][3] =='undefined'){ email ='';} else { email = locations[i][3];}
if (locations[i][4] =='undefined'){ web ='';} else { web = locations[i][4];}
if (locations[i][7] =='undefined'){ markericon ='';} else { markericon = locations[i][7];}
marker = new google.maps.Marker({
icon: markericon,
position: new google.maps.LatLng(locations[i][5], locations[i][6]),
map: map,
title: locations[i][0],
desc: description,
tel: telephone,
email: email,
web: web
});
link = ''; bindInfoWindow(marker, map, locations[i][0], description, telephone, email, web, link);
}
function bindInfoWindow(marker, map, title, desc, telephone, email, web, link) {
var infoWindowVisible = (function () {
var currentlyVisible = false;
return function (visible) {
if (visible !== undefined) {
currentlyVisible = visible;
}
return currentlyVisible;
};
}());
iw = new google.maps.InfoWindow();
google.maps.event.addListener(marker, 'click', function() {
if (infoWindowVisible()) {
iw.close();
infoWindowVisible(false);
} else {
var html= ""+title+"
";
iw = new google.maps.InfoWindow({content:html});
iw.open(map,marker);
infoWindowVisible(true);
}
});
google.maps.event.addListener(iw, 'closeclick', function () {
infoWindowVisible(false);
});
}
}
#nnp {
height:400px;
width:100%;
}
.gm-style-iw * {
}
.gm-style-iw h4, .gm-style-iw p {
margin: 0;
padding: 0;
}
.gm-style-iw a {
color: #4272db;
}