tombatossals / angular-leaflet-directive

AngularJS directive to embed an interact with maps managed by Leaflet library
http://tombatossals.github.io/angular-leaflet-directive
MIT License
1.5k stars 635 forks source link

How to get information about which marker to be fired when it is clicked. #1151

Open Hironobu-Fukuzawa opened 8 years ago

Hironobu-Fukuzawa commented 8 years ago

Hi, I'm a begginer of web programmar.

I'm in much trouble. I'd like to get information about which marker to be fired when it is clicked.

The minimum code I created is below.

I will be very helpful and glad If there is anyone who can resolve this problem, or anyone who can teach me the related issue.

Thanks for reading.

// Definite markers
$scope.markers =  [
    {
        layer: 'trip1',
        lat: 35.663296,
        lng: 139.73235,
        focus: true,
        timestamp:{
            month:10,
            day:13,
            hour:16,
            minute:04,
            second:25
        },
        icon: $scope.icons.trip1
    },
    {
        layer: 'trip1',
        lat: 35.663414,
        lng: 139.732595,
        focus: true,
        timestamp:{
            month:10,
            day:13,
            hour:16,
            minute:04,
            second:55
        },

        icon: $scope.icons.trip1
    },
    {
        layer: 'trip1',
        lat: 35.663532,
        lng: 139.73284,
        focus: true,
        timestamp:{
            month:10,
            day:13,
            hour:16,
            minute:05,
            second:20
        },
        icon: $scope.icons.trip1
    },                              
    {
        layer: 'trip1',
        lat: 35.66365,
        lng: 139.733085,
        focus: true,
        timestamp:{
            month:10,
            day:13,
            hour:16,
            minute:05,
            second:40
        },
        icon: $scope.icons.trip1
    }
];

// fire click event on all markers $scope.$on('leafletDirectiveMarker.viewMap.click', function (event, args) {

 // The program cannnot figure out which marker is clicked
 var responseTime = $scope.markers[0].timestamp.minute + "分" +     $scope.markers[0].timestamp.second + "秒";

 window.open('open.html?' + responseTime,'動画再生ページ');

});