I've created my markers with a small offset so that the tip of the marker is exactly at the right location on my map. Now I want to draw lines between the markers, but when I do they are at the tip of the marker, and I'd like them to be at the center of the marker. I've checked the documentation, and searched SO and Google and don't see anything on creating a polyline offset, other than offsetting one line from another.
If I don't use an offset on my markers, the polyline is exactly where I want, but then my marker point is in the wrong location.
I'm also using pixel coordinates, as I'm using a custom map which is not a geographic location.
How can I do this?
Marker code
var baseIcon = L.Icon.extend({
options: {
shadowUrl: '/markers/shadow.png',
iconSize: [40, 40],
shadowSize: [41, 41],
iconAnchor: [20, 44], // this is the marker offset
shadowAnchor: [11, 45]
}
});
Polyline code
var pointA = map.unproject([3474, 12427], map.getMaxZoom());
var pointB = map.unproject([2298, 11596], map.getMaxZoom());
var pointList = [pointA, pointB];
var firstpolyline = new L.Polyline(pointList, {
color: 'red',
weight: 5,
opacity: 0.5,
smoothFactor: 1
});
firstpolyline.addTo(map);
