Tag Info

Hot answers tagged

3

This should work. Which version of Leaflet are you using? Here, have a look at this jsFiddle. It is important you get the arrays right. First array is the polygon object [ in here the outer ring [ in here some [lat,lon],[,] close the outer ring], then the inner ring [ in here some [lat,lon],[,] close the inner ring ] close the polygon ]. scotland = ...


2

I can answer the 2nd part of your question, the first one has me a little tied up now too I'll edit if no one answers when I get my head around it. So for 2) just use something in the line of routeControl._routes[0].summary.totalDistance See if this works, also _routes[0] represents your choice for example if you have another routing option for which you ...


2

In case someone else stumbles upon this and needs a live pan, too. Just remove the click event like so: var marker = new L.marker([lat,lon],{ draggable: true }).addTo(map); marker.on("drag", function(e) { var marker = e.target; var position = marker.getLatLng(); map.panTo(new L.LatLng(position.lat, position.lng)); }); I wished it would ...


2

I mostly agree with you and would say: If the user wants to click on it => leaflet If it changes regularly (like a GPS track) => leaflet If it is loaded on demand => leaflet if frontend rendering is too slow/complex => tiles For interactivity, you may have another option, but I have never had the opportunity to play with that: UTF-grid ...


2

It's fine to use different tile sources for different zoom levels, just set the min and max zoom on each layer, and don't have the zoom ranges overlap. var map = L.map('map').setView([45, -110], 10); L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '&copy; <a ...


1

Use turf.js for this, the functions union and erase in particular. Make a union of all your polygons (or at least the ones that are within the current viewport), then erase the result from the polygon that covers the current viewport. The result will be the inverted selection you're looking for.


1

You should add the script that loads the markercluster plugin after you've loaded the core leaflet application. The markercluster functionality is based on extended/new classes from Leaflet, so it has to read Leaflet first. So, put this line: <script ...


1

The standard way to do this is to use setTimeout inside a function and call that function recursively, incrementing any values you need inside the function, rather than using setInterval. This allows you to pass variables into the function being called recursively, to either vary the calling interval or some other value, such as a lookup into an array, a ...


1

There is no 'uncluster' function to call per se, but you could keep both a clustered and unclustered version of your data available, and toggle between them when you click a button var cluster = L.markerClusterGroup(); var marker = L.featureGroup(); for (var i = 0; i < points.length; i++) { var point = points[i]; var marker = L.marker(new ...


1

May be It depends up on back end for serving geojson. Just it varies for different back end serving capabilities. Just change the serving back end and observe the result. In leaflet the layer is load once from the back end and we can do more functionalities available for manipulating the layer.


1

If you keep a reference to the L.Routing.Control around you can remove it later on. $scope.routingControl = L.Routing.control({ waypoints: [ L.latLng(fromLat, fromLng), L.latLng(toLat, toLng) ] }).addTo(map); and to remove it: $scope.removeRouting = function() { leafletData.getMap().then(function(map) { ...


1

The answer is simple javascript to cancel the setInterval you created: var handle = setInterval(function() { // do something }, 100); function onCancel() { if (handle) clearInterval(handle); } Here's a working example using your code: http://jsfiddle.net/umwo0rn1/25/


1

this works for me: function bindNewPopup(){ this.bindPopup(randomText()); } var marker = L.marker([47.16, -115.32]) .on('click', bindNewPopup) .addTo(map); The code in your gist only gets a randomText() when the marker is created. To change the text on every click, you need some way to call the function again; therefore create the ...


1

Overwrite the defaults in L.Path with: L.Path.include({options: newDefaultStyle}); e.g.: L.Path.include({options: { color: '#dd8855', fillOpacity: 0.5 }});


1

There are two possibilities I found (I have had the same problem). For the first one, the answer on top help. I was trying to do it as you did, without using the <script> tag to load the files, but if you do so, it works. Declare each JSON file using the <script> tag: <script src="JSONFILE-1.js" type="text/javascript"></script> ...


1

Leaflet tiles have the leaflet-tile class You can use css to make the border visible .leaflet-tile { border: solid black 5px; } This would create black borders for each tile. It worked for this example https://www.mapbox.com/mapbox.js/example/v1.0.0/wms/ by editing in the developer console of the browser.


1

Another plugin leaflet-image The plugin is working well with standard markers, for export leaflet map with special markers you can see export-leaflet-map-to-image


1

We have implemented WFST plugin here: https://github.com/Flexberry/Leaflet-WFST It supports reading GML and GeoJSON data, and can send transaction requests (insert, update, delete).


1

If you can see your layer on a map using L.TileLayer, the problem is in the boundary polygon you pass in L.TileLayer.BoundaryCanvas. It is difficult to guess the exact problem without example sources, but you can try the following checks: Add your layer using L.TileLayer and your boundary using L.Polygon (or using L.GeoJOSN). Check that your polygon ...


1

One option would be to use leaflet point in poly (leaflet.pip) which is available through Mapbox: https://www.mapbox.com/mapbox.js/example/v1.0.0/point-in-polygon/ Or as a leaflet plugin: https://github.com/mapbox/leaflet-pip The fiddle here: http://jsfiddle.net/TnX96/136/ will show exactly how this would work. Or see the code below.... HTML be sure to ...



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