Comments (8)
Looking forward to this.
from leaflet-measure.
I do like this feature. I know there have been multiple requests, but I don't have a solution that catches all cases well. Any suggestions would be appreciated. Until then, using the start/finish events may be the way to go.
from leaflet-measure.
Well, I don't have a good answer. But I do know that the start/finish is not working well for me. In the example below Car is a L.Marker. (But the truth is that I might have 100+ GeoJson and L.Markers each with a popup box associated with them). But even in the case where I manually do one (the ca). Even trying to turn off the popup, still does not work. Since that area is dead and I cannot put measure control points (they are blocked by the marker from appearing where the CAR is.
So I don't know if making things not clickable is all that needs to be done.
this.setupMeasure = function () {
measureControl = new L.Control.Measure({
position: 'topleft',
primaryLengthUnit: 'meters',
secondaryLengthUnit: 'feet',
primaryAreaUnit: 'sqmeters',
secondaryAreaUnit: 'acres'
});
theMap.on('measurestart',
function (e) {
self.carPopup = Car.theCar.getPopup();
Car.theCar.unbindPopup();
});
theMap.on('measurefinish',
function (e) {
Car.theCar.bindPopup(self.carPopup);
});
}
from leaflet-measure.
For your example, I think you will have better luck setting the marker to clickable = false
vs unbinding the popup. Unfortunately, the Leaflet API doesn't expose a way to set clickable
after the marker has already been created. There is a post on SO describing how this can be done. I haven't tried this, but it does look promising.
If you know all of the map layers in your application and have a reliable way to change their clickable state, I think this is the best solution. But as you mention, this could be an issue if you have too many markers, if you are adding/removing markers during an active measure (after the measure has started), or other cases where it is difficult to maintain what should be clickable what should not be clickable.
from leaflet-measure.
A couple options..
It would be difficult to disable/enable clicking on other map layers from the control. There are cases where keeping track of this state is complicated. Because there is no method to change clickable
on map layers in the Leaflet API, this could lead to other unforeseen issues. This still could be viable, it just needs more investigation.
Another option is to raise the z-index of the _measureDrag
marker (or maybe a new transparent marker that also follows the mouse cursor) above all other map layers and handle clicks on this feature instead of the map. This would effectively block out clicks on any existing map layers. This solution would not work on touch devices. This solution is probably more realistic.
from leaflet-measure.
I had seen the "clickable" option, but rejected it since it was a creation option. I tried the SO solution, but I am finding (in Chrome) that it is still a dead space around the Car marker, where one cannot put down measure control points. Raising Z-index is what I would have suggested, and your second option after that also makes sense to me.
from leaflet-measure.
Ok. Thanks. We're going to try something similar to the second option with an update coming soon.
The plan is to add a marker at the center of the map. The marker will have a transparent DivIcon
larger than the screen dimensions of the map, so it will cover the entire visible map. On each map moveend
, the marker will reposition itself to the new center. The marker will have a configurable z-index, set relatively high by default, ensuring it is on top of and blocking clicks on all other map layers. click
and dblclick
on the marker will add measure points just as those events on the map do now.
This is similar to the originally published version of this control. The issues then were 1. we were using a poygon covering the full WGS84 coordinate span (instead of the marker proposed here) and this broke on custom projections and 2. the polygon did not cover existing markers. Neither will be an issue with this plan.
from leaflet-measure.
#46 should solve this issue
from leaflet-measure.
Related Issues (20)
- Listening for measurefinish event HOT 1
- Is it possible to disable the autocomplete?
- Apply a different coordinate system to Coordinate Output?
- Measure not visible on layers HOT 6
- green dotted line appearing
- Adding Perimeter value to the measurefinish results data
- Customizing map feature styles?
- Polyline don't show up when measure starts - Django
- Angular 2 is unable to compile sass due to relative paths to package assets HOT 2
- localization HOT 3
- Show Measure Popup onclick
- Allow to adjust the vertices
- Does not work in Leaflet 1.8.0 HOT 8
- How to start the measurement directly whiling clicking the toggle button?
- Property 'Measure' does not exist on type 'typeof control' in Angular CLI HOT 2
- Is this project still upkept? HOT 5
- typings for Angular 14
- after clicking on map it changes center of the map HOT 3
- bug HOT 1
- Doesn't work with image overlays
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet-measure.