Start map without layer displayed when using layercontrol - leaflet

I have many overlays in Layercontrol. When I start the map the display is very confused, because all layers are displayed.
Is it possible to start the map so that no layer is displayed?

Leaflet will display all the layers that you add to the map. For base layers, you want to add one layer (which will be your default) and not the others. For overlay layers, it's up to you how many (or none) you add to the map for the default state. In both cases, the L.control.layers will configure itself to match the state of the layers when you add the control.

Related

How can I tell if a Leaflet layer is currently visible?

I'm building a Leaflet plugin that adds/removes layers to/from a Leaflet map. My plugin needs to know if a given layer is visible on-screen. So far, I've come up with the following criteria that a layer must meet in order to be considered "visible":
It must be added to the map. (This is trivial to check in my case.)
It must be within a valid zoom range. (This is also pretty easy to handle.)
It must be visible within the current extent/bounds.
The third criteria is the one I am having difficulty checking. My layers are a variety of different Esri-Leaflet layers. I understand that I can check whether a given point or rectangle is contained within the visible bounds of the map with map.getBounds().contains(...), but my problem is I am not sure how to represent my Esri-Leaflet layer as a rectangle. Not even all Leaflet layers have a getLatLng() method, so this question isn't even Esri-Leaflet specific (e.g. how would you perform the same check on a TileLayer)?
How can I get the bounds of a Leaflet layer, or otherwise check if the layer is visible on the map?
Not a duplicate of:
Get a list of markers/layers within current map bounds in Leaflet
Get the bounding box of the visible leaflet map?

Mapbox gl repeat marker

I try to repeat a marker at the same coordinates when I am moving the map to infinity, in the same way that layers.
example : https://www.mapbox.com/mapbox-gl-js/example/geojson-polygon/
Has anyone found how to do that please?
If it's not possible, conversely is it possible to not repeat layers when you moving the map ?
Thank you
The Link example you provided is not using Markers to render the shaded area. It is using a feature, in this case a polygon, included in a layer (a layer can have many features).
In MapBox the rendered map is made up of any number of layers (including the tile data) which is rendered whenever you scroll or drag to a particular area of the map. For example as you keep dragging to the right in the map it will just keep rendering in the relevant layers and tiles.
The Marker functionality has a different purpose which is as a one off selected point which is useful for a user click or hover interaction.

How to hide map but show other layers

I am developing a simple map app using Google Maps API v2 for Android.
The data that is displayed are:
a. The map layer (the satellite view from Google Maps);
b. The political map layer (KML);
c. Some custom markers from user (KML).
I would like to add a button to toggle show/hide each layer. I can do it for layers "b" and "c" (e.g. Hiding/showing a kml layer on customized google maps depending of the view), but how to do it with layer "a"???
I searched a lot and did not find how to do it using only that API. Is it possible?
The mapType MAP_TYPE_NONE positions the custom tiles according to the camera position, but does not show its own map tiles.

continuous drag or scaling in leaflet

at present our project is using the leaflet, I take the map parameters to background program (map.getZoom() and map.getbounds()) , then load the returned picture(return from background program) by imageoverlay.
excuse me how to solve continuous drag or continuous scaling, only the implementation of calling a daemon?
If you mean you dynamically load the base map (i.e. the image that is zoomable, draggable and that fills a big pane, not just a small portion that would have needed a single image overlay), you should probably rather do it through a Canvas Tile Layer:
Used to create Canvas-based tile layers where tiles get drawn on the browser side.
With this, you set up a myCanvasTileLayer.drawTile function that is called by Leaflet anytime the map needs more tiles (due to user panning / zooming). Please refer to Leaflet doc for the function arguments.
If you want to stick with your image overlay technique, you might want to listen to drag and zoomend map events to re-trigger your function that loads a new image overlay.

Reorder Leaflet layers

I have 3 layers, one GeoJSON that is used with leaflet-draw and two (vector and canvas/heatmap) that just display overlays.
My problem is, the overlays get added later dynamically with the layer-control, while the GeoJSON layer is always there. When the overlays get added, some of the draw features and general interaction with the GeoJSON layer top to work, because my overlays are always on top.
How can I get the GeoJSON layer back to the front?
Using layer.bringToFront() didn't work.
If the layers are being added through the layer control, you can keep your GeoJSON layer on top by bumping it back using .bringToFront() each time an overlayadd event is fired:
map.on('overlayadd', function() {
yourGeoJsonLayerName.bringToFront();
});
A somewhat unwieldy example fiddle is here:
http://fiddle.jshell.net/nathansnider/yt65dkyt/
Though layer ordering can be handled more gracefully in the Leaflet 1.0 betas by assigning layers to panes with a persistent zIndex, it looks like Leaflet Draw doesn't officially support 1.0 yet, so .bringToFront it is!