Maps: Zoom level conflict

Hi all, I stumbled over the following issue
If I put a Map in screen1, and give it say zoom level 12 in the designer settings, and then go to blocks, and initialize screen1 telling the Map to pan to certain Lon and Lat, I need to set zoom level 12 in that statement as well. If I pick a different zoom level than the one stated in the designer page, the map will pan to a different place.
So, a non identical zoom level in those two statements will result in a non-correct pan location.

Note that I tested this with Companion only.


Perhaps test as an apk
and provide a small test aia to see your code and confirm the issue? A graphic showing this behavior ( the map will pan to a different place. ) would be helpful. Thanks.

If this is what's happening it may be due to differences in the Map tiles (see ZoomLevel below). Note that often with App Inventor control settings it is best to set values with Blocks which seem to supersede the Designer set value.

Also of note is Map.PanTo is glitchy, often failing to pan correctly. Using Pan often results in a pixelated map rendering. I find it is often 'better' and more stable to pan and center the map using CenterFromString

Set the initial center coordinate of the map. The value is specified as a comma-separated pair of decimal latitude and longitude coordinates, for example, 42.359144, -71.093612.

Experience shows that this statement is not entirely correct: In blocks code, it is recommended for performance reasons to use PanTo with numerical latitude and longitude rather than convert to the string representation for use with this property. I take exception to the words 'it is recommended' as CenterFromString is more STABLE.

Follow the CenterFromString with ZoomLevel Block and the combination works better than Pan nine times out of ten. :astonished:

ZoomLevel specifies the zoom level of the map. Valid values of ZoomLevel are dependent on the tile provider and the latitude and longitude of the map. For example, zoom levels are more constrained over oceans than dense city centers to conserve space for storing tiles, so valid values may be 1-7 over ocean and 1-20 over cities. Tile providers may send warning or error tiles if the zoom level is too great for the server to support.

1 Like

i also faced the issue, but try numbers between 10-20 and set which suits you.

I use Map.PanTo every second in another app, and never ever saw a single glitch.
And in that app I didn't stumble over the issue I describe above since I state the zoom level in blocks during initiation, before I use PanTo to center the map.
I made a tiny test app, just use Companion and in Designer mode change the zoom level.
All works as expected. Then go to Blocks and remove the block that sets zoom level.
Return to Designer mode and experiment with different zoom settings. You will notice that only two identical zoom levels (in designer and blocks) will have the map pan do the right point where the marker is.

BuhlertBunkers.aia (1.7 KB)

Just what do you expect a tester to notice? I see expected behavior based on the zoom level and appropriate map tile. What do you see that I do not? How do you establish the "right point where the marker is"?

You set the precision of your latitude and longitude to 15 decimal places.

How precise do you expect each OpenStreetMap tile to be?


What your example shows whilst changing zoom. This is what I expect to see.

Lucky you. It may be you are connected to a different OSM server and or have faster DSL. OSM uses multiple map tile servers.

Well, you didn't take out the Set Map Zoomlevel to 12 in Blocks as I suggested.
If you take that out, you will see the issue because In Designer I set the zoomlevel at 11, not 12.

Just use my example aia and delete the block that defines zoom level.
So the only zoom statement in Blocks is in the PanTo command.
If Map zoom level in Designer is different than the zoom statement in PanTo, you will notice that the map will center on an entirely different place.
So, by only changing the zoom number in the Map Properties in Designer mode you can get the Map to correctly focus on somehere in Germany (with equal zoom setting) or somewhere in France or Luxemburg (with unequal zoom setting) .
That has nothing to do with accuracy. It's a bug.
Only if I re-define zoom level in Blocks before I give the PanTo command the issue doesn't occur.
Thank you.

Hi Steve,
Did you manage to reproduce the issue?
It's not a big thing since there's a workaround, but if it really is a bug it would be worth knowing, I guess.
Thank you,

My theory is that this is due to a potential interaction between the initial view setup and the fact that you are calling PanTo in Screen1.Initialize. The panning animation has a duration of 500ms, so if there is an interaction you would see it due to the quick succession of panning calls but if you're using a clock timer once per second then you wouldn't. You could test this if you set the clock time to something like 250ms or less to see if you get similar glitches.

I think your're right.
In below aia I have a clock running at 100msec intervals controlling the PAN action.
At start the map shows a spot in France and in 100msec intervals the map centre slowly moves to the specified spot in Germany.
That's the case using Companion as well as in the compiled app.
And picking similar or different zoom levels in Designer mode and Blocks don't seem to matter.
No big issue I suppose, but I was intrigued by this unexpected behavior.
Thanks for your reply, and a big thank you to all people that created and maintain this incredibly useful and versatile AI2 !


BuhlertBunkersB.aia (1.6 KB)

1 Like