Open JosefWN opened 2 years ago
Hi @JosefWN,
Can you try using the LatLngBounds.fromPoints
constructor, and see if that makes a difference?
Same problem. Here is a minimal snippet (EPSG:3996) reproducing it:
final topLeft = LatLng(74.60299799700462, -170.9997690385578);
final bottomRight = LatLng(77.77365255354441, 91.91349368273093);
final bounds = LatLngBounds(topLeft, bottomRight);
final projBounds1 = Bounds<num>(
map.project(bounds.northWest) - map.pixelOrigin,
map.project(bounds.southEast) - map.pixelOrigin,
);
final projBounds2 = Bounds<num>(
map.project(topLeft) - map.pixelOrigin,
map.project(bottomRight) - map.pixelOrigin,
);
final bounds2 = LatLngBounds.fromPoints([topLeft, bottomRight]);
final projBounds3 = Bounds<num>(
map.project(bounds2.northWest) - map.pixelOrigin,
map.project(bounds2.southEast) - map.pixelOrigin,
);
print('projBounds1 (current):');
print('topLeft: ${projBounds1.topLeft}');
print('bottomRight: ${projBounds1.bottomRight}');
print('topLeft: ${map.unproject(projBounds1.topLeft + map.pixelOrigin)}');
print('bottomRight: ${map.unproject(projBounds1.bottomRight + map.pixelOrigin)}');
print('projBounds2 (proposed):');
print('topLeft: ${projBounds2.topLeft}');
print('bottomRight: ${projBounds2.bottomRight}');
print('topLeft: ${map.unproject(projBounds2.topLeft + map.pixelOrigin)}');
print('bottomRight: ${map.unproject(projBounds2.bottomRight + map.pixelOrigin)}');
print('projBounds3 (LatLngBounds.fromPoints):');
print('topLeft: ${projBounds3.topLeft}');
print('bottomRight: ${projBounds3.bottomRight}');
print('topLeft: ${map.unproject(projBounds3.topLeft + map.pixelOrigin)}');
print('bottomRight: ${map.unproject(projBounds3.bottomRight + map.pixelOrigin)}');
This returns:
[ ] flutter: projBounds1 (current):
[ ] flutter: topLeft: CustomPoint (588.0229903084105, -381.9199091615926)
[ ] flutter: bottomRight: CustomPoint (1781.8419762539538, 414.2663707511856)
[ ] flutter: topLeft: LatLng(latitude:77.773653, longitude:-170.999769)
[ ] flutter: bottomRight: LatLng(latitude:74.602998, longitude:91.913494)
[ ] flutter: projBounds2 (proposed):
[ ] flutter: topLeft: CustomPoint (553.5052798486024, -599.8504701739987)
[ ] flutter: bottomRight: CustomPoint (1561.317779848603, 421.633904826002)
[ ] flutter: topLeft: LatLng(latitude:74.602998, longitude:-170.999769)
[ ] flutter: bottomRight: LatLng(latitude:77.773653, longitude:91.913494)
[ ] flutter: projBounds3 (LatLngBounds.fromPoints):
[ ] flutter: topLeft: CustomPoint (588.0229903084105, -381.9199091615926)
[ ] flutter: bottomRight: CustomPoint (1781.8419762539538, 414.2663707511856)
[ ] flutter: topLeft: LatLng(latitude:77.773653, longitude:-170.999769)
[ ] flutter: bottomRight: LatLng(latitude:74.602998, longitude:91.913494)
It seems some corner coordinates are swapped around in the assumption that topLeft
is southWest
and bottomRight
is northEast
.
(preventing staleness from setting in)
Thanks, we'll have a look at this when we get a moment.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
What is the bug?
I have discovered a couple of edge cases where having a bounding box:
... in addition to the bounding box I added to support polar projections:
... will create a bounding box of incorrect size / incorrect position. Not way off, but noticeably.
What is the expected behaviour?
Image positioning issues should not occur.
How can we reproduce this issue?
Do you have a potential solution?
In my fork I solved this by changing
bounds
to aList<LatLng>
. This would be a breaking API change. Should I make a PR for3.0.0
?Can you provide any other information?
No response
Platforms Affected
MacOS
Severity
Obtrusive: Prevents normal functioning but causes no errors in the console
Frequency
Consistently: Always occurs at the same time and location
Requirements
flutter doctor
finds no relevant issues