Comments (2)
Hi, and thanks for using my plugin!
I hoped to find a way to have rotation on markers without any new class, as the plugin already relies on many, but maybe I shouldn't care, and your solution is really simple and elegant.
Can I add your L.MarkerWithAngle
class to the source, and provide a boolean option like rotate
on L.Symbol.Marker
, to choose it instead of the simple L.Marker
class? I think it would be a good fix to this issue.
Or maybe you want to contribute a pull-request yourself?
About your question, it is complex matter, as nothing is really "wrong" technically speaking. The angle at each point seems to be properly computed, but on complex polylines it may result in overlaping symbols or worse, like on your 1st example, symbols that seem wrong although they indicate the right direction at the local level.
I don't see any easy solution right now, mainly because the drawing process is independant from the one computing points on the polyline.
It is somewhat linked to the bug #3 about dashes, although in that case I see quite well how to do it at the drawing step...
Can you elaborate on your idea of interpolating the points please?
I will think on the problem, thanks for pointing it!
from leaflet.polylinedecorator.
Hello!
I'm trying to use your nice plugin for adding direction arrows to a polyline.
Marker's rotation is planned in a "future" milestone: Leaflet/Leaflet#143
Meanwhile I've extended the L.Marker
in this way:
L.MarkerWithAngle = L.Marker.extend({
options: {
angle: 0
},
_setPos: function (pos) {
L.Marker.prototype._setPos.call(this, pos);
this._icon.style.MozTransform = this._icon.style.WebkitTransform + ' rotate(' + this.options.angle + 'deg)';
this._icon.style.MsTransform = this._icon.style.WebkitTransform + ' rotate(' + this.options.angle + 'deg)';
this._icon.style.OTransform = this._icon.style.WebkitTransform + ' rotate(' + this.options.angle + 'deg)';
this._icon.style.WebkitTransform = this._icon.style.WebkitTransform + ' rotate(' + this.options.angle + 'deg)';
}
});
and added a new Symbol using a DivIcon
for the marker using a plain-text rightwards arrow as html.
L.Symbol.Arrow = L.Class.extend({
buildSymbol: function (directionPoint, latLngs, map, index, total) {
var marker = new L.MarkerWithAngle(directionPoint.latLng, {
clickable: false,
draggable: false,
icon: new L.DivIcon({
html: 'β'
}),
angle: directionPoint.heading - 90 // since icon's is a rightwards arrow
});
return marker;
}
});
(You may need this CSS)
.leaflet-marker-icon.leaflet-div-icon {
background: none;
border: 0;
color: blue;
font-size: 18px;
}
While it works great for straight polylines, there're cases when it doesn't work (see attach), usually when there are curves. What would you do? The basic idea would just to not draw the decoration when it's "wrong", but also wecan interpolate the points in some way...
from leaflet.polylinedecorator.
Related Issues (20)
- How in leaflet add custom data to polyline?
- I'd like to ask you how to add slashes to polygons, like this
- how do i delete some arrow on the map HOT 1
- Separate colors for stroke, fill HOT 1
- Markers Color HOT 9
- Leaflet polyline decorator HOT 1
- Decorator onclick event retrieve property HOT 1
- How to disable arrow auto scale? HOT 2
- Using polylineDecorator with ant-path is not working HOT 1
- Show/Hide Polylinedecorators dynamically (based on other variable) in React Leaflet
- Is there any option to prevent collision between arrows?
- How to add multiple arrows in one lineοΌ HOT 2
- How do I make my arrowhead pointy? HOT 2
- Issue with Leaflet.PolylineOffset
- rotationAngle conflicts with Leaflet.RotatedMarker HOT 4
- L.polylineDecorator is Undefined HOT 2
- PolylineDecorator always top layer even when calling bringToBack() HOT 3
- Polyline decorator doesn't preserve the state of symbol styling HOT 1
- Problem with fullscreen control
- Problem with using method setPaths
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.polylinedecorator.