How can I avoid self-managing z-index on leaflet popups

المشرف العام

Administrator
طاقم الإدارة
I have a leaflet map with two tile layers (mapbox, and my own) one marker layer, and a GeoJSON layer. What I was finding was that since the GeoJSON layer is dynamically loaded (from a file contents) and that that happens after I had the marker layer, I the marker was getting hidden by z-index.

Ok, easy fix:

theCar = L.marker(mCityCenter, { draggable: true, rotationOrigin: "32px 32px", rotationAngle: 90, zIndexOffset: 10000, icon: myIcon }); carLayer = theCar;But that has force me to also self manage the z-index of the pop-up associated with it. Since it was much lower than 10,000.

var popup = L.popup(); popup.setContent("CAR"); popup.setLatLng(mCityCenter); carLayer.bindPopup(popup); popup.addTo(theMap); self.CarPopup = popup; $(self.CarPopup._container).css('z-index', 20000); theMap.closePopup(popup);This is getting really ugly. Obviously, I am doing something wrong here. While it works, I really hate working against the paradigm.



أكثر...
 
أعلى