Open zeljkoX opened 6 years ago
This is example of what I got in onRegionDidChange: { properties: { isUserInteraction: true, animated: false, pitch: 0, visibleBounds: [ [ 43.93220182671985, 56.41581361366437 ], [ 43.99874648238108, 56.218418519742016 ] ], heading: 313.4841380532595, zoomLevel: 10.273156629654782 }, geometry: { coordinates: [ 43.96442281512964, 56.31719488949874 ], type: 'Point' }, type: 'Feature' }
This is how I interpreted it: { latitude: 56.31719488949874, longitude: 43.96442281512964, latitudeDelta: 0.19739509392235277, longitudeDelta: 0.06654465566123235, latitudeSW: 56.218418519742016, longitudeSW: 43.99874648238108, latitudeNE: 56.41581361366437, longitudeNE: 43.93220182671985 }
Sometimes coordinates are out of visibleBounds (which is impossible), and sometimes, NE long, or NE lat, should be swapped.
After some empirical research, it seems that this happens for headings below -30 degrees, and above +55 degress. It seems to work correctly for angles between 0 - 55, and 330 - 360. This is not fact, maybe error just accumulates as we rotate away from 0 heading.
I have figured it out. Android gives coordinates of upper right and lower left corner of view port, while, iOS gives north-east, and south-west. In case map is not oriented towards north, it will give coordinates of upper right and lower left corner, as if map is oriented to the north. That means, that these are not visible bounds, because this points might not be in view port. What ever you choose it should be consistent. I think this should be marked as bug.
We will align this behavior with iOS, this is 100% a bug
This bug is just for Android, as stated in title, on iOS everything works.
So I use map bounds(lat SW, long SW, lat NE, long NE) in order to query server for annotation points.
When using bounds in combination with map rotation I get wrong result. Sometimes map bounds values change places in returning array.
Also I noticed that for some values of heading angle bounds values are correct.
When map rotation is disabled bound values are correct.
Wrong bound values come, both, from onRegionDidChange prop and getVisibleBounds method.
When I say map rotation is enabled I am talking about using below code. Angle value come from gyroscope sensor.