Composants et solutions de cartographie (mapping)
Durée estimée: 15 minutes
App Inventor lets us go mobile AND enables to build “location aware” Apps which can display and interact with our spatial environment : build games like Pokemon Go or services like pizza delivery management or manage a fleet of vehicles like Uber.
These apps will generally require 3 kinds of services :
- Mapping (with Open streetMap, google Maps or other services),
- Geolocation, indoors or outdoors with GPS, network, SSID, IP, …
- Data sharing on the web with structured databases (cars, customers, pokemons, …)
This tutorial, deals with the first subject : mapping
(we look at other ones in other tutorials : see the Geolocation and database tutorials).
App Inventor offers many different ways to do mapping with very different capabilities. We will see 4 of them :
- Mapping with a "web viewer" component and Open street Map or Google maps services,
- Mapping with the "Start Activity" component and the Google maps App,
- Mapping with a "Web viewer" component and "fusion tables" to share, display and manage data on the web,
- Mapping with a "Canvas" component with the "static maps" and "streetview"APIs.
These four techniques enable VERY different App capabilities :
- Mapping with a Webviewer and WebMap Services is quick and simple.
It provides good Map display with dynamic web interaction, but has poor capabilities to incorporate user’s data and does not allow feedback from the map back to the App.
- Mapping with the Start Activity has similar capabilities and limitations.
It offers more display options, and has a well-documented API (Application Programming Interface). However, your own App disappears while the map display activity runs (and comes back when you quit display). Besides, this solution is strongly connected to the android "Activity life cycle" which is too hard to explain here, so that you may use concepts which you may not understand.
Above solutions are fine if your requirement is to use map display for interactive output only (directions, locations, …) with limited user data. This is often the case, and you will find nice and popular Apps in the gallery, such as “find my car” that use these techniques.
Solutions below enable two-way interactions between maps and App data. These interactions are key for games where you take “action” in the map (like Pokemons) or for business App that interact with fleets of vehicles (like UBER or pizza deliveries).
- Mapping with fusion tables and a webviewer :
The choice here is to use cloud services (fusion tables) to manage data AND maps. Fusion tables enable management and Cloud sharing of data for multiple players. This goes with powerful query capabilities (SQL like), that are necessary to handle interconnected data. Fusion tables also have mapping capability. This solution is fit to run small databases (ex : customers, orders, fleet of vehicles, deliveries, …).
Note here that Mapping AND data management are subcontracted to cloud services. They will STILL be handled by YOU, but outside App Inventor .
- Mapping with a Canvas and static APIs :
the choice here is to keep full control inside the App, and manage all interactions with the canvas component. In this case, maps are handled as image files. Interactions are unlimited but you have to write code for each interaction : this powerful solution comes naked. We will provide reusable code to help (ex : translate pixel coordinates to geographic coordinates, measure distances in km, zoom, pan, etc.) but there is still more work to do than with solutions 1 and 2. This solution is fit for Pokemon like games, or when you need two-way interactions between App and map.
Solution 4 has very nice extensions such as streetview, for walking in the streets and inside buildings. This can be great for “treasure finding” games (but requires some good maths).