This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Android beta 6 : LatLngBounds.Builder() #11629
Comments
cc @osana |
Here is a code snippet that I tried and it works as expected:
I tried rotating the map and doing and diagonal was drawn from northEast to souWest corners. Could you provide us with a code snippet of what is not working. Thank you. cc @tobrun |
You can try this code : PolygonOptions opts = new PolygonOptions()
.add(new LatLng(50.63018102643986, 3.0535175809382062))
.add(new LatLng(50.63073906475279, 3.0535175809382062))
.add(new LatLng(50.63073906475279, 3.054754028380558))
.add(new LatLng(50.63018102643986, 3.054754028380558))
.add(new LatLng(50.63018102643986, 3.0535175809382062))
.fillColor(Color.GREEN)
.alpha(0.4f);
mapboxMap.addPolygon(opts);
LatLngBounds llb = new LatLngBounds.Builder()
.include(new LatLng(50.63018102643986, 3.0535175809382062))
.include(new LatLng(50.63073906475279, 3.0535175809382062))
.include(new LatLng(50.63073906475279, 3.054754028380558))
.include(new LatLng(50.63018102643986, 3.054754028380558))
.include(new LatLng(50.63018102643986, 3.0535175809382062))
.build();
PolylineOptions plopts = new PolylineOptions()
.add(llb.getSouthWest())
.add(llb.getNorthEast())
.color(Color.RED);
mapboxMap.addPolyline(plopts);
mapboxMap.setCameraPosition(new CameraPosition.Builder().target(new LatLng(50.63018102643986, 3.0535175809382062)).zoom(18).build()); If you want funny behaviour, replace the last line with : mapboxMap.setCameraPosition(new CameraPosition.Builder().target(llb.getCenter()).build()); |
The bug is when the first two points have the same longitude. Fails when points are passed to the Builder in the order like: I will add unit tests with first two points having the same longitude and another test with first two points having the same latitude. cc @tobrun |
This was referenced Apr 10, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Platform: Android
Mapbox SDK version: 6.0.0-beta.6
Steps to trigger behaviour
Expected behavior
The line should be a diagonale of the original rectangle.
Actual behavior
The line seems to be the left edge of the original rectangle
Exemple :
Original polygon :
Computed bounds :
Note : I have no issue with non-rectangle polygon
It works on Android 5.5.0. The problem seems to come from : e4a40fe#diff-24a1903a5def25e6a975df6b3ea38b40
The text was updated successfully, but these errors were encountered: