Javascript besoin d'aide

Publié le 15 janv. 2017 il y a 7A par Anonyme - Fin › 18 janv. 2017 dans 7A
2

Sujet du devoir

Quelqu'un pourrait m'expliquer ce bout de code ? 

 

Quel est le but de chaques fonctions, variables et qu'apportent t-elles ? 

 

<style type="text/css">
html, body { height: 100%; margin: 0; padding: 0; }
#map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>


<script type="text/javascript">




function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 50.85034, lng: 4.35171},
zoom: 12
});

var jours = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"];
var locations = [];

$.getJSON("https:opendata.bruxelles.be/api/records/1.0/search/?dataset=bxl_food_trucks", function (results) {
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (var i =0; i < results.records.length; i++) {
if (results.records[i].fields.lundi != undefined) {
locations[i] = {
'name' : results.records[i].fields.lundi,
'lat' : results.records[i].fields.latitude_breedtegraad,
'lng' : results.records[i].fields.longitude_lengtegraad
};
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i].lat, locations[i].lng),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i].name );
infowindow.open(map, marker);
}
})(marker, i));
}
}
});

// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};

var image = 'image/truck.png';
marker = new google.maps.Marker({
position: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
map: map,
icon: image
});

}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}

function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
}

</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC9y0i-GnLeSP9O5SwJJQfd-nNiYv2wWMM&callback=initMap">
</script>

<script
src="https://code.jquery.com/jquery-1.12.4.min.js"
integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
crossorigin="anonymous"></script>


</body>
</html>

 

Merci d'avance




2 commentaires pour ce devoir


Anonyme
Anonyme
Posté le 18 janv. 2017

c trop long essaye poste vraiment le passage ou tu bloque apres je pourrais t'aider

Anonyme
Anonyme
Posté le 18 janv. 2017

n'hésite pas si tu as la moindre question je suis ton devoir


Ils ont besoin d'aide !

Il faut être inscrit pour aider

Crée un compte gratuit pour aider

Je m'inscrisOU

J'ai déjà un compte

Je me connecte