I can create a custom marker as a png, and specify its path in the filesystem, in the setting "Marker icon path" in the Settings for "Geolocation CommonMap"
However the anchor point, i.e. the point within the market/peg upon which it is "pinned" to the map, cannot be set. This point is the actual latitude longitude co-ordinates.
I want to be able to define the anchor point so that the marker suitably marks a position on the map. For example for the traditional inverted tear drop shape map markers, the thin end tip is the anchor point.
At the moment my custom markers can be plotted on the map, but each of their anchor points is the top left corner of their png image.
The attached screenshot illustrates how the custom markers are (incorrectly) positioned compared with the default marker.
| Comment | File | Size | Author |
|---|---|---|---|
| 2018 08 14 geolocation 8.x-2.x openstreetmap custom marker anchor point.PNG | 325.45 KB | therobyouknow |
Comments
Comment #2
therobyouknow commentedComment #3
didebruI have the same problem my solution so far is a hardcoded patch, not nice!
I have tried to implement 2 more form number fields but was unable to put them in the markerSettings object as it was not clear to me where the switch from drupal to js happened.
If anyone can point it where the $this->options variable from the CommonMapBase.php Class is give to js I will write a patch.
https://stackoverflow.com/questions/17875438/leafletjs-markers-move-on-z...
This is done in the geolocation-leaflet-api.js file but without iconSize and iconAnchor.
Another approach could be to get the width and height directly from the image file via php and than divide width(x) by 2 for the anchor.
Comment #4
christianadamski commentedWell, does #2995694: Add "Marker Icon Adjustment" to the Leaflet help?
Comment #5
didebruOh I am sorry have overseen that I'll give it a try! Yes it worked but I would remove the form element to set the icon path in commonmapbase.php than.
Comment #6
christianadamski commentedHijacking this issue as the original problem was fixed by the linked issue.
- Write update hook to copy marker icon path from views style to either Google or Leaflet Map Feature
- remove setting
Comment #7
christianadamski commented