I need icons (PNG) and polygons on my map. So I create icons as markers and polygons as polygons. Unfortunately regardless of creation order polygons are displayed "below" markers. I need is vice-versa. Is there a way, how to do it?
相关问题
- Leaflet popups for specific base maps
- leafletjs adding scrollable pop up?
- Add text inside leaflet rectangle
- Fit map to bounds exactly
- Popup on hovering over cluster group
相关文章
- change leaflet marker icon
- Prevent zooming out in leaflet R-Map?
- Multiple markers on the exact same position on a L
- leaflet how to make dynamic picture popup using js
- Fill polygon with pattern doesn't work with le
- Leaflet: how to swap coordinates received from an
- Add polygon to map R leaflet
- Leaflet map returns to its original configuration
EDIT:
Correct default panes order in Leaflet 0.x: (from top-most to bottom-most)
L.CircleMarker
)L.CircleMarker
)So just using the marker's icon shadow is not enough. You have to manually change the
z-index
of those panes in CSS (or through JS).See also Leaflet: Polyline above Marker.
Original answer:
The stack order of vectors (like your polygons) and Markers is fixed in Leaflet 0.x. They are inserted into "panes" which order is (from top-most to bottom-most):
L.CircleMarker
)L.CircleMarker
)So you should be able to easily workaround this fixed order by using the Marker's Icon shadow. If you still want the user to be able to click on your marker, simply use a transparent image for the normal icon, with the same size as your shadow image.
The situation is different in Leaflet 1.0. You can create your own panes (
map.createPane
), set their order by specifying theirzIndex
(possibly through CSS), and specify where your vectors and markers go by using theirpane
(andshadowPane
for markers) option(s).