googlemaps / ios-maps-sdk

Google Maps SDK for iOS
Apache License 2.0
52 stars 6 forks source link

GoogleMaps: `GMSProjection` calculation error when doing a 3D tilt gesture #22

Open bobby-fi opened 5 months ago

bobby-fi commented 5 months ago

Environment details

Steps to reproduce

When using GMSMapView.projection.point(for:):

Sometimes seeing incorrect values for the calculated projected points

Scenarios:

All scenarios are using these coordinates for projection calculations:

[
    __C.CLLocationCoordinate2D(latitude: 40.796213, longitude: -72.638055),
    __C.CLLocationCoordinate2D(latitude: 40.795807, longitude: -72.637542),
    __C.CLLocationCoordinate2D(latitude: 40.795346, longitude: -72.6373),
    __C.CLLocationCoordinate2D(latitude: 40.79488, longitude: -72.637097),
    __C.CLLocationCoordinate2D(latitude: 40.794714, longitude: -72.637267),
    __C.CLLocationCoordinate2D(latitude: 40.794871, longitude: -72.636719),
    __C.CLLocationCoordinate2D(latitude: 40.794816, longitude: -72.636966),
    __C.CLLocationCoordinate2D(latitude: 40.794692, longitude: -72.637378),
    __C.CLLocationCoordinate2D(latitude: 40.794763, longitude: -72.637624),
    __C.CLLocationCoordinate2D(latitude: 40.79466, longitude: -72.638341),
    __C.CLLocationCoordinate2D(latitude: 40.794727, longitude: -72.63789),
    __C.CLLocationCoordinate2D(latitude: 40.794777, longitude: -72.637744),
    __C.CLLocationCoordinate2D(latitude: 40.794835, longitude: -72.637398),
    __C.CLLocationCoordinate2D(latitude: 40.79477, longitude: -72.637071),
    __C.CLLocationCoordinate2D(latitude: 40.794908, longitude: -72.636888),
    __C.CLLocationCoordinate2D(latitude: 40.794858, longitude: -72.63724),
    __C.CLLocationCoordinate2D(latitude: 40.796207, longitude: -72.638175),
    __C.CLLocationCoordinate2D(latitude: 40.786705, longitude: -72.635231)
]

Scenario 1: No tilt, projections are correct

Info: camera.zoom: 21.0 camera.bearing: 0.0 camera.viewingAngle: 0.0 projection.visibleRegion():

GMSVisibleRegion(
    nearLeft: __C.CLLocationCoordinate2D(latitude: 40.795967730633976, longitude: -72.63824209570885), 
    nearRight: __C.CLLocationCoordinate2D(latitude: 40.795967730633976, longitude: -72.63795375823973), 
    farLeft: __C.CLLocationCoordinate2D(latitude: 40.796440845303984, longitude: -72.63824209570885), 
    farRight: __C.CLLocationCoordinate2D(latitude: 40.796440845303984, longitude: -72.63795375823973)
)

Projections (GMSMapView.projection.point(for: _coordinate_)):

[
    (279.0000305175781, 449.0), 
    (1044.0, 1248.5), (1405.0, 2156.999755859375), 
    (1707.5001220703125, 3074.499755859375), 
    (1454.0, 3401.5), 
    (2271.500244140625, 3092.499755859375), 
    (1903.0, 3200.999755859375), 
    (1288.5, 3444.999755859375), 
    (922.0000610351562, 3305.0), 
    (-147.5, 3508.0), (525.0, 3376.0), 
    (743.0, 3277.499755859375), 
    (1259.0, 3163.499755859375), 
    (1746.5001220703125, 3291.499755859375), 
    (2019.5001220703125, 3019.5), 
    (1494.5, 3117.999755859375), 
    (100.00000762939453, 460.4999694824219), 
    (4490.5, 19177.498046875)
]

Scenario 2: Some tilt, projections are still correct

Info: camera.zoom: 21.0 camera.bearing: 0.0 camera.viewingAngle: 5.27223109279046 projection.visibleRegion():

GMSVisibleRegion(
    nearLeft: __C.CLLocationCoordinate2D(latitude: 40.79597229935399, 
    longitude: -72.63823874294758), 
    nearRight: __C.CLLocationCoordinate2D(latitude: 40.79597229935399, longitude: -72.63795711100101), 
    farLeft: __C.CLLocationCoordinate2D(latitude: 40.79644820596695, longitude: -72.63824578374624), 
    farRight: __C.CLLocationCoordinate2D(latitude: 40.79644820596695, longitude: -72.63795007020234)
)

Projections (GMSMapView.projection.point(for: _coordinate_)):

[
    (278.9004211425781, 449.1705017089844), 
    (1079.1568603515625, 1277.7587890625), 
    (1520.80419921875, 2312.550048828125), 
    (1944.7545166015625, 3474.443115234375), 
    (1680.2977294921875, 3920.747802734375), 
    (2601.040283203125, 3498.544677734375), 
    (2186.6044921875, 3644.959716796875), 
    (1488.0299072265625, 3981.49609375), 
    (1046.1187744140625, 3787.154052734375), 
    (-216.5809783935547, 4070.067138671875), 
    (581.0368041992188, 3885.2890625), 
    (834.6356811523438, 3749.376220703125), 
    (1431.5889892578125, 3594.134033203125), 
    (2013.8570556640625, 3768.592529296875), 
    (2299.331787109375, 3401.126220703125), 
    (1701.8555908203125, 3532.7802734375), 
    (100.1092758178711, 460.5931701660156), 
    (355610.65625, 1548234.125)
]

Scenario 3: More tilt, projections are giving invalid screen positions

Info: camera.zoom: 21.0 camera.bearing: 0.0 camera.viewingAngle: 13.7222311799457 projection.visibleRegion():

GMSVisibleRegion(
    nearLeft: __C.CLLocationCoordinate2D(latitude: 40.7959750913494, longitude: -72.63823337852955), 
    nearRight: __C.CLLocationCoordinate2D(latitude: 40.7959750913494, longitude: -72.63796247541904), 
    farLeft: __C.CLLocationCoordinate2D(latitude: 40.79646597308111, longitude: -72.63825248926878), 
    farRight: __C.CLLocationCoordinate2D(latitude: 40.79646597308111, longitude: -72.63794336467981)
)

Projections (GMSMapView.projection.point(for: _coordinate_)):

[
    (278.7434997558594, 449.9568786621094), 
    (1141.2845458984375, 1314.3035888671875), 
    (1758.3388671875, 2593.2509765625), 
    (2525.693359375, 4382.91650390625), 
    (2275.508544921875, 5200.82080078125), 
    (3411.028076171875, 4424.98974609375), 
    (2900.094482421875, 4685.55908203125), 
    (2018.0667724609375, 5318.85986328125), 
    (1365.58447265625, 4947.1015625), 
    (-402.77685546875, 5494.044921875), 
    (727.5779418945312, 5132.7021484375), 
    (1069.0631103515625, 4876.7763671875), 
    (1862.2835693359375, 4594.1240234375), 
    (2699.943603515625, 4912.47119140625), 
    (2976.6572265625, 4256.318359375), 
    (2214.291259765625, 4485.146484375), 
    (100.28165435791016, 461.0566101074219), 
    (1.1342744887950962e+38, 1.1342744887950962e+38)
]

note the last calculated projections with incorrect values: 1.1342744887950962e+38

appears to be some sort of overflow, since 1.1342744887950962e+38 is always returned in similar scenarios

wangela commented 5 months ago

If you would like to upvote the priority of this issue, please comment below or react on the original post above with :+1: so we can see what is popular when we triage.

@bobby-fi Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.