I want to fit the map on a specific wms layer in leaflet. for this, I try to get bounding box of the wms layer and then use the map.fitBounds(bbox) method. but I don't know how to get the bounding box of a layer! can somebody give me a solution? thanks
Depending on your WMS server, the capabilities of your WMS layers might contain bounding box information.
Perform a GetCapabilities request (see e.g. https://wiki.state.ma.us/display/massgis/GeoServer+-+WMS+-+GetCapabilities ), parse that document (see e.g. https://github.com/w8r/wms-capabilities ), and locate the appropiate WMS layer(s). Bounding box information should be there.
Please note that Leaflet does not request the capabilities of the WMS server, and does not have built-in facilities for parsing it.
Related
I'm using Leaflet (with omnivore and the MapQuest tile plugins) to display a map with colored polygons. The map and polygons look/work fine, but there are these mysterious blue markers everywhere.
There's nothing in the JS about markers at all, and if I comment out the polygon.addTo(map); line, the markers disappear. So they're definitely related to the polygons, even though they're not directly positioned on the polygons.
Any idea why the markers are appearing, or how I can make them disappear?
SOLVED: It turns out that the problem was that I'm using MSSQL's ".Reduce(n)" function to simplify the polygons (for performance), and if you simplify the polygons too far, the results have "Point(...)" items in them - which leaflet renders as markers!
Now, off to figure out why MSSQL is turning things into points...
Welcome to SO!
Most probably your polygon variable is a Leaflet GeoJSON Layer Group built by the omnivore plugin, and the data you feed it with contains "Point" type geometries.
If you do not specify anything special to handle these points, Leaflet will render them with this default blue marker icon.
In that case, you could simply filter out those point features, whether after omnivore processing (use the ready event) or using a custom GeoJSON Layer Group with its filter option. There should be other posts describing such solutions.
See e.g. Mapbox: Filtering out markers in a Leaflet Omnivore KML layer
If you are not in this case, you would have to provide more information for people to be able to help you. Typically code that you use to build your polygon layer and sample data.
now I use leaflet.
I want to know what are their policies about heavy traffic.
like OSM, I have to make another server? then, how can i do?
thanks for answering.
Leaflet is a javascript library and does not provide tiles. So there is no limit in using leaflet.
Your question is more towards the provider of the tiles that leaflet uses.
For example:
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
The map you see is actually a set of images (usually 256x256 pixels). There are served by a tiles server. See https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames.
The limitation you want to know is the limitation of the tiles server.
Leaflet is the glue that knows which tiles to show according to the lat,lng you want to show.
The TileLayer you create tells leaflet where it must get the tiles from.
Will it be possible to get Bounding Box of uploading shapefile or geotiff?
I can able to upload shapefile and geotiff but not getting bounding box information. I am loading this shapefile and geotiff through WMS layer in Leaflet, and want to center map with layer. I want bounding to center map to geotiff and shapefile.
The information is not available via the REST API, but once uploaded you'll find the layer in the WMS capabilities document, and there you can get its bounds.
I have a complete set of waypoints (beginning, end, every intersection) and I'd like to display this on a map. I don't want to use a routing service and it should be offline.
How can I draw polylines on a map so that they follow the curves of the road?
I'm using leaflet.
Could the data be extracted from a relational database(PostgreSQL) and then convert it into GeoJSON and display on the map by leaflet?
I can't use any paid services either.
Leaflet has a polyline object. MapBox has a nice example how to use it.
I think scai has given you a good example to practice.By the way you can also store the data in JSON format in PostgreSQL.Refer this documentation for more details.JSON Types
I have a simple Leaflet application containing 3 layers: OSM layer, Google Satellite layer (from Pavel Shramov plugin) and my own WMS layer.
My WMS layer show well over OSM basemap but when switching basemap to Google layer with layers control, Google Satellite layer show well but my WMS is not shown over it.
Exploring in Firebug tell me that my WMS images are there but not shown correctly OVER Google layer... This was working well using old version of Leaflet js/css but I want to use the new release 0.4.2...
Any idea how to patch this issue?
Thanks a lot
Etienne
Finallly, adding this line:
$("#" + this._container.id).css("z-index", "auto");
in the _initContainer() function of the Google.js plugin solved the problem...
Check this conversation for more detail: https://github.com/shramov/leaflet-plugins/issues/29
Regards
Etienne