SlideShare a Scribd company logo
Hello GoogleMaps!
Roc Boronat
Overview

What's a Google Map?


About MapActivity


Build your own MapActivity


Codesprint!
Google
«…apples, penguins, windows... and Google»
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
#CatDroid
I la ISO, què?
                                                       What about the ISO?



       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
#CatDroid
I la ISO, què?
                                                                              What about the ISO?



        What's Google Maps?

                            Functionality
                          (formerly Google Local) is a Efficiency
        Google Maps Suitability                         web mapping service
        application and technology provided by Google, Utilisation (for non-
                       Accuracy
                       Interoperability
                                                        Time Behaviour
                                                        Resource      free
        commercial use), that powers many map-based services, including the
                       Security

        Google Maps website, Google Ride Finder, Google Transit,[1] and maps
                                                       Maintainability
                     Reliability
        embedded on third-party websites via the Google Maps API.[2] It offers
                                                        Analyzability
                                                        Changeability
        street maps, Maturity
                        a route planner for traveling by foot, car, or public
                       Fault Tolerance
                                                        Stability
                                                        Testability
        transport and an urban business locator for numerous countries around
                       Recoverability


        the world. Google Maps satellite images are not in real time; they are
                                                       Portability
                     Usability
        several years old.[3]                           Adaptability
                              Understandability
                                                                              Installability
                              Learnability
                                                                              Co-Existence
                              Operability
                                                                              Replaceability
                              Attractiveness




                                                                     * Analising from the user point of view,
http://en.wikipedia.org/wiki/ISO/IEC_9126
                                                                  'cause we cannot analise the source code.
http://openiconlibrary.sourceforge.net/gallery2/?./Icons/status
#CatDroid
What can we do
with Google Maps?




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




http://www.bing.com ergo http://google.com
#CatDroid
Android is an Open Source project?
   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]


http://en.wikipedia.org/wiki/Android_%28operating_system%29#Licensing
#CatDroid
Google Maps is an Android module?

   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 android-partnerships@google.com for inquiries
   related to those apps.




http://source.android.com/faqs.html
#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/
#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      Steve Coast, 2009
   2.0 licence.[3]


http://en.wikipedia.org/wiki/OpenStreetMap
#CatDroid
Hello MapView!
ASL?
Steps
     1. Obtaining a Maps API key
     2. Adding the lib and the permission to your Manifest
     3. Displaying the map
     4. Displaying the Zoom View




#CatDroid
Obtaining a Maps API key
        Beginning 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 SettingsApplication DataAndroid". 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
#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
#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 FilesJava<JDK_version_number>bin" folder.




http://developer.android.com/resources/tutorials/views/hello-mapview.html
#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
#CatDroid
Obtaining a Maps API key
        Call the following command to extract the MD5 fingerprint.


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




http://mobiforge.com/developing/story/using-google-maps-android
#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
#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
#CatDroid
Displaying the Map
     To 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
#CatDroid
Displaying the Map
     In 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
#CatDroid
Displaying the Zoom View
     First, 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
#CatDroid
Displaying the Zoom View
     In 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
#CatDroid
Displaying the Zoom View
     Alternatively, 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
#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 weimenglee@learn2develop.net.




#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/CatDroid
   The 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




#CatDroid
Thanks for your attention!
… and patience!




           rocboronat.net                   catdroid.org
            roc@rocboronat.net   http://groups.google.com/group/CatDroid

More Related Content

PPTX
Study Abroad Presentation
PPTX
Google Apps
PPT
PPTX
Work abroad, Dream Global Consultants.
PPSX
Asking & giving directions
PPSX
Giving directions presentation_oseiasa_modelo
PPTX
Google map tutorials
PPTX
Google Location Services
Study Abroad Presentation
Google Apps
Work abroad, Dream Global Consultants.
Asking & giving directions
Giving directions presentation_oseiasa_modelo
Google map tutorials
Google Location Services

Similar to Hello GoogleMaps! (20)

PPT
Gmaps001
PDF
Comparative Study of Diverse API Perspective of Spatial Data
DOCX
Location Based Services Android Google Maps API with Examples
PDF
[English] Create Mobile LBS Application Using Maps API
PDF
Maps API on_mobile_dev_festbangkok
PDF
Mobile Maps On Labs
PPT
Google Geo APIs Overview
PDF
Intro to apps with maps for series 40
PPTX
The Ubiquitous Digital Map (Abridged) by Gary Gale
PDF
Intro To Google Maps
PPTX
Case study of goggle map
PPT
Post-PC: Geolocation & Maps in the Android Ecosystem
PPTX
Introducing Google Apps
PPTX
Google World - Hassan magdy
PDF
The User-participated Geospatial Web as Open Platform
KEY
State of the Map 2012 talk
PPTX
The Features and Use of Google Maps
PDF
ANDROID MAPPING APPLICATION
PPTX
What are the Uses & Benefits of Google Maps?
PDF
Building Mobile Cross-Platform Geospatial Apps, Nick Landry
Gmaps001
Comparative Study of Diverse API Perspective of Spatial Data
Location Based Services Android Google Maps API with Examples
[English] Create Mobile LBS Application Using Maps API
Maps API on_mobile_dev_festbangkok
Mobile Maps On Labs
Google Geo APIs Overview
Intro to apps with maps for series 40
The Ubiquitous Digital Map (Abridged) by Gary Gale
Intro To Google Maps
Case study of goggle map
Post-PC: Geolocation & Maps in the Android Ecosystem
Introducing Google Apps
Google World - Hassan magdy
The User-participated Geospatial Web as Open Platform
State of the Map 2012 talk
The Features and Use of Google Maps
ANDROID MAPPING APPLICATION
What are the Uses & Benefits of Google Maps?
Building Mobile Cross-Platform Geospatial Apps, Nick Landry
Ad

