Maptype not working with Map component (and an alternative using Google Static Map)

Only Map1.Maptype=1 works for me.

Map1.Maptype=2 or 3 produce empty map with squares

Is this normal?

Working OK here.

Test with the default coordinates that load when you add the map component.
Could be a slow internet connection ?

If you are using different coordinates it is possible that 2, 3 are not available for you location?

Tim identified the probable issue. The Aerial and Terrain are not usually available for higher value Map tiles when using OSM. Try changing the Map type while using a zoom of 10. What happens? If you are zooming at 18 or so, you will not have 2 or 3 available.

Unlike GoogleMaps map tiles; OSM (the map engine the Map component uses) does not provide images other than Roads for all zoom levels.

Regards,
Steve

1 Like

Thank you all.
I am making more tests and sometimes i have problems also with MapType=1… when zooming back a lot the screen refresh freezes… and it stays frozen.
So what’s the way to use Map1. If it works in this way it means it doesn’t work :smiley:
Nobody ever complained before me :slight_smile: ?

The Map component uses OpenStreetMap tile servers. The OSM servers do not have unlimited capacity. Their use is load limited. If there are many users, sometimes changes to your Map during periods of high server load take longer to render. Response also depends on your device
WIFI or network connection. Whether you have a slow network or WIFI affects ability to render tiles since the map tiles are in the Cloud, not on your device.

So when you 'when zooming back a lot the screen refresh freezes… and it stays frozen."... just do not do that. Make your zoom changes slowly.

OSM works exactly as designed; if you want faster response, use Google's Google Map Static Map. Static Map uses Google's servers which are significantly faster and responsive compared to the 'donated' servers used by OSM.

"Nobody ever complained before me" ... this behavior is a known issue with the way OSM works...MIT App Inventor 2 has no control over OSM's servers. The Map component merely provides a link to OSM.

To learn about how OSM tiles 'work' and especially about high usage.

very clear! thanks
last question can AI2 use Static Map?

Yes, AI2 can use a Static Map.

Points to be aware of:

  • since late 2018, Google requires users obtain an api key. They allow a certain amount of ‘free’ usage

notFREE

  • Usage is fairly straight forward. Use a WebViewer and set it to an URL you construct with AI2 Blocks. It can be used with a LocationSensor. Here is a non AI2 example. To get the map to render, you MUST add your api key. (Once upon a time, the key was not required. It is required now.) If you key in the URL without the api key filled in, you shall get an error message.

The following blocks are a partial port of Google’s example to AI2 Blocks

It will produce a map like:

staticMapImage

Here is an example of a StaticMap using the LocationSensor and centered on the device’s geocoordinates

staticMap

These examples should get you started.

  • A simpler way to use Google Map tiles might be to use the third party, commercial Block clone called Thunkable. That compiler has a Map component based on Google Map tiles. It might do what you want.

  • There are many StaticMap examples in the old AI2 Forum which although deactivated, can still be searched using terms like static map. Here is a tutorial

.

Have fun experimenting.

Regards,
Steve

1 Like

your tips are so helpful!
thanks and compliments

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.