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

-[MGLMapView showAnnotations:] should span the antimeridian #8708

Closed

Description

@ab-rdarts

Platform:
iOS
Mapbox SDK version:
3.5.2

Steps to trigger behavior

  1. Add annotations like (latitude:0, longitude:179), (latitude:0, longitude:0), (latitude:0, longitude:-180)
  2. use showAnnotations method

Expected behavior

MapView shows three annotations

Actual behavior

MapView shows only two annotations and only after pan map a little bit (doesn't work at all if not pan)

TestMap.zip

Activity

  1. added
    annotations
    iOS
    on Apr 11, 2017
  2. 1ec5 commented on Apr 13, 2017

    @1ec5
    Contributor

    It isn’t possible to zoom all the way out to the point where the Prime Meridian, antimeridian, and 179° east are all visible at the same time. The map is constrained to avoid showing multiple “copies” of the world simultaneously and to avoid showing anything beyond 85.051129° north or south (due to Web Mercator projection). In the sample application provided above, the map view is 375 points wide and 563 points tall. At this aspect ratio, attempting to show all three annotations would require breaking both of those constraints.

  3. changed the title [-]showAnnotations works in wrong way[/-] [+]Unable to show all longitudes in portrait orientation[/+] on Apr 13, 2017
  4. jfirebaugh commented on Apr 13, 2017

    @jfirebaugh
    Contributor

    @1ec5 Should we close this as working as designed then?

  5. ab-rdarts commented on Apr 13, 2017

    @ab-rdarts
    Author

    @1ec5 I understand that in this particular case it's not possible to fit all annotations, but the problem in another side. you can move annotation (0, 0) close to other annotations so that it can fit. And in this case it will not work also, it will show only two of them which close to 180 longitude. You should take into account span of longitude and latitude instead of calculating min/max of longitudes.

    try to change array of annotations to these and you will see that it doesn't work correct:

            let annotations = [Annotation(latitude: 0, longitude: 179),
                               Annotation(latitude: 0, longitude: 160),
                               Annotation(latitude: 0, longitude: -180)]
    

    it's possible now to fit all three markers, but showAnnotations show only two of them.
    In my opinion you should calculate span of latitude/longutude, set center and zoom appropriately

  6. changed the title [-]Unable to show all longitudes in portrait orientation[/-] [+]-[MGLMapView showAnnotations:] should span the antimeridian[/+] on Apr 13, 2017
  7. 1ec5 commented on Apr 13, 2017

    @1ec5
    Contributor

    That’s a good point, @ab-rdarts! I’ve retitled this issue to reflect the fact that -showAnnotations: should be able to straddle the antimeridian if necessary. (Another use case would be showing a single polyline annotation corresponding to the borders of Russia.) This would require mbgl::Map::cameraForLatLngs() to be able to straddle the antimeridian as well.

  8. 1ec5 commented on Apr 14, 2017

    @1ec5
    Contributor

    Fixed in #8744.

  9. added
    macOS
    on Apr 14, 2017
  10. added this to the ios-v3.6.0 milestone on Apr 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    annotationsbugiOSmacOS

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions