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
Describe the bug
When you move the map to where its transform state has a longitude over 180 (or less than -180), Map::pixelForLatLng() will no longer work.
To Reproduce
In your zoom call, print abs(map->getTransfromState().getLatLng().longitude()).
Also print a value from map->pixelFotLatLng().
Pan and zoom the screen to where the 180th meridian is near the center of the screen. Keep moving the map around until you see the longitude go greater than 180 in the print out.
Once the longitude is over 180, you will notice that the x pixel values from Map::pixelForLatLng() go way out of bounds or negative.
Expected behavior
Map::pixelForLatLng() should return a legit value.
Platform information (please complete the following information):
ScreenCoordinate Map::pixelForLatLng(const LatLng& latLng) const {
// If the center and point longitudes are not in the same side of the
// antimeridian, we unwrap the point longitude so it would be seen if
// e.g. the next antimeridian side is visible.
LatLng unwrappedLatLng = latLng.wrapped();
unwrappedLatLng.unwrapForShortestPath(impl->transform.getLatLng());
auto result = impl->transform.latLngToScreenCoordinate(unwrappedLatLng);
// Hack: We correct for the case where longitude goes out of bounds.
if (abs(getTransfromState().getLatLng().longitude()) > 180.0)
{
auto const shift = impl->transform.latLngToScreenCoordinate(impl->transform.getLatLng());
result.x = (getTransfromState().getSize().width / 2.0) + (result.x - shift.x);
}
return result;
}
Additional Info
getTransfromState().getLatLng() returns an unwrapped coord, and impl->transform.getLatLng() returns a wrapped coord. I'm not sure if that is the intended design.
Also, I wonder if this is related to #2951 since it also deals with the 180th meridian.
The text was updated successfully, but these errors were encountered:
Describe the bug
When you move the map to where its transform state has a longitude over 180 (or less than -180), Map::pixelForLatLng() will no longer work.
To Reproduce
Expected behavior
Map::pixelForLatLng() should return a legit value.
Platform information (please complete the following information):
Hack/Fix
This is my temporary hack:
Additional Info
getTransfromState().getLatLng() returns an unwrapped coord, and impl->transform.getLatLng() returns a wrapped coord. I'm not sure if that is the intended design.
Also, I wonder if this is related to #2951 since it also deals with the 180th meridian.
The text was updated successfully, but these errors were encountered: