How can I get zoom levels to decode a polyline from Google Maps Directions API?

三世轮回 提交于 2019-12-12 01:23:39

问题


Following this polyline decoder class from @Kenny:

int[] decodedZoomLevels = PolylineDecoder.decodeZoomLevels(levels);
GeoPoint[] gPts = PolylineDecoder.decodePoints(points, decodedZoomLevels.length);

I'm trying to draw the route from Barcelona to Madrid with Google Maps Directions API:

<DirectionsResponse>
  <status>OK</status>
  <route>
    <leg>
      ...
    </leg>
    <copyrights>Datos de mapa ©2012 Google, Tele Atlas</copyrights>
    <overview_polyline>
      <points>
        cjr{F_u(...)rw@bD~]ln@xo@fnB`M|iAxEvV
      </points>
    </overview_polyline>
  <route>
<DirectionsResponse>

I manage to read the XML response and get \DirectionsResponse\route\overview_polyline\points polyline string; but I cannot find the <levels> tag.

I'm trying to draw smoother line (route) when the users zooms in but freeing smartphone's CPU when the zoom is out.

Am I using wrong API? Or this class is outdated?

Thanks in advance...


回答1:


ZoomLevel is econded inside the polyline "string". In the Kenny's class just give as 2nd parameter to "decodePoints" method the size of the polyline string.

Look at the bottom of this 1 and I wonder you will understand more.



来源:https://stackoverflow.com/questions/9653483/how-can-i-get-zoom-levels-to-decode-a-polyline-from-google-maps-directions-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!