hello googlemaps!

29
Hello GoogleMaps! Roc Boronat

Upload: roc-boronat

Post on 15-May-2015

4.008 views

Category:

Technology


3 download

DESCRIPTION

Overviewing Google Maps service and how to start your Google Maps based Android application.

TRANSCRIPT

Page 1: Hello GoogleMaps!

Hello GoogleMaps!Roc Boronat

Page 2: Hello GoogleMaps!

Overview

What's a Google Map?

About MapActivity

Build your own MapActivity

Codesprint!

Page 3: Hello GoogleMaps!

Google«…apples, penguins, windows... and Google»

Page 4: Hello GoogleMaps!

#CatDroid

What's Google Maps?

Google Maps (formerly Google Local) is a web mapping service application and technology provided by Google, free (for non-commercial use), that powers many map-based services, including the Google Maps website, Google Ride Finder, Google Transit,[1] and maps embedded on third-party websites via the Google Maps API.[2] It offers street maps, a route planner for traveling by foot, car, or public transport and an urban business locator for numerous countries around the world. Google Maps satellite images are not in real time; they are several years old.[3]

http://en.wikipedia.org/wiki/Google_Maps

Page 5: Hello GoogleMaps!

#CatDroid

What's Google Maps?

Google Maps (formerly Google Local) is a web mapping service application and technology provided by Google, free (for non-commercial use), that powers many map-based services, including the Google Maps website, Google Ride Finder, Google Transit,[1] and maps embedded on third-party websites via the Google Maps API.[2] It offers street maps, a route planner for traveling by foot, car, or public transport and an urban business locator for numerous countries around the world. Google Maps satellite images are not in real time; they are several years old.[3]

I la ISO, què?What about the ISO?

http://en.wikipedia.org/wiki/Google_Maps

Page 6: Hello GoogleMaps!

#CatDroid

What's Google Maps?

Google Maps (formerly Google Local) is a web mapping service application and technology provided by Google, free (for non-commercial use), that powers many map-based services, including the Google Maps website, Google Ride Finder, Google Transit,[1] and maps embedded on third-party websites via the Google Maps API.[2] It offers street maps, a route planner for traveling by foot, car, or public transport and an urban business locator for numerous countries around the world. Google Maps satellite images are not in real time; they are several years old.[3]

http://en.wikipedia.org/wiki/ISO/IEC_9126http://openiconlibrary.sourceforge.net/gallery2/?./Icons/status

Functionality Suitability Accuracy Interoperability Security

Reliability Maturity Fault Tolerance Recoverability

Usability Understandability Learnability Operability Attractiveness

Efficiency Time Behaviour Resource Utilisation

Maintainability Analyzability Changeability Stability Testability

Portability Adaptability Installability Co-Existence Replaceability

I la ISO, què?What about the ISO?

* Analising from the user point of view,'cause we cannot analise the source code.

Page 7: Hello GoogleMaps!

#CatDroid

What can we do with Google Maps?

Page 8: Hello GoogleMaps!

#CatDroid

Facts...http://kcy.me/1vdf

http://www.bing.com ergo http://google.com

Page 9: Hello GoogleMaps!

#CatDroid

Android is an Open Source project?

http://en.wikipedia.org/wiki/Android_%28operating_system%29#Licensing

Android is a mobile operating system initially developed by Android Inc. Android was bought by Google in 2005.[5] Android is based upon a modified version of the Linux kernel. Google and other members of the Open Handset Alliance collaborated on Android's development and release.[6][7] The Android Open Source Project (AOSP) is tasked with the maintenance and further development of Android.[8]

With the exception of brief update periods, Android has been available under a free software / open source license since 21 October 2008. Google published the entire source code (including network and telephony stacks)[33] under an Apache License.[34] Google also keeps the reviewed issues list publicly open for anyone to see and comment.[35]

Page 10: Hello GoogleMaps!

#CatDroid

Google Maps is an Android module?

http://source.android.com/faqs.html

The Google apps for Android, such as YouTube, Google Maps and Navigation, Gmail, and so on are Google properties that are not part of Android, and are licensed separately. Contact [email protected] for inquiries related to those apps.

Page 11: Hello GoogleMaps!

#CatDroid

… so?

Google APIs Add-On is an extension to the Android SDK development environment that lets you develop applications for devices that include Google's set of custom applications, libraries, and services. A central feature of the add-on is the Maps external library, which lets you add powerful mapping capabilities to your Android application.

The add-on also provides a compatible Android system image that runs in the Android Emulator, which lets you debug, profile, and test your application before publishing it to users. The system image includes the the Maps library and other custom system components that your applications may need, to access Google services (such as Android C2DM). The add-on does not include any custom Google applications. When you are ready to publish your application, you can deploy it to any Android-powered device that runs a compatible version of the Android platform and that also includes the custom Google components, libraries, and services.

http://code.google.com/intl/en-EN/android/add-ons/google-apis/

Page 12: Hello GoogleMaps!

#CatDroid

Free alternatives

http://www.openstreetmap.org/

OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world.

The maps are created using data from portable GPS devices, aerial photography, other free sources or simply from local knowledge. Both rendered images and the vector graphics are available for download under a Creative Commons Attribution-ShareAlike 2.0 licence.[3]

http://en.wikipedia.org/wiki/OpenStreetMap

Steve Coast, 2009

Page 13: Hello GoogleMaps!

Hello MapView!ASL?

Page 14: Hello GoogleMaps!

#CatDroid

Steps1. Obtaining a Maps API key

2. Adding the lib and the permission to your Manifest

3. Displaying the map

4. Displaying the Zoom View

Page 15: Hello GoogleMaps!

#CatDroid

Obtaining a Maps API keyBeginning with the Android SDK, you need to apply for a free Google Maps API key before you can integrate Google Maps into your Android application. To apply for a key, you need to follow the series of steps outlined below. You can also refer to Google's detailed documentation on the process at http://code.google.com/android/toolbox/apis/mapkey.html.

First, if you are testing the application on the Android emulator, locate the SDK debug certificate located in the default folder of "C:\Documents and Settings\<username>\Local Settings\Application Data\Android". The filename of the debug keystore is debug.keystore. For deploying to a real Android device, substitute the debug.keystore file with your own keystore file.For simplicity, copy this file (debug.keystore) to a folder in C:\ (for example, create a folder called "C:\Android").

http://developer.android.com/resources/tutorials/views/hello-mapview.html

Page 16: Hello GoogleMaps!

#CatDroid

Obtaining a Maps API key

Simplified translation:

Find “debug.keystore” file inside your “Documents and Settings” path.

http://developer.android.com/resources/tutorials/views/hello-mapview.html

Page 17: Hello GoogleMaps!

#CatDroid

Obtaining a Maps API key

Using the debug keystore, you need to extract its MD5 fingerprint using the Keytool.exe application included with your JDK installation. This fingerprint is needed to apply for the free Google Maps key. You can usually find the Keytool.exe from the "C:\Program Files\Java\<JDK_version_number>\bin" folder.

http://developer.android.com/resources/tutorials/views/hello-mapview.html

Page 18: Hello GoogleMaps!

#CatDroid

Obtaining a Maps API key

Simplified translation:

Find “Keytool.exe” file inside your JRE/JDK path, probably placed at “Program Files”.

http://developer.android.com/resources/tutorials/views/hello-mapview.html

Page 19: Hello GoogleMaps!

#CatDroid

Obtaining a Maps API key

Call the following command to extract the MD5 fingerprint.

keytool.exe -list -alias androiddebugkey -keystore "C:\android\debug.keystore"-storepass android -keypass android

http://mobiforge.com/developing/story/using-google-maps-android

Page 20: Hello GoogleMaps!

#CatDroid

Obtaining a Maps API key

Copy the MD5 certificate fingerprint and navigate your web browser to:

http://code.google.com/android/maps-api-signup.html

Follow the instructions on the page to complete the application and obtain the Google Maps key.

http://mobiforge.com/developing/story/using-google-maps-android

Page 21: Hello GoogleMaps!

#CatDroid

Editing AndroidManifest.xml

