-
Notifications
You must be signed in to change notification settings - Fork 1.3k
setZoom overwrites setLatLng #10928
Comments
I was able to reproduce this issue: The following code will position the camera correctly above the U.S. capitol: mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
mapboxMap.setZoom(20);
mapboxMap.setLatLng(new LatLng(38.889783, -77.009037));
mapboxMap.setZoom(16);
}
}); While the following code places us somewhere in Ecuador: mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
mapboxMap.setLatLng(new LatLng(38.889783, -77.009037));
mapboxMap.setZoom(16);
}
}); |
Been debugging our C++ code and I'm seeing the folllowing easeTo invocations in transform.cpp: First code block
Second code block
While the intermediate results are the same, it's not resulting in the same transformation. Note: above latlng values equal to the camera definition passed into easeTo. |
Looked more into the calculated values of easeTo, below you can see the start LatLng value for each easeTo invocation: First code block
Second code block
|
I identified that the 0 latitude value is coming from static LatLng unproject(const Point<double>& p, double scale, LatLng::WrapMode wrapMode = LatLng::Unwrapped) {
auto p2 = p * util::DEGREES_MAX / worldSize(scale);
return LatLng {
util::DEGREES_MAX / M_PI * std::atan(std::exp((util::LONGITUDE_MAX - p2.y) * util::DEG2RAD)) - 90.0,
p2.x - util::LONGITUDE_MAX,
wrapMode // unwrapped
};
} Since this method is called multiple times, it's hard to tell where the calculation is going wrong. FWIW when the 0 occurs: p2.y = 180 |
This is expected behavior; at low zoom levels, @tobrun, can you ensure that this is mentioned in the Android documentation? |
@jfirebaugh How is that expected behavior. If you dont change the behavior be sure you add this information at a prominent position in the javadoc and in the getting started. |
@jfirebaugh I had a hunch this was expected behaviour. On top of adding documentation, I think exposing a method as |
You can already set the center and zoom simultaneously with |
The api's from OP have been removed, issue is not longer actionable. |
Hi,
I've found that when calling setLatLng and then setZoom. The position set in setLatLng is not centered anymore. When calling setZoom first it works as expected. It would be nice if this bug could be documented in the javadoc of MapboxMap.
Platform: Android
Mapbox SDK version: 5.3.1
Steps to trigger behavior
Expected behavior
The mapview shows the map in the set zoom and at the position centered.
Actual behavior
The mapview shows the map in the set zoom and at some location near the position.
PS: I've seen this issue on the OnePlus 5 and OnePlus 5t. I've also seen it on an emulator of a colleague but was not able to replicate it by myself. Also my Motorola G 2014 (titan) wasn't showing bug.
The text was updated successfully, but these errors were encountered: