bbecquet / Leaflet.PolylineDecorator

A plug-in for the JS map library Leaflet, allowing to define patterns (like dashes, arrows, icons, etc.) on Polylines.
MIT License
492 stars 114 forks source link

put in svg for complete LineString #32

Open emrahkutlu opened 9 years ago

emrahkutlu commented 9 years ago

Hi, thank you for that great plugIn! I´m triying to put in an Image for a LineString. The Example shows that with airplanes on a Line. I would like to put a picture on that lineString, so the picture replaces the geometry. I#m doing that on top of GeoJSON data. The goal is to have more styling you can´t have with Leaflets pathOptions. 2015-03-06_09h56_54 In my example the svg wont take place on the LineString and the more you zoom out, the more they move away.

bbecquet commented 9 years ago

Hi, and thanks for your interest in my plugin. I'm not quite sure about the effect you want to achieve. Can you please paste the relevant pieces of code you use and have problems with? I'm not 100% sure but I think this is related to using svg symbols instead of raster images, something I haven't really considered when first coding my plugin and that I should probably improve.

emrahkutlu commented 9 years ago

Hi thanks, yes that seems to be so. I know, that the position of the SVG changes when i change the svg coords and size or the iconAnchor. But I haven't found the right configuration for this. And the other thing is that while zooming the SVG position won't correspond to the map. It would be so great if SVG would work. Here is the code: in JS:

var arrowHead = L.polylineDecorator(arrow, { patterns: [ { offset: '50%', repeat: '0%', symbol: L.Symbol.marker({rotate: true, markerOptions: { icon: L.divIcon({ className: 'stepsSVG', //iconSize: null, //iconUrl: 'treppe3.svg', iconAnchor: [5, 50], }) }})} ]}).addTo(map);

in CSS:

.stepsSVG{ background-image : url(steps5.svg); }

the SVG:

milovanderlinden commented 9 years ago

I got a similar request. I currently create these linestyles with OpenLayers 2.x but want to migrate to Leaflet. The only barrier is complex line styles. Picture is an operational OpenLayers example.

screenshot from 2015-04-08 23 04 03