This tutorial shows how you can develop an app that allows you to record list of addresspita and view the address on the Google Maps. It will juga show you how view your current location on the Google Map. This tutorial assumes you have completed the basic tutorials of App Inventor. For basic and intermediate tutorials, click here.

Anda sedang menonton: Cara membuat peta lokasi di google maps

Introduction

This tutorial introduces:

List manipulation – creatingai lists, appendingi items to listsListPicker – adding items to lists, savingai list dataLocationsensor – detectinew york current location for displayingai on Google MapsActivityStarter – used to start-up Google Maps for current or predefined addressNotifier – displaying messagesTinyDB – saving data into a persistent databaseMisc. – text manipulation, basic validation

We will be worraja toward the design shown in figure blow:

*

The ilustrasi below shows how the components are arranged in the degejala editor. It juga shows you the non-visible components (e.g. TinyDb, ActivityStarter, LocationSensor, Notifier) that are digunakan in the app.

*

Blocks

We define 2 global variables.

tagAddress – a variable that is a constant and will be used, as a tag, for storingi and retrievingai data from our database.listLocations – a variable that can be tangan kedua to store and manipulate list of addresses.

We now membuat a procedure that can be invoked when the app is started (initialized). The procedure sets up the initial state of some of the components. Some of these settings bisa have been done from the detanda tangan editor, but for demo pursikap and clarification, we are usingi a procedure. In the procedure, we also ciblis our database to find out if tdi sini are any stored addresses. If no data, then we just use an empty list.

*

Addingi a New Addresses

We use AddLocationButton to add a new address, CancelButnada to cancel the process of adding, and LocationHelpButselang to disbermain what type of addresspita pengukur can be entered. The blocks to make these tindakan work are here:

*

When AddLocationButton is clicked, we mausai our address data entry visible (usingai screen arrangement), allowingai user to enter address. If user clicks on Cancel, we make the arrangement tersembunyi again. Usingai this approach, we keep the screen simple and avoid the clutter. We also provide the Subchannelishop.comButton to allow the user to indikate that they want to store data.

When the user clicks on Subchannelishop.comButton, we perform basic validation to ensure data has been subchannelishop.comted. If validation melakukan not pass, we disbermain an error message. Otherwise, we invoke a procedure that appends the new address to our list. We juga store the updated list into our database. Once address is added, we hideas our arrangeobat-obatan again. The blocks below show how this logic is done:

*

Selectinew york an Addresses

When the user clicks on ListPicker1 ‘Select Location’ and selects an address, this pergerakan calls the blocks below:

*

This displays the address in the device and allow the user to tap on ViewOnMapButton to see the blocks selected address on the Google Map — see the figure below:

*

When ViewOnMapButton is clicked, we validate to ensure that an address already has been selected. If not, an error message is displayed. Otherwise, we use blocks below to show address:

*

The above blocks will open the map and the output will be like image below:

*

Viewingi Current Location On the Map

We have dropped in a button, MyLocationButnada ‘My location On the Map’ that can be clicked to view one"s current location. It will use

*

Download Source Code

If you"d lisetelah to work with this sample in App Inventor, download the source code to your computer, then open App Inventor, click Projects, choose Import project (.aia) from my computer...

Lihat lainnya: Cara Mengatasi Hidung Tersumbat Dengan Cepat, 5 Penyebab Hidung Tersumbat Dan Cara Mengatasinya

, and select the source code you just downloaded.

channelishop.com App Inventor expresspita its gratitude to M. Hossein Amerkashi for developingi this tutorial. Visit Hossein"s blog to find out more about him and his App Inventor support materials.