Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Location mark (not drawn) disappears when view crosses international date line. #3995

Closed
manimaul opened this issue Feb 18, 2016 · 13 comments
Closed
Labels
Android Mapbox Maps SDK for Android bug

Comments

@manimaul
Copy link

Given the view crosses the international date line (180 degrees E)
Given the center of the screen is right/east of the dateline
When the user location is east of the dateline
Then the user location should be drawn (but is not drawn)

See below screenshots where the location is: 16.85 S , 179.89 W
device-2016-02-17-162405
device-2016-02-17-162442

@friedbunny friedbunny added bug Android Mapbox Maps SDK for Android labels Feb 18, 2016
@tobrun
Copy link
Member

tobrun commented Feb 18, 2016

@manimaul thank you for reporting this edge-case, this is great information to have.

@friedbunny
Copy link
Contributor

edge-case

There's no edge like the dateline edge. 🤔

@manimaul
Copy link
Author

@tobrun yes, dealing with the dateline is always fun. I'm wondering if you're willing to escalate this issue as it is a blocker for me. I have a large audience in New Zealand who use my app (MX Mariner) on the water, near the dateline. I'm currently using the previously deprecated Mapbox SDK and this is the remaining issue before making the switch to Mapbox GL. Thank you,
Will

@mb12
Copy link

mb12 commented Feb 21, 2016

@manimaul I would recommend looking at the following known issues for Android before switching over to new SDK. Your application will stop working on certain devices (where it previously worked including older Google Galaxy Nexus).

#2980
#4037
#3693
#1702

@manimaul
Copy link
Author

@mb12 thanks, I'll definitely keep an eye on those issues before making the leap.

@tobrun tobrun added this to the android-v4.0.0 milestone Feb 24, 2016
@tobrun
Copy link
Member

tobrun commented Feb 25, 2016

@manimaul I added this issue to the higher priority list of bugs to solve. Sorry for not being able to give you a concrete ETA. It is not the only issue on that list. For now I'm doing some small tests around this issue to identify the source and determine the amount of work needed to get a fix in.

@tobrun
Copy link
Member

tobrun commented Feb 25, 2016

@manimaul could you give me some more information how you are setting this test up?
All the mock GPS apps I have tested, don't work with this dateline issue.
Example of this here, where you can see it's going the opposite direction.

@manimaul
Copy link
Author

@tobrun I'm using the Genymotion Android emulator which makes it easy to set the device's location.

other options:

  1. Use the standard Android emulator and send a mock "geo" command via adb described here: http://developer.android.com/guide/topics/location/strategies.html
  2. Use the "new" beta Android emulator which has a GUI similar to Genymotion for setting the mock location. http://tools.android.com/tech-docs/emulator

@tobrun
Copy link
Member

tobrun commented Mar 1, 2016

@manimaul
thank you for adding that information. I was tackling this issue from the perspective of having a route/gps trace. Looking into manually setting the location reveals the following:

screen shot 2016-03-01 at 11 02 17

if you pan the map a bit to the right, the UserLocationView disappears:

screen shot 2016-03-01 at 11 02 25

The source of that issue will be the solution to what is mentioned above.

@tobrun
Copy link
Member

tobrun commented Mar 1, 2016

I was able to pinpoint this to toScreenLocation method returning the wrong values when crossing the dateline. This toScreenLocation is used in the following method:

    public PointF getMarkerScreenPoint() {
        if (mMyLocationTrackingMode == MyLocationTracking.TRACKING_NONE) {
            mMarkerScreenPoint = mProjection.toScreenLocation(mMarkerCoordinate);
        } else {
            // tracking the user
        }
        return mMarkerScreenPoint;
    }

This method is being called on every update call, to get the correct x,y coordinates for the UserLocationView. Currently not the correct values are returned.

For example:
before crossing the dateline:

MarkerScreenPoint 455.80133:746.6456

after

MarkerScreenPoint 393667.44:747.1837

@tobrun
Copy link
Member

tobrun commented Mar 1, 2016

Been trying to locate this problem in C++.

It is going through map.cpp, transform.cpp and transform_state.cpp.

In transform_state.cpp it is using the following method:

PrecisionPoint TransformState::latLngToPoint(const LatLng& latLng) const {
    return coordinateToPoint(latLngToCoordinate(latLng));
}

which on his turn calls coordinateToPoint and latLngToCoordinate:

PrecisionPoint TransformState::coordinateToPoint(const TileCoordinate& coord) const {
    mat4 mat = coordinatePointMatrix(coord.zoom);
    matrix::vec4 p;
    matrix::vec4 c = {{ coord.column, coord.row, 0, 1 }};
    matrix::transformMat4(p, c, mat);
    return { p[0] / p[3], height - p[1] / p[3] };
}
TileCoordinate TransformState::latLngToCoordinate(const LatLng& latLng) const {
    const double tileZoom = getZoom();
    const double k = zoomScale(tileZoom) / worldSize();
    return {
        lngX(latLng.longitude) * k,
        latY(latLng.latitude) * k,
        tileZoom
    };
}

@tobrun
Copy link
Member

tobrun commented Mar 1, 2016

I made a follow up issue #4155, since this problem is found in mbgl instead of Android SDK.

@tobrun
Copy link
Member

tobrun commented Mar 6, 2016

I'm closing this issue in favour of #4155

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android bug
Projects
None yet
Development

No branches or pull requests

4 participants