You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Currently due to lack of support in core GL layer, we don't support anchor() with Marker. An anchor is a custom point in the Marker image (using a GL texture like coordinate system of 0 to 1) where we assign the Markers 'position()` to.
Currently we just use the centre of the image. You can see this is the default red marker image which is twice as high as needed (and padded with transparent pixels) to push the tip of the marker to the image centre. A anchor function would remove the need for this padding.
However this is not currently on our core GL roadmap.
A similar infoWindowAnchor() function would be easy to implement currently as it would only require changes to Java.
Hi, I was working on an Android app and experimenting with somewhat bigger markers on Mapbox maps with images. Since the marker is fairly big (having a big marker is kind of necessary for the app. I just need 1 marker for the map and no marking of routes involved), I would definitely need the anchor for the marker. The big marker currently gets a very inaccurate position on the map and gets worse while zooming in/out of the map in different views. Is there any workaround regarding the same? Any help would be appreciated. Thanks! :)
The (already mentioned) workaround here is to double the height of your marker asset, such that the desired anchor is also the true center. This is how our marker images currently work.
Thanks for your response. I'm doing exactly that for the workaround. I was just worried if clicking on the empty space would also trigger the onMarkerClick actions. But, so far there haven't been any issues. :)
Just for reference, if somebody else is looking for a hack and lands on this thread, this is the code I'm using:
Looking into this, I feel the only real good solution would be a feature in core.
We could go with a hack as suggested above but this will be not very efficient.
I need to check what status is for core GL roadmap on this feature.
Looking into this, I feel the only real good solution would be a feature in core.
After discussing this with @tobrun, I propose the following:
Replace Map::getTopOffsetPixelsForAnnotationIcon withMap::getAnnotationIconOrigin, with origin being a ScreenCoordinate to comply with both axis customization.
Add an optional anchor parameter to addAnnotationIcon, which will be the return value for the function suggested above, being the top left position the fallback value.
This comment from the related iOS issue is relevant.
The "right way" to implement this is via the icon-offset or icon-translate style properties. But in order to control those per-annotation, we need either data-driven styles or control over annotation grouping into layers.
Activity
ljbade commentedon Nov 3, 2015
/cc @tobrun @bleege @zugaldia
thatsvishalhere commentedon Dec 29, 2015
Hi, I was working on an Android app and experimenting with somewhat bigger markers on Mapbox maps with images. Since the marker is fairly big (having a big marker is kind of necessary for the app. I just need 1 marker for the map and no marking of routes involved), I would definitely need the anchor for the marker. The big marker currently gets a very inaccurate position on the map and gets worse while zooming in/out of the map in different views. Is there any workaround regarding the same? Any help would be appreciated. Thanks! :)
tobrun commentedon Jan 4, 2016
@thatsvishalhere
Thank you for reaching out and highlighting this issue.
It will help a lot when trying to implement the feature / resolve the incorrect positioning,
thatsvishalhere commentedon Jan 4, 2016
Hi, thanks for your reply. I'm using markers of height more than 48 dp. For example you may consider this marker, https://github.com/google/material-design-icons/blob/master/navigation/drawable-mdpi/ic_arrow_downward_black_48dp.png. I can't anchor the lowermost tip of the marker to a particular point in the map. Since I want to show the correct point on the map with the lowermost tip and the anchor is of the image is set to the middle of the icon, I can't really show the right location on the map. The lower most point on the icon is pointing to different locations on the map on zoom in/out and rotation of the map.
friedbunny commentedon Jan 4, 2016
The (already mentioned) workaround here is to double the height of your marker asset, such that the desired anchor is also the true center. This is how our marker images currently work.
thatsvishalhere commentedon Jan 4, 2016
Thanks for your response. I'm doing exactly that for the workaround. I was just worried if clicking on the empty space would also trigger the onMarkerClick actions. But, so far there haven't been any issues. :)
Just for reference, if somebody else is looking for a hack and lands on this thread, this is the code I'm using:
Thanks again for your response!
1 remaining item
tobrun commentedon Apr 4, 2016
I'm picking this up, since this is a blocker for #3643 and a highly requested feature.
tobrun commentedon Apr 4, 2016
Looking into this, I feel the only real good solution would be a feature in core.
We could go with a hack as suggested above but this will be not very efficient.
I need to check what status is for core GL roadmap on this feature.
bleege commentedon Apr 4, 2016
👍
brunoabinader commentedon Apr 5, 2016
After discussing this with @tobrun, I propose the following:
Map::getTopOffsetPixelsForAnnotationIconwithMap::getAnnotationIconOrigin, withoriginbeing aScreenCoordinateto comply with both axis customization.anchorparameter toaddAnnotationIcon, which will be the return value for the function suggested above, being the top left position the fallback value.jfirebaugh commentedon Apr 5, 2016
This comment from the related iOS issue is relevant.
The "right way" to implement this is via the
icon-offsetoricon-translatestyle properties. But in order to control those per-annotation, we need either data-driven styles or control over annotation grouping into layers.tobrun commentedon Apr 6, 2016
@jfirebaugh thank you for the 👀, will not work or ping people for this or similar issues until the dust from implementing the style api has settled.
tobrun commentedon Jun 21, 2016
Closing as it will be automatically be picked up again with style api and we have a workaround with view annotations in place.
andre99 commentedon Jul 17, 2016
Just in case someone comes across this and needs it working on v4.1.0, I have found a solution.
If you call MarkerViewManager.ensureInfoWindowOffset() with the marker that you've just added it will add the marker correctly.