mapnik/mapnik — Issue #1122: SVG markers are not placed on the center of the SVG marker
Author: olt
Created: 2012-03-09 16:21:44+00:00
State: open

Right now SVG markers are placed on the center of the SVG object itself. (Mapnik calculates the bounding rect of all paths of the SVG). That way SVG markers are always centered, but this makes it impossible to place arrow like markers to point to an exact location.

A simple solution to place arrow-like markers is to create a larger SVG canvas and point the tip of the arrow to the center of the large canvas. That does work great with OpenLayers or MapFish Print, but not with Mapnik.
I did a quick hack to read the actual SVG canvas size from the XML, instead of calculating it, and it works great. See here:
https://github.com/olt/mapnik/commit/3f6cf0f8efd052570d98f66d89e9770708288568

Unfortunately, the bounding rects are calculated inside the marker cache, so it is not easy to make this an option for the PointSymbolizer. Or am I missing something? What would be the best way to add this behavior?