leaflet-responsive-popup icon indicating copy to clipboard operation
leaflet-responsive-popup copied to clipboard

Cant open popup on geoJSON element on load

Open OmegaSkiller opened this issue 3 years ago • 1 comments

I'm trying to open popup based on GET param. Each cell in the geoJSON have different popup data. I've searched all over the net but didnt find anything... This is my code:

                angular.extend($scope.layers.overlays, {
                    sold: {
                        name: 'Sold Land',
                        type: 'geoJSONShape',
                        data: data,
                        visible: true,
                        layerOptions: {
                            style: {
                                color: '#ff0000',
                                weight: 1,
                                fillOpacity: 0,
                                opacity: 1,
                            },
                            onEachFeature:
                                function (feature, layer) {
                                layer.on('click', function (e) {
                                    $http.get("/ajax.php?landId=" + feature.properties.id).success(function (data, status) { //var landData =
                                        var landDiv = document.getElementById('sold-detail-' + feature.properties.id);
                                        landDiv.innerHTML = data;
                                        return data;
                                    });
                                });
                                const popup = L.responsivePopup({className: 'buyPopup'}).setContent('<div class="buyPopup" id="sold-detail-' + feature.properties.id + '">Loading...</div>');
                                layer.bindPopup(popup).openPopup();
                            },
                        },
                    },
                    selectedLand: {},
                });
                    // Put the cells on an associative array
                $scope.cells = {};
                for (var i = 0; i < data.length; i++) {
                    var cell = data[i];
                    $scope.cells[cell['properties']['type']] = cell;
                }
            });

OmegaSkiller avatar Jan 24 '22 21:01 OmegaSkiller

This is not an issue with this plugin.

I can put you on track but i won't be able to spend time on this.

Bottomline: you cannot access your feature in the click event

yafred avatar Jan 25 '22 13:01 yafred