Hot answers tagged

4

The L.GeoJson class has a built in filter option that you can use to filter your data. Just pass it a function that will return true for the features you want to show: var picnic_parks = L.geoJson(myJson, {filter: picnicFilter}).addTo(map); function picnicFilter(feature) { if (feature.properties.Picnic === "Yes") return true } Here is a fiddle with a ...


3

Basically you just need a PHP script that acts as a middle man and does the fetching for you, then returns what it gets directly to the client. I converted your JS snippet above into the relevant parts below. Notice that the url in your Leaflet tileLayer example has been changed to a PHP endpoint with URL parameters: ?s={s}&z={z}&x={x}&y={y} ...


3

I've solved ... doing a search on the web I've found that the problem was about the layer's zIndexes and that there is a UNDOCUMENTED (!!???), feature that solve the problem ... Here you're a couple of useful links: http://www.wjst.de/blog/sciencesurf/2015/08/leaflet-js-layer-order-layer-address-and-links/ ...


3

I can confirm that, as you've reported, this appears to be a real bug in both 0.7x and 1.0x (on Chrome, at least; I haven't tested it elsewhere). However, there is a workaround that seems to prevent it. If you name your click event listener function, you can turn it off on dragstart, then use setTimeout to turn it back on a short time after dragend: ...


3

You can initialize your Borne geoJson layer without any data but with a styling function specified in the options: var Borne = new L.GeoJSON(false, { style: function (feature) { return {color: feature.properties.color}; } }); This style will be applied to any data you add later with addData.


2

One option is to use Proj4Leaflet to read the projected GeoJSON. If you have a variable called sampleProjected referencing your GeoJSON (and assuming you are using a projection that is defined in Proj4, as EPSG:3857 is), you could just add it like so: L.Proj.geoJson(sampleProjected).addTo(map); Here is an example comparing your projected data (in blue) ...


2

There is no built-in support for that. See https://github.com/heigeo/leaflet.wms.


2

The leaflet-bing-layer plugin requires a valid Bing Maps key, which means that all tiles are obtained via "an authenticated call to the Services." Thus, it complies with the terms of use. The Leaflet plugin just simplifies interaction with the Bing Maps API. The developer is still subject to all the usage limits/restrictions that normally apply to the API, ...


2

gdal_translate params in python script must be: ['gdal_translate', '-a_ullr', str(-w/2), str(h/2), str(w/2), str(-h/2), '-a_srs', MERC, infile, '%s.tif' % infile] (swap h/2 and -h/2)


2

It's free but you will have "only" 50,000 map views / mo, or 50,000 mobile users / mo More infos here: https://www.mapbox.com/pricing/#


2

Follow the map panes tutorial and create an explicit separate pane for the labels.


2

Though I used Leaflet in my webGIS application, OpenLayers has much more advantages over Leaflet. For example if you want to use your application in mobile devices, OpenLayers is a must for the time being. There are lots of resources related with OpenLayers, however I think developing application with Leaflet is easier than OpenLayers (it is easier to read ...


2

See the list of Leaflet plugins for vector tiles. Note that MapboxVectorTile and hoverboard work only with Leaflet 0.7.x, which will be deprecated by Leaflet 1 "Really Soon™".


2

your sample is working fine for me. if you're having trouble clicking on point features, consider calling tolerance() and passing in a number of screen pixels greater than the default value of 3. that being said, you are not limited to working with L.esri.dynamicMapLayer in order to get a reference to the symbology defined by the service itself. when ...


2

Instead of creating a convex hull over a set of points with the same attributes, create a Voronoi tesselation of all points, then merge the Voronoi polygons of those points with the same attributes. There are lots of ways to process the information you may have, and what I just said is one idea on how to do it. Voronoi + merge might create multipolygons, ...


2

The L.geoJson() constructor is actually just a convenient tool to convert GeoJSON data into Leaflet vector / path object(s) (like L.polyline, L.polygon, etc.). It also attaches the extra information that may be contained in the GeoJSON data into the created Leaflet objects (in layer.feature.properties for example). Therefore, if the GPS track that you ...


1

Scale dependent rules need to be applied via min/max scale denominators. https://github.com/mapnik/mapnik/wiki/MinScaleDenominator Converting mapnik scales to map scales requires a conversion. The table below is a good start http://wiki.openstreetmap.org/wiki/MinScaleDenominator My example ended up working with something like below <Rule> ...


1

You can set the line color based on the length value with: layer.setStyle({ color: 'red' }); And you can use a function to determine that color based on then length of the line var determineColor = function(length) { if (length > 4000) { return 'red'; } else if (length > 2500) { return 'orange'; } else if (length > 1500) { ...


1

CartoDB.js includes Leaflet already, so it's possible that you have some conflicts there. You can use this URL to get CartoDB.js without Leaflet included: http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb_noleaflet.js


1

Building your own solution might actually not be as hard as you think. All you would have to do is register a moveend event and then call getBounds() or getBoundsZoom() (in case the zoom level is important). Then you send this extent to your database and query all the points that fall within it. Of course you need a database that understands geospatial ...


1

In your first case, you're adding Marker objects iteratively to your MarkerCluster. In the second case, you are just giving a list of coordinates, but not Marker objects. Convert your locations list first: locations = [folium.Marker(l) for l in locations] This is incorrect advice, see comment and the MarkerCluster source.


1

Though all the examples on the Leaflet.Photo plugin page involve getting data via an API, all you really need is an array of objects with the latitude, longitude and URL(s) for each image. For example: var photos = [{ "lat": 34.04555452, "lng": -118.3001509, "thumbnail": "http://www.mydomain.com/photo1_thumb.jpg", "url": ...


1

1) The OSM Layer (that is, the one named osm) is added to the map, but because you have added the Mapquest layer (the one named openstreetmap) as well, the osm layer is hidden beneath it. And because you haven't added osm as one of the basemaps in your layer control, you have no way to turn off the other layers and reveal it. 2) The precipitation layer ...


1

It appears that the tiles are not showing up because they do not exist. If you look at the console output or network traffic log, you will see that 403 (Forbidden) errors are being produced for all tiles above zoom level 14 in this area (in other areas, there is data for zoom levels up to 16) as well as any tile that does not contain data. Even on the ...


1

You will have to dump that tiff file (or whatever) into a <canvas> and read the values of whatever pixels you want. Be aware of cross-origin issues. Do read: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas


1

EDITED to include Leaflet 1.0 example: In Leaflet 0.7x, this is made easy with the Leaflet.MapboxVectorTile plugin. You just need to specify the URL pattern in the url configuration option. The plugin documentation details the other configuration options that are available. To add the Mapillary data, you would use it like this: var config = { url: ...


1

Problem was that for the container to be created, first you have to add the control to the map. var mapbuttons_div = L.DomUtil.create('div', 'mapbuttons leaflet-bar leaflet-control'); var zoom = L.control.zoom( { position: 'topleft' } ); zoom.addTo(map); mapbuttons_div.appendChild(zoom.getContainer()); // works


1

Yes, there is a plugin for that.


1

Use L.Control.Layers.addOverlay() and L.Control.Layers.removeLayer().


1

Try this: var FilterWMSlayer= L.tileLayer.wms("http://Server.com/geoserver/Workspace/wms", { layers: 'Workspace:Layer', format: 'image/png', transparent: true, CQL_FILTER:'NAME=Leeds' }); EDIT In case you want to query more params: CQL_FILTER:'param=value&param1=value1&...' EDIT 2 I've updated your ...



Only top voted, non community-wiki answers of a minimum length are eligible