bringToFront(), bringToBack() on L.geojson problem

I'm trying to make a simple interactive map of Germany. I'm using mapbox.js (2.4.0) and have it set up like this:

var map; var currLayer, citiesLayer, riversLayer;  $(document).on("ready", function() { L.mapbox.accessToken = ''; map = L.mapbox.map('map', 'vantuch.d55cb2a1', {zoomControl: true, scrollWheelZoom: true}). setView([51.0621,10.9863], 6);      // CALL AJAX REQUEST FOR TESTING     findCities();     findRivers();     findCityPlaces(); }); 

I am calling AJAX functions to set up a L.geojson layer after success like this:

/* functions for setting up MARKERS (find_river_places) */ function showMarkers(map, geojson, selectType) {      geojsonLayer = L.geoJson(geojson, {         // setting up markers     });  currLayer = geojsonLayer; map.addLayer(geojsonLayer); } 

What I want to do is to have layers for rivers and cities always on the top of other layers (user should be able to turn them on or off), no matter which function is called the first. But they're always rendered at the bottom.

I thought that citiesLayer.bringToFront() after adding other layers should work. But after testing it in the console it does nothing. So what am I doing wrong, or is there a better way to do this ?

Replay

Category: leaflet Time: 2016-07-30 Views: 0
Tags: leaflet mapbox

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.146 (s). 12 q(s)