To use the Google Maps in your Android application, you need to modify your AndroidManifest.xml file by adding the <uses-library> element together with the INTERNET permission:

<…> <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-library android:name="com.google.android.maps" /> <activity android:name=".MapsActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.INTERNET" /></...>

http://mobiforge.com/developing/story/using-google-maps-android

Page 22: Hello GoogleMaps!

#CatDroid

Displaying the MapTo display the Google Maps in your Android application, modify the main.xml file located in the res/layout folder. You shall use the <com.google.android.maps.MapView> element to display the Google Maps in your activity. In addition, let's use the <RelativeLayout> element to position the map within the activity:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.google.android.maps.MapView android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="0l4sCTTyRmXTNo7k8DREHvEaLar2UmHGwnhZVHQ" /> </RelativeLayout>

http://mobiforge.com/developing/story/using-google-maps-android

Page 23: Hello GoogleMaps!

#CatDroid

Displaying the MapIn the MapsActivity.java file, modify the class to extend from the MapActivity class, instead of the normal Activity class:

package net.learn2develop.GoogleMaps;

import com.google.android.maps.MapActivity;import com.google.android.maps.MapView;import android.os.Bundle; public class MapsActivity extends MapActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override protected boolean isRouteDisplayed() { return false; }}

http://mobiforge.com/developing/story/using-google-maps-android

Page 24: Hello GoogleMaps!

#CatDroid

Displaying the Zoom ViewFirst, add a <LinearLayout> element to the main.xml file as shown below:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.google.android.maps.MapView android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="0l4sCTTyRmXTNo7k8DREHvEaLar2UmHGwnhZVHQ" /> <LinearLayout android:id="@+id/zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /> </RelativeLayout>

http://mobiforge.com/developing/story/using-google-maps-android

Page 25: Hello GoogleMaps!

#CatDroid

Displaying the Zoom ViewIn the MapsActivity.java file, add the following imports:

import com.google.android.maps.MapView.LayoutParams; import android.view.View;import android.widget.LinearLayout

...and add the following code after the line setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapView); LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom); View zoomView = mapView.getZoomControls(); zoomLayout.addView(zoomView, new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); mapView.displayZoomControls(true);

http://mobiforge.com/developing/story/using-google-maps-android

Page 26: Hello GoogleMaps!

#CatDroid

Displaying the Zoom ViewAlternatively, you can also programmatically zoom in or out of the map using the zoomIn() and zoomOut() methods from the MapController class:

public class MapsActivity extends MapActivity { MapView mapView; public boolean onKeyDown(int keyCode, KeyEvent event) { MapController mc = mapView.getController(); switch (keyCode) { case KeyEvent.KEYCODE_3: mc.zoomIn(); break; case KeyEvent.KEYCODE_1: mc.zoomOut(); break; } return super.onKeyDown(keyCode, event); }

// … the rest of the class

http://mobiforge.com/developing/story/using-google-maps-android

Page 27: Hello GoogleMaps!

#CatDroid

More info:Great post where I found the data that I've pasted here:http://mobiforge.com/developing/story/using-google-maps-android

- Changing Views of the Map- Displaying a Particular Location- Adding Markers- Getting the Location that was touched- Geocoding and Reverse Geocoding

Wei-Meng Lee is a technologist and the founder of Developer Learning Solutions (http://www.learn2develop.net), a company focusing on hands-

on training on the latest technology. Wei-Meng specializes in mobile technologies and has written several books on .NET, VB, C#, and .NET

Compact Framework and is currently working on an Android book for Wrox. Contact Wei-Meng Lee at [email protected].

Page 28: Hello GoogleMaps!

#CatDroid

More info:

The official pseudo-comprehensive post about adding overlay items:http://developer.android.com/resources/tutorials/views/hello-mapview.html

You can also try asking at http://groups.google.com/group/CatDroidThe most handsome men use to cooperate with that open community. And they also have lots of ziritione.

And at last point, if you need a MWC pass, try asking at this community:http://groups.google.com/group/barcelona-gtug

Page 29: Hello GoogleMaps!

Thanks for your attention!

[email protected]

catdroid.orghttp://groups.google.com/group/CatDroid

… and patience!