File: D:/HostingSpaces/SBogers10/signmania.komma.pro/wwwroot/js/googleMaps.js
/**
* Created by Pascal on 05/04/16.
*/
var mapLocation = document.getElementById('map');
$(function () {
if (mapLocation != null) {
initMap();
}
});
function initMap() {
mapLocation = document.getElementById('map');
if (mapLocation != null) {
mapLocation.classList.add('show');
googleMaps(parseFloat(mapLocation.getAttribute('data-googlex')), parseFloat(mapLocation.getAttribute('data-googley')));
}
}
function googleMaps(googleX, googleY) {
var zoom = 14;
var marker = '/img/googleMarker.png';
var mapOptions = {
// How zoomed in you want the map to start at (always required)
zoom: zoom,
//minZoom: zoom,
//maxZoom: zoom,
//disableDefaultUI: true,
//draggable: false,
scrollwheel: false,
// The latitude and longitude to center the map (always required)
center: new google.maps.LatLng(googleX, googleY),
// styles: [{"stylers":[{"hue":"#B61530"},{"saturation":60},{"lightness":-40}]},{"elementType":"labels.text.fill","stylers":[{"color":"#ffffff"}]},{"featureType":"water","stylers":[{"color":"#B61530"}]},{"featureType":"road","stylers":[{"color":"#B61530"},{}]},{"featureType":"road.local","stylers":[{"color":"#B61530"},{"lightness":6}]},{"featureType":"road.highway","stylers":[{"color":"#B61530"},{"lightness":-25}]},{"featureType":"road.arterial","stylers":[{"color":"#B61530"},{"lightness":-10}]},{"featureType":"transit","stylers":[{"color":"#B61530"},{"lightness":70}]},{"featureType":"transit.line","stylers":[{"color":"#B61530"},{"lightness":90}]},{"featureType":"administrative.country","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"transit.station","elementType":"labels.text.stroke","stylers":[{"visibility":"off"}]},{"featureType":"transit.station","elementType":"labels.text.fill","stylers":[{"color":"#ffffff"}]}]
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":"poi.attraction","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fea0a0"}]},{"featureType":"poi.business","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fea0a0"}]},{"featureType":"poi.government","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fea0a0"}]},{"featureType":"poi.medical","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fea0a0"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fae7e7"}]},{"featureType":"poi.place_of_worship","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fea0a0"}]},{"featureType":"poi.school","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fea0a0"}]},{"featureType":"poi.sports_complex","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fea0a0"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.highway.controlled_access","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#ffb4b4"}]},{"featureType":"road.arterial","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fbd5d5"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"road.local","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#ffdfdf"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"transit.line","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fec0c0"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#d24a43"},{"visibility":"on"}]},{"featureType":"water","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fba4a4"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#ffffff"},{"visibility":"on"}]},{"featureType":"water","elementType":"labels.text.stroke","stylers":[{"visibility":"off"}]}]
}
var map = new google.maps.Map(mapLocation, mapOptions);
var marker = new google.maps.Marker({
position: {lat: googleX, lng: googleY},
optimized: false,
map: map,
icon: marker,
animation: google.maps.Animation.DROP,
zIndex: 10
});
marker.setMap(map);
// map.addListener('center_changed', function() {
// // 3 seconds after the center of the map has changed, pan back to the
// // marker.
// window.setTimeout(function() {
// map.panTo(marker.getPosition());
// }, 3000);
// });
marker.addListener('click', toggleBounce);
function toggleBounce() {
if (marker.getAnimation() !== null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
marker.addListener('click', function () {
window.open('http://maps.google.com/?q=' + googleX + ',' + googleY);
map.setZoom(8);
map.setCenter(marker.getPosition());
});
}