Hot answers tagged

3

If you already have a GeoServer WMS service, then the most straightforward way is to use the getFeatureInfo capabilities of the WMS protocol. See https://github.com/heigeo/leaflet.wms and http://docs.geoserver.org/latest/en/user/services/wms/reference.html#wms-getfeatureinfo


3

You can get the current zoom level using getZoom(). Assuming that you're using the tile layer system as used by Google Maps, Bing, Open Street Map and Esri, you can use that to infer the scale - see What ratio scales do Google Maps zoom levels correspond to? If you're not using that tile system, you may need to find another way to infer the scale from the ...


3

You should not have to do any particular conversion on your OSM data or Leaflet returned coordinates. There is a high confusion on this subject, but I think it comes down to a simple explanation: OSM data is in WGS84 datum (EPSG 4326). This is how you plot the Earth onto an ellipsoid. Web Mercator (EPSG 3857) is how you project this ellipsoid onto a plane....


3

In general, yes, in theory, yes, in practice, yes with a bit of work. There's no general general solution because you can't know how the data is coming from the server. The solution involves looking at the underlying Javascript and seeing what it does. Chances are it will be an AJAX call to a server that returns a geoJSON data set, but it could literally be ...


2

As an alternative to @Joran's approach, you can skip GeoJSON completely and just iterate through the points, creating instances of L.LatLng and L.Marker as you go, like: var points = [{ "latitud": 43.526523590087891, "longitud": -5.6150951385498047 }, { "latitud": 43.511680603027344, "longitud": -5.6671133041381836 }, ...


2

I found an extension of Leaflet Data Visualization Framework Leaflet Visualisation specially for charts all types of charts


2

