
/*****************************************************************/
/* Creating event when clicking on marker                        */

//create function that reacts for marker event click
function onMarkerClick(e) {
    alert("Hey, you clicked it right " + e.toGeoJSON);
}

//put trigger on marker that shows interface
marker.on('click', onMarkerClick);

function onMarker2Click(e) {
    var interfaceBlock = document.getElementById('interfaceBlock');
    interfaceBlock.style.display = "block";
    //Display event in interface
    var event = ['<p>Bruno vous demande un café.<p/>', '<p>Il n\'y a personne, une lettre se trouve par terre.<p/>', '<p>Antoine Beauvilain vous saute dessus en criant "SQUIRREL !"<p/>'];
    var event = event[Math.floor(Math.random()*event.length)];
    var paragraphe = document.getElementById('description');
    paragraphe.innerHTML = event;
}
//close the interface
function onClickclose() {
    var interfaceBlock = document.getElementById('interfaceBlock');
    interfaceBlock.style.display = "none";
}

function changeIcon(e) {
    console.log(e.getLatLng);
    marker.setIcon(fastfoodIcon);
}
//put trigger on marker
marker2.on('click', onMarker2Click);


//on map, popup appears with coordinates
/*var popup = L.popup();

function onMapClick(e) {
    popup
        .setLatLng(e.latlng)
        .setContent("You clicked the map at " + e.latlng.toString())
        .openOn(map);
}

map.on('click', onMapClick);
*/

//hotelsLayer.on('click', changeIcon);

hero.on('drag', function(event){
            var coordinates = hero.getLatLng();
            circle.setLatLng(coordinates);
});

hero.on('dragend', function(event){
    map.setView(hero.getLatLng(), 13);
})

function showHideInterface(){
    if (!Game.showHideInterface) {
        $('#interfaceBlock').animate({
            marginLeft: '-630px'
        }, 500);
        Game.showHideInterface = 1;
        document.getElementById('slideButton').innerHTML = ">";
        //console.log('boolean: ' + Game.showHideInterface);
    }
    else{
        $('#interfaceBlock').css('margin', '39px auto');
        Game.showHideInterface = 0;
        document.getElementById('slideButton').innerHTML = "<";
        //console.log('boolean: ' + Game.showHideInterface);
    }
    
    //console.log('Clicked');
}

@@ -1693,16 +1693,17 @@
  13);%0A%7D)
+;
 %0A%0Afuncti
@@ -2284,12 +2284,1040 @@
 licked');%0A%7D%0A
+%0A//Set hero position to clicked marker%0Afor (var i = 0; i %3C markerMusees.length; i++) %7B%0A    markerMusees%5Bi%5D.on('click', function(event) %7B%0A        var position = this.getLatLng();%0A        hero.setLatLng(position);%0A        circle.setLatLng(position);%0A        displayMarker();%0A    %7D);%0A%7D%0Afor (var i = 0; i %3C markerCommissariats.length; i++) %7B%0A    markerCommissariats%5Bi%5D.on('click', function(event) %7B%0A        var position = this.getLatLng();%0A        hero.setLatLng(position);%0A        circle.setLatLng(position);%0A        displayMarker();%0A    %7D);%0A%7D%0Afor (var i = 0; i %3C markerHopitaux.length; i++) %7B%0A    markerHopitaux%5Bi%5D.on('click', function(event) %7B%0A        var position = this.getLatLng();%0A        hero.setLatLng(position);%0A        circle.setLatLng(position);%0A        displayMarker();%0A    %7D);%0A%7D%0Afor (var i = 0; i %3C markerPub.length; i++) %7B%0A    markerPub%5Bi%5D.on('click', function(event) %7B%0A        var position = this.getLatLng();%0A        hero.setLatLng(position);%0A        circle.setLatLng(position);%0A        displayMarker();%0A    %7D);%0A%7D%0A%0A

Add heros movement per click on marker