76 lines
1.4 KiB
JavaScript
76 lines
1.4 KiB
JavaScript
|
|
const zuerich_bounds = {
|
|
north: 47.41590970260092,
|
|
south: 47.315703309031846,
|
|
west: 8.45742642179812,
|
|
east: 8.600047733589026,
|
|
};
|
|
|
|
function initMap() {
|
|
const map = new google.maps.Map(document.getElementById('map'), {
|
|
mapId: "fd4581e1612d9ef",
|
|
center: {lat: 47.38109493760974, lng: 8.521861488204763},
|
|
restriction: {
|
|
latLngBounds: zuerich_bounds,
|
|
strictBounds: false,
|
|
},
|
|
zoom: 13,
|
|
});
|
|
infoWindow = new google.maps.InfoWindow();
|
|
addMarkers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addMarkers(){
|
|
let url = "system/alleMarkerHolen.php";
|
|
fetch(url)
|
|
.then((response) => {
|
|
return response.json();
|
|
})
|
|
.then((markerData) => {
|
|
console.log("test");
|
|
for (let i = 0; i < markerData.length; i++) {
|
|
if (markerData[i].sichtbarkeit = 1) {
|
|
const marker = new google.maps.Marker({
|
|
position: {lat: markerData[i].koordinatenLat, lng: markerData[i].koordinatenLng},
|
|
map: map,
|
|
title: markerData[i].titel,
|
|
icon: {
|
|
url: "/images/ort.png",
|
|
scaledSize: new google.maps.Size(38, 38),
|
|
},
|
|
animation: google.maps.Animation.DROP,
|
|
|
|
});
|
|
marker.addListener("click", () => {
|
|
console.log("hello this is idea number:" + markerData[i].titel);
|
|
})
|
|
}
|
|
else {
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
.catch(function(error) {
|
|
console.log('Error: ' + error.message);
|
|
});
|
|
}
|
|
|
|
}
|