Two things here checking on your fiddle. First is you are putting the https:true option in the wrong place, you need to add it to the next parameter. In normal JS it would be like this: cartodb.createLayer(map, { user_name: 'user', filter: "mapnik", type: 'cartodb', sublayers: [{ sql: layer_sql, ...


2

It seems to me that you could just add the features to the local layer as well as sending them to PostGIS. I'd comment further but the key part of the code is missing from your question. As an aside why not use the WFS-T functionality built in to GeoServer instead of reinventing it using PHP?


2

This is not a GIS question, but rather a HTML+CSS one. Start by reading https://developer.mozilla.org/en-US/Learn/CSS/CSS_layout/Positioning , then do a bit of research on positioning block-level elements relative to the viewport, including how to use the vw and vh units.


2

I do not believe it's possible to limit the records retrieved from a geojson file. A complete geojson data structure is always an object, so if you only fetched a part of it (for example using an http range request) then you would get an invalid json syntax - missing either the opening or closing brace and the json would not be parseable by the browser. ...


2

Mapbox.js extends Leaflet, which means that it includes all of Leaflet, plus a few extras like L.mapbox.featureLayer and L.mapbox.geocoder that make handling GeoJSON more convenient and add an interface to the Mapbox Geocoding API, respectively (there are more L.mapbox methods that you can read about on the API documentation page and you can check out ...


2

You would probably be interested in this post: Feature Request - Ability to cluster polygons (Leaflet.markercluster issue #612) You might be interested in Leaflet.Deflate plugin, but be careful when removing the marker (see #580). Another possibility would be to "add" methods getLatLng and setLatLng to your polygons, so that MCG can handle them ...


2

Add the following CSS somewhere (either between <style> tags in your main map HTML file within the <head>, or better in a CSS file): .leaflet-popup-content { max-width: 200px; height: 200px; overflow-y: scroll; } Not fully tested - hope it's broadly correct.


2

Where can I find data to produce these sort of visualizations? You're asking for administrative boundaries. How to get the official version depends on the country's administration. As far as I'm aware, a normalized dataset for all official administrative boundaries doesn't exist. IMHO the closest you might get to that is Natural Earth or OpenStreetMap. ...


1

This is done in the Leaflet code by using the cursor CSS property, see https://github.com/Leaflet/Leaflet/blob/master/dist/leaflet.css#L193


1

You need to retrieve the user coordinates to use them as input. In leaflet you can use e.latlng.lng and e.latlng.lat. Using this, your example should look like this: var control = L.Routing.control({ // waypoints: [null], waypoints: [ L.latLng( e.latlng.lat, e.latlng.lng), L.latLng(" string address") ], routeWhileDragging: true, show: true, ...


1

Hmm. Yes, most tile provider use 3857 but, 4326 is also native supported by leaflet. Before you asked question did you try retrieved data from mongo to use with leaflet? As far as I know it's shouldn't be a problem. When you add geojson with points in 4326 leaflet will internally reproject them to 3857.


1

what if, hypothetically, otile1 was down? If one subdomain is down, then they are all down. Let me quote from https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Tile_servers: Generally several subdomains (server names) are provided to get around browser limitations on the number of simultaneous HTTP connections to each host. Browser-based ...


1

In your second code snippet, you're using the style option for L.GeoJSON as if it were an valid option for L.CircleMarker. Read the documentation carefully again and ask yourself: Does L.CircleMarker use a style option? A better way would be to calculate styles inside pointToLayer, e.g.: var layer = L.geoJson(data, { pointToLayer: function(feat, ll) { ...


1

Do read the Leaflet tutorial on using WMS - it specifically addresses how to use WMS services in other projections. Also note that you can not have raster layers in different CRSs in Leaflet. It's simply not supported due to the complexity of on-the-fly raster reprojection.


1

I think you're just forgetting about the popupAnchor option of L.Icon/L.DivIcon.


1

If you want just the label: // add a scale at at your map. var scale = L.control.scale().addTo(map); // Get the label. var metres = scale._getRoundNum(map.containerPointToLatLng([0, map.getSize().y / 2 ]).distanceTo( map.containerPointToLatLng([scale.options.maxWidth,map.getSize().y / 2 ]))) label = metres < 1000 ? metres + ' m' : (metres / 1000) + ' ...


1

Limited success, but following seems to give at least some intellisense ... add a _references.js to the Visual Studio solution add a copy of the leaflet-src.js make sure the _references.js has /// <reference path="leaflet-src.js" /> in it But it's not 100%, so anything better?


1

So finally, here is the solution I used thanks to Barrett ! If it can help someone else here is the code : var defaultParameters = { service : 'WFS', version : '1.0.0', request : 'GetFeature', typeName : 'database:table’, outputFormat : 'text/javascript', format_options : 'callback:callEP', srsName : 'EPSG:4326', }; var ...


1

Try using preventDefault() or try changing #formulaire from a 'submit' type to a 'button' type and just have the script execute on click. At that point the data will submit but the updated image won't show since it not calling a new request to geoserver (which was happening when the page was refreshed). You need to find a function in leaflet to force your ...


1

I only want the few that should be displayed in the current bounding box Why? Unless there's a performance hit, you shouldn't filter the results - when you pan the map, you'll have to manually recalculate the visible points again. If there's a performance hit due to a large number of points, use some clustering/decluttering leaflet plugin first (these ...


1

This is a classic script tag order issue. Make sure you load the Leaflet library (and possibly the Mapbox one too) before the associated plugins. Otherwise, the latter will not be able to find Leaflet definition and do their work. When your issue is very programming-related, feel free to ask on Stack Overflow, you would probably receive an answer much more ...


1

I would complete (although it can still be known how data come from the server) Spacedman's answer by saying that reverse-engineering the AJAX call to retrieve data with the finest granularity (at the level of each point) would give nothing but an important coding/development stage to accomplish first. Indeed, data aggregation (averaging and so on) is ...


1

_popup has an underscore in front of it to indicate that it's a private / member instance, and should not be accessed directly. The correct API is Layer.setPopupContent(). e.g. marker.setPopupContent(newContent);



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