I have a path they draw routes path on the mapview and I search the way for show the complete path with the best zoom level for the longer of the path.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you iterate through the points in your path and find the maximum longitudes and latitudes, (that is, the farthest points north, south, east, and west), you’ll have the bounding rectangle for your path (that is, the smallest rectangle that can contain your path).
From there, you can find the center of your rectangle. Get the MapController for your MapView (using MapView.getController()) and use MapController.setCenter() to set the map’s center to the center of the rectangle.
Finally, compute the latitude span and longitude span (the north-south size of your rectangle and the east-west size of your rectangle) and pass those into MapController.zoomToSpan().