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.
Sprite location appears to move when map is zoomed in and out #1121
The default marker has a visual indication of a pointer, however the sprite is centered above the annotations location. Because of this, the marker appears to point to different locations as the map is zoomed in and out. Possible solution, the sprite data should contain an offset location to indicate the "visual" center of the image.
The default marker, like our markers API, uses a partially-transparent image where the point of the pin is actually at the image center. So this shouldn't be happening?
Here is a quick example. The marker is at a fixed lat/lon, only the map zoom is changed. As you can see, the marker sometime appears to point north of the road when zoomed in, but south of the road when zoomed out. Obviously, the more extreme the zooming, the more obvious the discrepancy.
But I do agree with your reasoning that this should not be happening.
I suspect it may be an @2x issue when calculating the image size or center point. The same this happens with our custom marker when I adjust the height so the the point "should" be in the center.
Here’s an interesting experiment: place the pin directly atop a label, such that the visual tip of the pin pierces the label. Center the map on the pin. Then zoom out slowly. The pin and label are in sync as they both begin to drift. Below, the label “Emerald” should be near the center of the station building, but as you zoom out it wanders onto the tracks:
Well, that's interesting. I don't know offhand how labels' anchor points are specified, but it would seem that whatever is wrong affects them both. I'm not sure if it's problematic for labels, but it definitely proves the bug for points.
Ha, this was a sprite size specification miscomm between @peterqliu and I. Check out old vs. new, where new specifies that the marker was twice as tall, encompassing the blank space at the bottom like Maki markers do, so that the point of the marker is in the image center:
The "point" actually switches sides of the street and the latter, north-side one is correct — and doesn't move.
@peterqliu's rolling some style updates including this to fix now.
Hmm, are you saying that we changed the marker image to contain blank space at the bottom? Let's not do that -- it was a mistake in our markers API / mapbox.js that we shouldn't repeat.
We then need to communicate a marker offset in the sprite JSON back to the code so that it knows how to place the marker — its style is created on-the-fly in code and we shouldn't require the user to specify an offset at runtime when they specify an image. It makes an already-clumsy stopgap marker method that much more clumsy.
I looked into adding an offset property in the sprite JSON but it seemed like high overhead for a holdover method of annotation styling.
I don't think a sprite JSON property is required -- the intended way to do this type of relative positioning of symbol icons is via the style properties icon-translate and icon-translate-anchor: viewport. Can you ticket this as a post-beta 1 issue?
Specifying style properties at runtime for each marker is awkward when the imagery is already put into the sprite sheet statically before runtime. For b1 we are telling the user to add a marker and specify e.g. default_marker as the marker to use at runtime. We don't also want them to have to know anything in code about the translation properties of this image and/or pass those as well, either per-marker or at map setup time with some sort of registration for each marker image being used. It just makes an awkward holdover API more awkward.
Post-beta 1, we will hopefully be passing bitmap imagery across the wire instead of relying on pre-made sprite sheets, so this point is moot. At that point, since you are supplying imagery at runtime (which might be created on-the-fly anyway), passing things like calloutOffset and centerOffset is much more natural.
Activity
incanus commentedon Mar 26, 2015
The default marker, like our markers API, uses a partially-transparent image where the point of the pin is actually at the image center. So this shouldn't be happening?
picciano commentedon Mar 26, 2015
Here is a quick example. The marker is at a fixed lat/lon, only the map zoom is changed. As you can see, the marker sometime appears to point north of the road when zoomed in, but south of the road when zoomed out. Obviously, the more extreme the zooming, the more obvious the discrepancy.
But I do agree with your reasoning that this should not be happening.
incanus commentedon Mar 26, 2015
Hmm, weird. This is in GL, so it shouldn't be a sync or screen conversion issue. Will check on the sprite centering etc.
picciano commentedon Mar 26, 2015
I suspect it may be an @2x issue when calculating the image size or center point. The same this happens with our custom marker when I adjust the height so the the point "should" be in the center.
1ec5 commentedon Mar 27, 2015
Here’s an interesting experiment: place the pin directly atop a label, such that the visual tip of the pin pierces the label. Center the map on the pin. Then zoom out slowly. The pin and label are in sync as they both begin to drift. Below, the label “Emerald” should be near the center of the station building, but as you zoom out it wanders onto the tracks:
/cc @ansis
incanus commentedon Mar 27, 2015
Well, that's interesting. I don't know offhand how labels' anchor points are specified, but it would seem that whatever is wrong affects them both. I'm not sure if it's problematic for labels, but it definitely proves the bug for points.
/cc @ansis
ansis commentedon Mar 27, 2015
What is the style for this point's layer? the point and icon are in gl-land right?
incanus commentedon Mar 27, 2015
@ansis It's made on the fly here:
mapbox-gl-native/src/mbgl/style/style_parser.cpp
Lines 34 to 63 in 5c6809f
incanus commentedon Apr 1, 2015
Ha, this was a sprite size specification miscomm between @peterqliu and I. Check out old vs. new, where new specifies that the marker was twice as tall, encompassing the blank space at the bottom like Maki markers do, so that the point of the marker is in the image center:
The "point" actually switches sides of the street and the latter, north-side one is correct — and doesn't move.
@peterqliu's rolling some style updates including this to fix now.
incanus commentedon Apr 1, 2015
Slider quick-zooming test code for later: https://gist.github.com/incanus/5638f2466416b9c4ed57
jfirebaugh commentedon Apr 1, 2015
Hmm, are you saying that we changed the marker image to contain blank space at the bottom? Let's not do that -- it was a mistake in our markers API / mapbox.js that we shouldn't repeat.
incanus commentedon Apr 1, 2015
We then need to communicate a marker offset in the sprite JSON back to the code so that it knows how to place the marker — its style is created on-the-fly in code and we shouldn't require the user to specify an offset at runtime when they specify an image. It makes an already-clumsy stopgap marker method that much more clumsy.
I looked into adding an
offsetproperty in the sprite JSON but it seemed like high overhead for a holdover method of annotation styling.jfirebaugh commentedon Apr 1, 2015
I don't think a sprite JSON property is required -- the intended way to do this type of relative positioning of symbol icons is via the style properties
icon-translateandicon-translate-anchor: viewport. Can you ticket this as a post-beta 1 issue?incanus commentedon Apr 1, 2015
My point is twofold:
default_markeras the marker to use at runtime. We don't also want them to have to know anything in code about the translation properties of this image and/or pass those as well, either per-marker or at map setup time with some sort of registration for each marker image being used. It just makes an awkward holdover API more awkward.calloutOffsetandcenterOffsetis much more natural.jfirebaugh commentedon Apr 2, 2015
👍, makes sense. Thanks for the explanation.
incanus commentedon Apr 2, 2015
Fixed in @peterqliu's Emerald sprite update in 523295a.