Leaflet.js - markers get overlapped with overlay

1.2k views Asked by At

I have leaflet.js layer control with Google Maps, OSM and Yandex maps layers and Yandex Maps traffic overlay (it's just color lines showing traffic)

I use following plugins for Google and Yandex maps to put it to leaflet: https://github.com/shramov/leaflet-plugins

here is my code:

    var map = new L.Map('map', { center: new L.LatLng(59.94, 30.29), zoom: 10, zoomsliderControl: true,
        scrollWheelZoom:true, zoomAnimation: false });
    var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
    var osm = new L.TileLayer(osmUrl, {attribution: '', maxZoom:18 });
    var yndx = new L.Yandex("", {attribution: ''});
    var ytraffic = new L.Yandex("null", {traffic:true, opacity:1, overlay:true });
    var googleLayer = new L.Google('ROADMAP');
    var layersControl = new L.Control.Layers({"Yandex":yndx, 'OSM':osm, 'Google':googleLayer}, {"Traffic":ytraffic});
    map.addControl(layersControl);
    map.addLayer(yndx);     

    L.marker([59.94, 30.29], {icon: new L.Icon({iconUrl: "../css/car.png", iconAnchor: new L.point(16, 37), iconSize: new L.point(64, 38)}) }).addTo(map);

The problem is that traffic lines overlay overlaps markers on the map. As I know this shouldn't happen because overlay pane is normally below marker pane.

Please advise what can be done to put markers above traffic lines.

1

There are 1 answers

0
twinmind On

I found on GitNub that it is known issue, third comment from the top helped me: https://github.com/shramov/leaflet-plugins/issues/97