4

I need to display a polyline and want to center the map on this polyline. How to zoom to a specific square consisting of two latitudes and two longitudes in Skobbler maps?

Mohamed Taher Alrefaie
  • 15,698
  • 9
  • 48
  • 66

1 Answers1

3

Create an SKBoundingBox from the 2 coordinates and then "fit" the visible screen to that bounding box via fitBoundingBox

Ando
  • 11,199
  • 2
  • 30
  • 46
  • good answer. but is there a way to center it around a polyline immediately without calculating the 2 coordinates? – Mohamed Taher Alrefaie Aug 19 '14 at 12:57
  • Don't think so - you can zoom to a bounding box, to a track or to a route – Ando Aug 19 '14 at 13:19
  • @Ando what happen if i have 3 different coordinates or more, I've been trying to create a SKBoundingBox with more than 2 coordinates and it's been imposible. I think the correct way to calculate a boundingBox with more than 2 coordinates is extrapolating the coordinates to envelope all coordinates on a list. What do you think? – AXSM Nov 27 '14 at 16:39
  • @AlexSanchez from your three (or more points) establish the most western/eastern longitude and the northern/southern latitude and those will be your four bounding box coordinates. – Ando Dec 02 '14 at 07:49
  • yeah, that's what i did @Ando, i take all points and search for most west/east longitude and north/south latitude and then combine them to find the bounding coordinates. But now a new question arise. What happen when you have some points fitted on the boundingbox but the route in between some of then is out of the bounding box, how i include those route into my BoundingBox? – AXSM Dec 03 '14 at 14:23
  • If you have a route then it's best that you use zoomToRoute() - http://developer.skobbler.com/docs/android/2.3.0/com/skobbler/ngx/routing/SKRouteManager.html#zoomToRoute(float, float, int, int, int, int) – Ando Dec 04 '14 at 07:42
  • @Ando Sorry to dig out this thread, but we are facing this exact situation. We are able to calculate the bounding boxes, etc. But, there are cases when a coordinate lies inside more than a single bounding box. For example (44.076104, 11.473820), this point falls under packages ITREG08 and ITREG18. How to decide which package to download ? – anemo Oct 06 '16 at 15:56
  • That is up to you. If you think that you need additional packages create (following custom bounding boxes), contact the Telenav team at dev@telenav.com – Ando Oct 07 '16 at 07:56