8

What are "levels" in polyline encoding/decoding, and exactly how do they relate to map zoom levels in Google Maps API v3 or Android Maps API v2?

The only description I can find is from the Interactive Polyline Encoder Utility:

Polylines in Google Maps are formed as a set of latitude/longitude pairs. In addition, for each vertex (location) in an encoded polyline, a level can be specified indicating that the location should appear on that level and any level higher (i.e. any decrease in zoom.). If a location does not appear on a given level, then the line will go from the last visible location to the next visible location. Note that the first and last locations must be Level 3 points, otherwise the polyline won't display on all levels.

Does "Level 3" correspond to a zoom level of 3 in the Google Maps API v3 or Android Maps API v2?

Here's what a zoom level of 3 looks like in the Google Maps API v3 (no polyline is displayed - this is simply to illustrate what the "zoom level = 3" looks like):

enter image description here

Should a "Level 3" point be displayed if we zoom out one step further, to zoom Level 2?

enter image description here

The quote:

Note that the first and last locations must be Level 3 points, otherwise the polyline won't display on all levels.

...seems to indicate that Level 3 points should be displayed on all levels, including zoom levels 2, 1, and 0.

I'm wondering if the statement:

...a level can be specified indicating that the location should appear on that level and any level higher (i.e. any decrease in zoom.)

...should actually be:

...a level can be specified indicating that the location should appear on that level and any level higher (i.e. any increase in zoom.)

"decrease in zoom" doesn't seem correct, because Level 18 (very zoomed in) points would be rendered on Level 3 (very zoomed out).

"increase in zoom" seems to generally make sense (you'd render a Level 3 zoomed out point also when you zoom in to Level 18 - in other words, you add detail as you zoom in closer to the map) - however, it seems to contradict the statement that Level 3 points should be rendered at lower zoom levels 2, 1, and 0.

On Android, the open-source android-maps-utils library includes a method to decode polylines, but it doesn't handle levels, so I can't tell if there is a readily-available mapping to Android Maps API v2 zoom levels.

Can anyone provide clarity on this?

Sean Barbeau
  • 11,496
  • 8
  • 58
  • 111
  • 1
    I wonder where did you write the "encoded polyline" in your code. I can't see the code at all. – wf9a5m75 Mar 17 '16 at 16:40
  • @wf9a5m75 There isn't any encoded polyine in the Javascript code or displayed on the map - I was using these screenshtos simply to illustrate what a particular zoom level looks like on Google Maps. Sorry if that wasn't clear - I'll add a note in the question about this. – Sean Barbeau Mar 17 '16 at 17:53

2 Answers2

0

Levels are an obsolete feature. They controlled whether points were visible at certain zoom levels. They were a significant feature of Google Maps API v2, but you should ignore them now; Google Maps API v3 does it automatically.

Aidan Stanger
  • 127
  • 1
  • 6
0

zoom level defines the resolution of the current view.

zoom level

  • 0: to encompass the entire earth
  • 1: World
  • 5: Landmass/continent
  • 10:City
  • 15: Streets
  • 20: Buildings

"zoom=12" isused in below exapmle

https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&key=YOUR_API_KEY&signature=YOUR_SIGNATURE