1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| ajaxGet("https://api.jcdecaux.com/vls/v1/stations?contract=lyon&apiKey=62f............................c642c0987e254d5af", function(reponse){
var velov = JSON.parse(reponse);
//manipulation du tableau
var markers = new Array();
//boucle pour initialiser chaque marqueur de la station
for(var i=0;i<velov.length;i++)
{
var staVel = velov[i];
var posX = staVel.position.lat;
var posY = staVel.position.lng;
var myLatlng = new google.maps.LatLng(posX,posY);
//gestion marker et de ses proprietes
var marker = new google.maps.Marker(
{
position: myLatlng,
title:staVel.name,
address:staVel.address,
totalSpots:staVel.bike_stands,
freeSpots:staVel.available_bike_stands,
freeBikes:staVel.available_bikes,
status:staVel.status,
icon:markerIcon(staVel.status)
});
//ajoute marker à la fin du tableau
markers.push(marker);
//Creation d'evenement pour la reservation
marker.addListener("click", function(){
reservation.init(this.title,this.address,this.totalSpots,this.freeBikes,this.status);
domMaster.infoResa();
});
//ajoute un nouvel élément A Map.
marker.setMap(map);
}
var markerCluster = new MarkerClusterer(map, markers, {imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'}); |
Partager