More from Roc Boronat (10)

PPTX
Introducing EDD: Error Driven Development
PDF
From CVS to GIT
PDF
Introducing Clean Architecture
PDF
Testing, CI and CD in the real world
PDF
Testing, CI and CD in the real world
PDF
The chromecast's guide to the galaxy
PDF
Sessió motivacional
PDF
QuitNow!
PDF
Hello NFC!
PDF
Barcelona Bicing: Next steps
Introducing EDD: Error Driven Development
From CVS to GIT
Introducing Clean Architecture
Testing, CI and CD in the real world
Testing, CI and CD in the real world
The chromecast's guide to the galaxy
Sessió motivacional
QuitNow!
Hello NFC!
Barcelona Bicing: Next steps
Ad

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
Teaching material agriculture food technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Building Integrated photovoltaic BIPV_UPV.pdf
Programs and apps: productivity, graphics, security and other tools
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Teaching material agriculture food technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction
Encapsulation_ Review paper, used for researhc scholars
Dropbox Q2 2025 Financial Results & Investor Presentation
20250228 LYD VKU AI Blended-Learning.pptx
MIND Revenue Release Quarter 2 2025 Press Release
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
sap open course for s4hana steps from ECC to s4
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

Hello GoogleMaps!

  • 2. Overview What's a Google Map? About MapActivity Build your own MapActivity Codesprint!
  • 4. 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 #CatDroid
  • 5. I la ISO, què? What about the ISO? 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 #CatDroid
  • 6. I la ISO, què? What about the ISO? What's Google Maps? Functionality (formerly Google Local) is a Efficiency Google Maps Suitability web mapping service application and technology provided by Google, Utilisation (for non- Accuracy Interoperability Time Behaviour Resource free commercial use), that powers many map-based services, including the Security Google Maps website, Google Ride Finder, Google Transit,[1] and maps Maintainability Reliability embedded on third-party websites via the Google Maps API.[2] It offers Analyzability Changeability street maps, Maturity a route planner for traveling by foot, car, or public Fault Tolerance Stability Testability transport and an urban business locator for numerous countries around Recoverability the world. Google Maps satellite images are not in real time; they are Portability Usability several years old.[3] Adaptability Understandability Installability Learnability Co-Existence Operability Replaceability Attractiveness * Analising from the user point of view, http://en.wikipedia.org/wiki/ISO/IEC_9126 'cause we cannot analise the source code. http://openiconlibrary.sourceforge.net/gallery2/?./Icons/status #CatDroid
  • 7. What can we do with Google Maps? #CatDroid
  • 9. Android is an Open Source project? 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] http://en.wikipedia.org/wiki/Android_%28operating_system%29#Licensing #CatDroid
  • 10. Google Maps is an Android module? 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 android-partnerships@google.com for inquiries related to those apps. http://source.android.com/faqs.html #CatDroid
  • 11. … 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/ #CatDroid
  • 12. 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 Steve Coast, 2009 2.0 licence.[3] http://en.wikipedia.org/wiki/OpenStreetMap #CatDroid
  • 14. Steps 1. Obtaining a Maps API key 2. Adding the lib and the permission to your Manifest 3. Displaying the map 4. Displaying the Zoom View #CatDroid
  • 15. Obtaining a Maps API key Beginning 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 SettingsApplication DataAndroid". 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 #CatDroid
  • 16. 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 #CatDroid
  • 17. 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 FilesJava<JDK_version_number>bin" folder. http://developer.android.com/resources/tutorials/views/hello-mapview.html #CatDroid
  • 18. 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 #CatDroid
  • 19. Obtaining a Maps API key Call the following command to extract the MD5 fingerprint. keytool.exe -list -alias androiddebugkey -keystore "C:androiddebug.keystore" -storepass android -keypass android http://mobiforge.com/developing/story/using-google-maps-android #CatDroid
  • 20. 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 #CatDroid
  • 21. 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 #CatDroid
  • 22. Displaying the Map To 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 #CatDroid
  • 23. Displaying the Map In 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 #CatDroid
  • 24. Displaying the Zoom View First, 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 #CatDroid
  • 25. Displaying the Zoom View In 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 #CatDroid
  • 26. Displaying the Zoom View Alternatively, 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 #CatDroid
  • 27. 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 weimenglee@learn2develop.net. #CatDroid
  • 28. 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/CatDroid The 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 #CatDroid
  • 29. Thanks for your attention! … and patience! rocboronat.net catdroid.org roc@rocboronat.net http://groups.google.com/group/CatDroid