Листовка всплывающая на markercluster - PullRequest
0 голосов
/ 07 ноября 2018

Я хочу показать всплывающее окно в событии при наведении мыши, у меня уже есть весь popupContent предустановленного всплывающего окна, но я застрял.

    //pane
    map.createPane('PaneIncidentes');
    map.getPane('PaneIncidentes').style.zIndex = 405;
    map.getPane('PaneIncidentes').style['mix-blend-mode'] = 'normal';
    //layer
    Layers['Incidentes'] = new L.geoJson(json_Incidentes, {
        attribution: 'Toluca',
        pane: 'PaneIncidentes',
        onEachFeature: function(feature, layer){//here is the problem
            layer.on({
                mouseout: function(e) {
                    if (typeof layer.closePopup == 'function') {
                        layer.closePopup();
                    } else {
                        layer.eachLayer(function(feature){
                            feature.closePopup()
                        });
                    }
                },
                mouseover: function(e){
                    if (typeof e.target.openPopup == 'function') {
                        e.target.openPopup();
                    }
                },
                });
                var popupContent = '<table style="text-align: center;" border="1">\
                    <tr>\
                        <td colspan="2"><b>' + (feature.properties['Incident'] !== null ? Autolinker.link(String(feature.properties['Incident'])) : '') + '</b></td>\
                    </tr>\
                </table>';
                layer.bindPopup(popupContent, {maxHeight: 400});

        },
        pointToLayer: function (feature, latlng) {
            var context = {
                feature: feature,
                variables: {}
            };

            return L.marker(latlng, (function(feature){

                switch(String(feature.properties['Incident'])) {
                    case 'Droga':
                        return {
                            pane: 'PaneIncidentes',
                            icon: L.icon({
                                iconUrl:Icon['0'].src,
                                iconSize:[32,32]
                            }),
                            interactive: true
                        }
                        break;
                    case 'Robo':
                        return {
                            pane: 'PaneIncidentes',
                            icon: L.icon({
                                iconUrl:Icon['1'].src,
                                iconSize:[32,32]
                            }),
                            interactive: true
                        }
                        break;                      
                }
            }(feature)))
        },
    });
    Layers['Cluster'] = new L.markerClusterGroup({
        showCoverageOnHover: true,
        zoomToBoundsOnClick: true,
        spiderfyDistanceMultiplier: 5});
    Layers['Cluster'].addLayer(Layers['Incidentes']);
    //map
    boundsGroup.addLayer(Layers['Cluster']);
    map.addLayer(Layers['Cluster']);

все работает отлично, кроме части событий, когда это кластер, и я ищу возможное решение, и мне потребовалось почти два дня, чтобы показать всплывающее окно. Я отлаживаю объект, и все идет хорошо, но он не распознает функции, хотя и говорит, что они существуют.

...