SlideShare une entreprise Scribd logo
1  sur  76
Télécharger pour lire hors ligne
Kasia Derc-Fenske

                       Google Maps Mobile APIs


                       @kaskaderc +Kasia Derc-Fenske // Google
                          kaskaderc




Friday, March 22, 13                                             1
Google Maps Mobile APIs
                             +Kasia Derc-Fenske   kaskaderc      Kasia Derc-Fenske | Google



                        Google Maps                     Google Maps
                       Android API v2                    SDK for iOS




Friday, March 22, 13                                                                          2
Friday, March 22, 13   3
Goal of this presto
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 4
Key features
                                    +Kasia Derc-Fenske                   kaskaderc                              Kasia Derc-Fenske | Google




                                    Android                                       iOS

                                                                                  Development: Xcode 4.5+, iOS SDK 6.+.
                                    API level 12 (level 4 w/Support Library),
               Platforms                                                          Target platform: iOS 5.1
                                    GLES 2


               Vector Maps                      3D Buildings, Roadmap, Hybrid Map, Satellite Imagery, Terrain Map



               Camera Positioning                                Zoom, Pan, Tilt, Bearing, Animation


               Markers & Info
                                                Custom Icons, Anchoring, Dragging (Android), Custom Info Windows
               Windows

               Drawing              Polylines (geodesic), Polygons, and Circles   Polylines (geodesic)



               Overlays                           Ground and Tile                 Ground



               Layers                                                Traffic and Indoor (Android)




Friday, March 22, 13                                                                                                                         5
Before you start
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                               Things you need to do to
                               use the APIs.




Friday, March 22, 13                                                                 6
Getting started
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




       Services Section



       API Access section




Friday, March 22, 13                                                                 7
Getting started
                                 +Kasia Derc-Fenske     kaskaderc             Kasia Derc-Fenske | Google


        API Access section




       13:4A:53:3D:F7:B6:20:...:2C:01:58:F2:C8:36:6A;com.example.mapdemo

       Certificate
        debug
         ◦   OS X and Linux: ~/.android/
         ◦   Windows Vista and Windows 7: C:Usersyour_user_name.android
                                                                                release
                                                                                http://
                                                                                developer.android.com/
                                                                                tools/publishing/app-
                                                                                signing.html#releasemo
     Getting the fingerprint                                                    de

     %> keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -
     storepass android -keypass android




Friday, March 22, 13                                                                                       8
The important NOT s
                          +Kasia Derc-Fenske   kaskaderc           Kasia Derc-Fenske | Google




       • MapView v1 keys will NOT work with the new v2 API

       • The key is generated in the Google APIs Console, NOT the Google Play
         Developer Console




Friday, March 22, 13                                                                            9
+Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                            iOS demo




Friday, March 22, 13                                                                 10
Demo time !
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 11
iOS demo code
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




           Run it!




Friday, March 22, 13                                                                 12
GIS Trivia 1
                                           +Kasia Derc-Fenske      kaskaderc   Kasia Derc-Fenske | Google




        Designed by Ben King (http://thenounproject.com/Kinger/)




Friday, March 22, 13                                                                                        13
GIS Trivia 1
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                 The earth is not flat!




Friday, March 22, 13                                                                 14
What is a geodesic ?
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google



        • the path followed by an object with not
          forces acting on it

        • the “straightest” you can get in curved
          space

        • it’s about pinning a string to two points
          on earth and making it as short as
          possible


Friday, March 22, 13                                                                 15
Going from New York to Rome
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 16
+Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                       Android demo




Friday, March 22, 13                                                                 17
How does it work: Google Play .apk
                       +Kasia Derc-Fenske   kaskaderc       Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                     18
Setting up ADT
                         +Kasia Derc-Fenske   kaskaderc        Kasia Derc-Fenske | Google


     What we need:
       • ADT: http://developer.android.com/sdk/
       • Google Play Services
       • Android Support Library

      Note: Sample code is also bundled with Google Play Services SDK




Friday, March 22, 13                                                                        19
Android Support Library
                        +Kasia Derc-Fenske   kaskaderc       Kasia Derc-Fenske | Google

     • Use SupportMapFragment is targeting API 11 or below
     • Also required for example app




Friday, March 22, 13                                                                      20
Setting up ADT
                                     +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                • import
                       sdk/extras/google/google_play_services/libproject/google-
                       play-services_lib
                       sdk/extras/google/google_play_services/samples/maps
                • add
                       android/compatibility/v4/android-support-v4.jar
                       as an external jar




Friday, March 22, 13                                                                               21
AndroidManifest.xml
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 22
Become a developer
                          +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                       Plug in a physical phone




                       Enable debugging and Run!




Friday, March 22, 13                                                                    23
GIS Trivia 2: Projections
                                           +Kasia Derc-Fenske      kaskaderc   Kasia Derc-Fenske | Google




        Designed by Ben King (http://thenounproject.com/Kinger/)




Friday, March 22, 13                                                                                        24
GIS Trivia 2: XKCD Mercator
                       +Kasia Derc-Fenske   kaskaderc                    Kasia Derc-Fenske | Google




                                            source: http://imgs.xkcd.com/comics/map_projections.png




Friday, March 22, 13                                                                                  25
GIS Trivia 2: Mercator
                         +Kasia Derc-Fenske   kaskaderc     Kasia Derc-Fenske | Google

                       http://kaskaderc.github.com/
                       maps_samples/projections/mercator.html




Friday, March 22, 13                                                                     26
What’s available
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                          Android Maps Api
                          Features




Friday, March 22, 13                                                                 27
The simplest implementation
                           +Kasia Derc-Fenske    kaskaderc               Kasia Derc-Fenske | Google


    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:map="http://schemas.android.com/apk/res-auto"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      class="com.google.android.gms.maps.MapFragment"
      map:cameraBearing="12.5"
      map:cameraTargetLat="53.012098"
      map:cameraTargetLng="18.593674"
      map:cameraTilt="45"
      map:cameraZoom="14"
      map:mapType="normal"
      map:uiCompass="false"
      map:uiRotateGestures="true"    public class MainActivity extends Activity {
      map:uiScrollGestures="true"
                                         @Override
      map:uiTiltGestures="true"          protected void onCreate(Bundle savedInstanceState) {
      map:uiZoomControls="true"
                                             super.onCreate(savedInstanceState);
      map:uiZoomGestures="true" />           setContentView(R.layout.activity_main);
                                          }
                                     }




Friday, March 22, 13                                                                                  28
Android Maps API: deeper dive
                                    +Kasia Derc-Fenske    kaskaderc              Kasia Derc-Fenske | Google


        http://developer.android.com/reference/

                                       com/google/android/gms/maps/package-summary.html




       public class MainActivity extends android.support.v4.app.FragmentActivity {
           private GoogleMap map;

               protected void onCreate(Bundle savedInstanceState) {
                   super.onCreate(savedInstanceState);
                   setContentView(R.layout.activity_main);

                       map = ((SupportMapFragment) getSupportFragmentManager()
                               .findFragmentById(R.id.map)).getMap();
               }
       ...




Friday, March 22, 13                                                                                          29
1. Base Maps in 3D
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 30
Camera positioning
                               +Kasia Derc-Fenske        kaskaderc               Kasia Derc-Fenske | Google



         sample code from CameraDemoActivity.java
           static final CameraPosition BONDI =
               new CameraPosition.Builder().target(new LatLng(-33.891614, 151.276417))
                   .zoom(15.5f)
                   .bearing(300)
                   .tilt(50)
                   .build();


         CameraUpdate   cameraUpdate   =   CameraUpdateFactory.newCameraPosition(BONDI));
         CameraUpdate   cameraUpdate   =   CameraUpdateFactory.newLatLng(new LatLng(-33.89, 151.27));
         CameraUpdate   cameraUpdate   =   CameraUpdateFactory.scrollBy(50, 0);
         CameraUpdate   cameraUpdate   =   CameraUpdateFactory.zoomTo(10); // Or In/Out/By




         map.moveCamera(cameraUpdate);                 map.animateCamera(cameraUpdate);




Friday, March 22, 13                                                                                          31
2. Indoor floor plans
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                                   map:cameraTargetLat="47.35"
                                   map:cameraTargetLng="8.523"
                                   map:cameraTilt="45"
                                   map:cameraZoom="18"
                                   map:mapType="normal"




Friday, March 22, 13                                                                 32
3. Traffic and My Location
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                                    LayersDemoActivity.java




                                  mMap.
                                    setTrafficEnabled(true);




Friday, March 22, 13                                                                 33
4. Custom Overlays
                       +Kasia Derc-Fenske   kaskaderc        Kasia Derc-Fenske | Google




                                             sample code from
                                             GroundOverlayDemoActivity.java




   mGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions()
       .image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922))
       .anchor(0, 1)
       .position(NEWARK, 8600f, 6500f));




                                                                                  34
Friday, March 22, 13                                                                      34
5. Markers & InfoWindows
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 35
5. Markers and Info Windows
                       +Kasia Derc-Fenske    kaskaderc          Kasia Derc-Fenske | Google




                                            map.addMarker(new MarkerOptions()
                                            .position(new LatLng(37.5, 122.5))
                                            .title("Title") // optional
                                            .snippet("And a Snippet!") //
                                            optional
                                            .draggable(true) // optional
                                            .visible(true)); // optional




Friday, March 22, 13                                                                         36
5. Markers and Info Windows
                                 +Kasia Derc-Fenske   kaskaderc               Kasia Derc-Fenske | Google



                             map.addMarker(new MarkerOptions()
                                 .position(new LatLng(40, 40))
                                 .icon(BitmapDescriptorFactory.defaultMarker(
                                     BitmapDescriptorFactory.HUE_AZURE))); // float hue 0-359




                                     map.addMarker(new MarkerOptions()
                                         .position(new LatLng(50, 50))
                                         .icon(BitmapDescriptorFactory
                                         .fromResource(R.drawable.marker)));
                                     // or fromAsset(String), fromBitmap(Bitmap), fromFile(String)


                map.addMarker(new MarkerOptions()
                    .position(new LatLng(60, 60))
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_shadow))
                    .anchor(.23f, 1)); // ratio of width & height from top-left corner




Friday, March 22, 13                                                                                       37
5. Markers and Info Windows
                              +Kasia Derc-Fenske      kaskaderc               Kasia Derc-Fenske | Google



                                                           (1.0,0.0)
                                           ←u→



                               ←v→
                                                                  (0.8,0.4)



                                                             (1.0,1.0)
                       (0.0,1.0)        (0.5,1.0)
                                          [default]




Friday, March 22, 13                                                                                       38
Custom info windows
                                  +Kasia Derc-Fenske   kaskaderc             Kasia Derc-Fenske | Google



         • Create a InfoWindowAdapter

              class CustomInfoWindowAdapter implements InfoWindowAdapter {
                @Override
                public View getInfoContents(Marker marker) {
                  return null; // return null for default InfoWindow
                }

                  @Override
                  public View getInfoWindow(Marker marker) {
                    return null; // call getInfoContents
                  }
              }

         • Attach the adapter to the map




Friday, March 22, 13                                                                                      39
Marker and Info Window Events!
                                  +Kasia Derc-Fenske    kaskaderc            Kasia Derc-Fenske | Google



         • Defining Listeners
             public class MarkerActivity extends android.support.v4.app.FragmentActivity
             implements OnMarkerClickListener, OnInfoWindowClickListener,
             OnMarkerDragListener {
             ...

         • Registering Listeners
            map.setOnMarkerClickListener(this);
            map.setOnInfoWindowClickListener(this);
            map.setOnMarkerDragListener(this);

         • Receiving Events
            public     void onMarkerDrag(Marker marker) {}
            public     void onMarkerDragEnd(Marker marker) {}
            public     void onMarkerDragStart(Marker marker) {}
            public     void onInfoWindowClick(Marker marker) {}
            public     boolean onMarkerClick(Marker marker) {}




Friday, March 22, 13                                                                                      40
6. Polylines & Polygons
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 41
Slide’s title
                               +Kasia Derc-Fenske    kaskaderc               Kasia Derc-Fenske | Google


       • Polyline
             map.addPolyline(new PolylineOptions()
                 .add(LHR, AKL, LAX, JFK, LHR) // LatLng... or addAll(List<LatLng>)
                 .width(5)
                 .color(Color.BLUE)
                 .geodesic(true));



       • Polygon

           map.addPolygon(new PolygonOptions()
               .addAll(coords) // List<LatLng>
               .addHole(hole) // List<LatLng>
               .fillColor(Color.CYAN)
               .strokeColor(Color.BLUE)
               .strokeWidth(5)
               .geodesic(true));




Friday, March 22, 13                                                                                      42
6. Fragment Support
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 43
6. Fragment Support
                            +Kasia Derc-Fenske   kaskaderc               Kasia Derc-Fenske | Google


        MultiMapDemoActivity.java
       public class MultiMapDemoActivity extends
       android.support.v4.app.FragmentActivity {
           @Override
           protected void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
               setContentView(R.layout.multimap_demo);
           }
       }             <LinearLayout xmlns:android=...
                       xmlns:map=...
                       android:id="@+id/map_container"
                      ...
                                                 <fragment
       <LinearLayout                                   android:id="@+id/map1"
              android:id="@+id/map_container2"               <fragment
                                                                  android:id="@+id/map2"




Friday, March 22, 13                                                                                  44
7. Tile Overlays
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 45
Hello Map and getting started
                         +Kasia Derc-Fenske   kaskaderc                Kasia Derc-Fenske | Google




       Shortcuts: Kick-start Google Maps Android API v2 Development
       https://www.youtube.com/watch?v=VecPbAK5U4M




                                                 http://github.com/googlemaps/hellomap-android




Friday, March 22, 13                                                                                46
GIS Trivia 3: Projections c.d.
                                           +Kasia Derc-Fenske      kaskaderc   Kasia Derc-Fenske | Google




        Designed by Ben King (http://thenounproject.com/Kinger/)




Friday, March 22, 13                                                                                        47
GIS Trivia 3: XKCD Gall-Peters
                       +Kasia Derc-Fenske     kaskaderc                     Kasia Derc-Fenske | Google




                                            source: http://imgs.xkcd.com/comics/map_projections.png




Friday, March 22, 13                                                                                     48
GIS Trivia 3: Gall - Peters projection
                         +Kasia Derc-Fenske   kaskaderc           Kasia Derc-Fenske | Google

                       http://kaskaderc.github.com/
                       maps_samples/projections/gallpeters.html




Friday, March 22, 13                                                                           49
GIS Trivia 3: XKCD and Projections
                       +Kasia Derc-Fenske      kaskaderc                     Kasia Derc-Fenske | Google




      http://xkcd.com/977/




                                        source: http://imgs.xkcd.com/comics/map_projections.png




Friday, March 22, 13                                                                                      50
Maps SDK for iOS Features and Sample
                          +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                       Maps SDK for iOS Features




Friday, March 22, 13                                                                    51
1. Basic Maps in 3D, map types, traffic layer
                       +Kasia Derc-Fenske   kaskaderc        Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                      52
2. Polylines, Custom Markers, Ground Overlay...
                       +Kasia Derc-Fenske   kaskaderc     Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                   53
Let’s check sample projects!
                       +Kasia Derc-Fenske   kaskaderc    Kasia Derc-Fenske | Google




                                            Instead or
                                            reiterating sample
                                            code let’s see how to
                                            use storyboards and
                                            look at the event
                                            model.



Friday, March 22, 13                                                                  54
Getting started iOS project
                        +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                       getting started project




Friday, March 22, 13                                                                  55
Using storyboards
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 56
Protocols and Delegates
                                    +Kasia Derc-Fenske       kaskaderc                 Kasia Derc-Fenske | Google




    #import <UIKit/UIKit.h>
    #import <GoogleMaps/GoogleMaps.h>

    @interface googleMainController : UIViewController<GMSMapViewDelegate>
    @property (weak, nonatomic) IBOutlet UILabel *mapLabel;
    @property (strong, nonatomic) IBOutlet GMSMapView *googleMap;
    ...
    @end
                  - (void)viewDidLoad
                  {
                      [super viewDidLoad];
                      self.googleMap.camera = [GMSCameraPosition cameraWithLatitude:41.9015141
                                                                          longitude:12.4607737
                                                                               zoom:15
                                                                            bearing:10.f
                                                                       viewingAngle:37.5f];
                      self.googleMap.delegate = self;

                  }




Friday, March 22, 13                                                                                                57
From the Controller’s perspective
                              +Kasia Derc-Fenske   kaskaderc         Kasia Derc-Fenske | Google




        We will implement some of the Map delegate functions
                  @interface googleMainController :            declared in
                  UIViewController<GMSMapViewDelegate>         GMSMapView.h


        We will tell the map we will be it’s delegate
                 self.googleMap.delegate = self;




Friday, March 22, 13                                                                              58
GMS Map View Delegate methods
                           +Kasia Derc-Fenske   kaskaderc            Kasia Derc-Fenske | Google



       @protocol GMSMapViewDelegate <NSObject>
        (void)mapView:(GMSMapView *)mapView
           didChangeCameraPosition:(GMSCameraPosition *)position;

                         - (void)mapView:(GMSMapView *)mapView
                             didTapAtCoordinate:(CLLocationCoordinate2D)coordinate;

      - (void)mapView:(GMSMapView *)mapView
          didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate;

                                    (BOOL)mapView:(GMSMapView *)mapView didTapMarker:
                                   (id<GMSMarker>)marker;

      - (void)mapView:(GMSMapView *)mapView
          didTapInfoWindowOfMarker:(id<GMSMarker>)marker;




Friday, March 22, 13                                                                              59
Logging activity
                       +Kasia Derc-Fenske   kaskaderc      Kasia Derc-Fenske | Google




   - (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:
   (GMSCameraPosition *)position {
       NSLog(@"You changed camera position to zoom %f, target: %f, %f ",
             position.zoom,
             position.targetAsCoordinate.latitude,
             position.targetAsCoordinate.longitude);

   }

   - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:
   (CLLocationCoordinate2D)coordinate {
         NSLog(@"You tapped at %f,%f",
             coordinate.latitude, coordinate.longitude);
   }




Friday, March 22, 13                                                                    60
Zoom in out buttons
                                     +Kasia Derc-Fenske       kaskaderc                      Kasia Derc-Fenske | Google




                       https://github.com/kaskaderc/ios_samples/




       - (IBAction)tappedZoomOut:(UIButton *)sender {
           CGFloat currentZoom = self.googleMap.camera.zoom;
           if (currentZoom > kGMSMinZoomLevel) {
               self.googleMap.camera = [GMSCameraPosition cameraWithLatitude:self.googleMap.camera.target.latitude
                                                                   longitude:self.googleMap.camera.target.longitude
                                                                        zoom:currentZoom-1
                                                                     bearing:self.googleMap.camera.bearing
                                                                viewingAngle:self.googleMap.camera.viewingAngle];
           }
       }




Friday, March 22, 13                                                                                                      61
Visualizing JSON data
                         +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                       Earthquakes on the Move




Friday, March 22, 13                                                                   62
Earthquakes on the Move storyboard
                       +Kasia Derc-Fenske   kaskaderc       Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                     63
Earthquakes on the Move code
                           +Kasia Derc-Fenske    kaskaderc                  Kasia Derc-Fenske | Google



     #define kUSGSEarthQuakes [NSURL URLWithString:@"http://
     earthquake.usgs.gov/earthquakes/feed/geojson/all/hour"]

     #import <UIKit/UIKit.h>

     @interface EQTableViewController : UITableViewController
     @property (nonatomic, strong) IBOutlet UILabel *quakeLabel;
     @property (nonatomic, strong) NSString *quakeName;
     @property (nonatomic, strong) IBOutlet UITableView *tableView;
     @property (nonatomic, strong) NSData* data;
     @property (nonatomic, strong) NSDictionary* json;

     @end


     @interface EQTableViewController (){                    - (void)viewDidLoad
         NSMutableArray *quakeArray;                         {
         NSMutableArray *markerArray;                            [super viewDidLoad];
     }                                                           [self fetchData];
     @end                                                    }




Friday, March 22, 13                                                                                     64
iOS Demo App : Earthquakes on the Move
                       +Kasia Derc-Fenske    kaskaderc          Kasia Derc-Fenske | Google




       Find out by watching Maps Developer
       Shortcuts!

                                       Shortcuts: Earthquakes on the Move
                                       https://www.youtube.com/watch?v=xZt5ZIWWUd0




Friday, March 22, 13                                                                         65
Launching native Google Maps app
                                +Kasia Derc-Fenske    kaskaderc             Kasia Derc-Fenske | Google



      Android intents
     Uri uri = Uri.parse("http://maps.google.com/maps?saddr=FROM_LOCATION&daddr=TO_LOCATION");
     Uri uri = Uri.parse("geo:13.070984,80.253639");
     Intent in = new Intent(Intent.ACTION_VIEW, uri);
     startActivity(in);




     iOS URL Scheme
               [[UIApplication sharedApplication] canOpenURL:
                   [NSURL URLWithString:@"comgooglemaps://"]];


                comgooglemaps://?saddr=Google+Inc,+8th+Avenue,+New+York,
                +NY&daddr=John+F.+Kennedy+International+Airport,+Van+Wyck
                +Expressway,+Jamaica,+New+York&directionsmode=transit




Friday, March 22, 13                                                                                     66
Google Maps Web Services - Server side
                                  +Kasia Derc-Fenske    kaskaderc               Kasia Derc-Fenske | Google


      100K requests per 24 hour period ( if billing is enabled )
                 Places API: Detailed information about (80M+) places
                 across a wide range of categories.

     2500 requests per day
                  Directions API: Directions for several modes of transportation
                  (transit, driving, walking or cycling) between locations, including waypoints.

                  Distance Matrix API: Travel distance and time for a matrix of locations.

                  Elevation API: Elevation data for all locations on the surface of the earth,
                  including depth locations on the ocean floor.

                  Geocoding API: Forward and reverse geocoding.

                  Time Zone API: Time offset data for locations on Earth.


Friday, March 22, 13                                                                                         67
GIS Trivia 4: Maps Surprises
                                           +Kasia Derc-Fenske      kaskaderc   Kasia Derc-Fenske | Google




        Designed by Ben King (http://thenounproject.com/Kinger/)




Friday, March 22, 13                                                                                        68
GIS Trivia 4: be surprised
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 69
GIS Trivia 4: True size of Africa by Kai Krause
                       +Kasia Derc-Fenske   kaskaderc                                Kasia Derc-Fenske | Google




                                                  full image: http://www.learnnc.org/lp/multimedia/16023




Friday, March 22, 13                                                                                              70
Getting in touch
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




            https://developers.google.com/maps/forum/
Friday, March 22, 13                                                                 71
Issue tracker
                       +Kasia Derc-Fenske   kaskaderc        Kasia Derc-Fenske | Google




                                                        Issue tracker
                                                            code.google.com




Friday, March 22, 13                                                                      72
Asking questions
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




Friday, March 22, 13                                                                 73
Staying tuned
                       +Kasia Derc-Fenske   kaskaderc   Kasia Derc-Fenske | Google




                       developers.google.com/maps
                       Google Maps API (G+ & Twitter)

                       Google Geo Developers Blog

                       Google Maps API Developers Live



Friday, March 22, 13                                                                 74
Extra tips
                              +Kasia Derc-Fenske   kaskaderc               Kasia Derc-Fenske | Google



            Add
             <uses-permission
            android:name="android.permission.ACCESS_NETWORK_STATE"/>

           into AndroidManifest.xml to ensure correct behavior under poor connectivity conditions




Friday, March 22, 13                                                                                    75
Kasia Derc-Fenske

                       Thank you!
                       @kdf +Kasia Derc-Fenske // Google
                          kaskaderc

                       @ +alfredomorresi Alfredo Morresi // Google Italy
                          rainbowbreeze




Friday, March 22, 13                                                       76

Contenu connexe

Plus de Codemotion

Plus de Codemotion (20)

Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
 
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
 
Mete Atamel - Serverless with Knative - Codemotion Amsterdam 2019
Mete Atamel - Serverless with Knative - Codemotion Amsterdam 2019Mete Atamel - Serverless with Knative - Codemotion Amsterdam 2019
Mete Atamel - Serverless with Knative - Codemotion Amsterdam 2019
 
Rahul Shetty - Corporate relocation prediction - Codemotion Amsterdam 2019
Rahul Shetty - Corporate relocation prediction - Codemotion Amsterdam 2019Rahul Shetty - Corporate relocation prediction - Codemotion Amsterdam 2019
Rahul Shetty - Corporate relocation prediction - Codemotion Amsterdam 2019
 
Mario Viviani - Designing apps for fire TV - Codemotion Amsterdam 2019
Mario Viviani - Designing apps for fire TV - Codemotion Amsterdam 2019Mario Viviani - Designing apps for fire TV - Codemotion Amsterdam 2019
Mario Viviani - Designing apps for fire TV - Codemotion Amsterdam 2019
 
Ilona Demidenko - Conversational Sign Up - Codemotion Amsterdam 2019
Ilona Demidenko - Conversational Sign Up - Codemotion Amsterdam 2019Ilona Demidenko - Conversational Sign Up - Codemotion Amsterdam 2019
Ilona Demidenko - Conversational Sign Up - Codemotion Amsterdam 2019
 
Katie Koschland - Ready, steady, crash - Codemotion Amsterdam 2019
Katie Koschland - Ready, steady, crash - Codemotion Amsterdam 2019Katie Koschland - Ready, steady, crash - Codemotion Amsterdam 2019
Katie Koschland - Ready, steady, crash - Codemotion Amsterdam 2019
 
Matteo Antony Mistretta - React, the Inglorious way - Codemotion Amsterdam 2019
Matteo Antony Mistretta - React, the Inglorious way - Codemotion Amsterdam 2019Matteo Antony Mistretta - React, the Inglorious way - Codemotion Amsterdam 2019
Matteo Antony Mistretta - React, the Inglorious way - Codemotion Amsterdam 2019
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Google Maps Mobile APIs by Kasia Derc-Fenske

  • 1. Kasia Derc-Fenske Google Maps Mobile APIs @kaskaderc +Kasia Derc-Fenske // Google kaskaderc Friday, March 22, 13 1
  • 2. Google Maps Mobile APIs +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Google Maps Google Maps Android API v2 SDK for iOS Friday, March 22, 13 2
  • 4. Goal of this presto +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 4
  • 5. Key features +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Android iOS Development: Xcode 4.5+, iOS SDK 6.+. API level 12 (level 4 w/Support Library), Platforms Target platform: iOS 5.1 GLES 2 Vector Maps 3D Buildings, Roadmap, Hybrid Map, Satellite Imagery, Terrain Map Camera Positioning Zoom, Pan, Tilt, Bearing, Animation Markers & Info Custom Icons, Anchoring, Dragging (Android), Custom Info Windows Windows Drawing Polylines (geodesic), Polygons, and Circles Polylines (geodesic) Overlays Ground and Tile Ground Layers Traffic and Indoor (Android) Friday, March 22, 13 5
  • 6. Before you start +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Things you need to do to use the APIs. Friday, March 22, 13 6
  • 7. Getting started +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Services Section API Access section Friday, March 22, 13 7
  • 8. Getting started +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google API Access section 13:4A:53:3D:F7:B6:20:...:2C:01:58:F2:C8:36:6A;com.example.mapdemo Certificate debug ◦ OS X and Linux: ~/.android/ ◦ Windows Vista and Windows 7: C:Usersyour_user_name.android release http:// developer.android.com/ tools/publishing/app- signing.html#releasemo Getting the fingerprint de %> keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey - storepass android -keypass android Friday, March 22, 13 8
  • 9. The important NOT s +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google • MapView v1 keys will NOT work with the new v2 API • The key is generated in the Google APIs Console, NOT the Google Play Developer Console Friday, March 22, 13 9
  • 10. +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google iOS demo Friday, March 22, 13 10
  • 11. Demo time ! +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 11
  • 12. iOS demo code +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Run it! Friday, March 22, 13 12
  • 13. GIS Trivia 1 +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Designed by Ben King (http://thenounproject.com/Kinger/) Friday, March 22, 13 13
  • 14. GIS Trivia 1 +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google The earth is not flat! Friday, March 22, 13 14
  • 15. What is a geodesic ? +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google • the path followed by an object with not forces acting on it • the “straightest” you can get in curved space • it’s about pinning a string to two points on earth and making it as short as possible Friday, March 22, 13 15
  • 16. Going from New York to Rome +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 16
  • 17. +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Android demo Friday, March 22, 13 17
  • 18. How does it work: Google Play .apk +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 18
  • 19. Setting up ADT +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google What we need: • ADT: http://developer.android.com/sdk/ • Google Play Services • Android Support Library Note: Sample code is also bundled with Google Play Services SDK Friday, March 22, 13 19
  • 20. Android Support Library +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google • Use SupportMapFragment is targeting API 11 or below • Also required for example app Friday, March 22, 13 20
  • 21. Setting up ADT +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google • import sdk/extras/google/google_play_services/libproject/google- play-services_lib sdk/extras/google/google_play_services/samples/maps • add android/compatibility/v4/android-support-v4.jar as an external jar Friday, March 22, 13 21
  • 22. AndroidManifest.xml +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 22
  • 23. Become a developer +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Plug in a physical phone Enable debugging and Run! Friday, March 22, 13 23
  • 24. GIS Trivia 2: Projections +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Designed by Ben King (http://thenounproject.com/Kinger/) Friday, March 22, 13 24
  • 25. GIS Trivia 2: XKCD Mercator +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google source: http://imgs.xkcd.com/comics/map_projections.png Friday, March 22, 13 25
  • 26. GIS Trivia 2: Mercator +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google http://kaskaderc.github.com/ maps_samples/projections/mercator.html Friday, March 22, 13 26
  • 27. What’s available +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Android Maps Api Features Friday, March 22, 13 27
  • 28. The simplest implementation +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.MapFragment" map:cameraBearing="12.5" map:cameraTargetLat="53.012098" map:cameraTargetLng="18.593674" map:cameraTilt="45" map:cameraZoom="14" map:mapType="normal" map:uiCompass="false" map:uiRotateGestures="true" public class MainActivity extends Activity { map:uiScrollGestures="true" @Override map:uiTiltGestures="true" protected void onCreate(Bundle savedInstanceState) { map:uiZoomControls="true" super.onCreate(savedInstanceState); map:uiZoomGestures="true" /> setContentView(R.layout.activity_main); } } Friday, March 22, 13 28
  • 29. Android Maps API: deeper dive +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google http://developer.android.com/reference/ com/google/android/gms/maps/package-summary.html public class MainActivity extends android.support.v4.app.FragmentActivity { private GoogleMap map; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); map = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)).getMap(); } ... Friday, March 22, 13 29
  • 30. 1. Base Maps in 3D +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 30
  • 31. Camera positioning +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google sample code from CameraDemoActivity.java static final CameraPosition BONDI = new CameraPosition.Builder().target(new LatLng(-33.891614, 151.276417)) .zoom(15.5f) .bearing(300) .tilt(50) .build(); CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(BONDI)); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLng(new LatLng(-33.89, 151.27)); CameraUpdate cameraUpdate = CameraUpdateFactory.scrollBy(50, 0); CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(10); // Or In/Out/By map.moveCamera(cameraUpdate); map.animateCamera(cameraUpdate); Friday, March 22, 13 31
  • 32. 2. Indoor floor plans +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google map:cameraTargetLat="47.35" map:cameraTargetLng="8.523" map:cameraTilt="45" map:cameraZoom="18" map:mapType="normal" Friday, March 22, 13 32
  • 33. 3. Traffic and My Location +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google LayersDemoActivity.java mMap. setTrafficEnabled(true); Friday, March 22, 13 33
  • 34. 4. Custom Overlays +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google sample code from GroundOverlayDemoActivity.java mGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922)) .anchor(0, 1) .position(NEWARK, 8600f, 6500f)); 34 Friday, March 22, 13 34
  • 35. 5. Markers & InfoWindows +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 35
  • 36. 5. Markers and Info Windows +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google map.addMarker(new MarkerOptions() .position(new LatLng(37.5, 122.5)) .title("Title") // optional .snippet("And a Snippet!") // optional .draggable(true) // optional .visible(true)); // optional Friday, March 22, 13 36
  • 37. 5. Markers and Info Windows +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google map.addMarker(new MarkerOptions() .position(new LatLng(40, 40)) .icon(BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_AZURE))); // float hue 0-359 map.addMarker(new MarkerOptions() .position(new LatLng(50, 50)) .icon(BitmapDescriptorFactory .fromResource(R.drawable.marker))); // or fromAsset(String), fromBitmap(Bitmap), fromFile(String) map.addMarker(new MarkerOptions() .position(new LatLng(60, 60)) .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_shadow)) .anchor(.23f, 1)); // ratio of width & height from top-left corner Friday, March 22, 13 37
  • 38. 5. Markers and Info Windows +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google (1.0,0.0) ←u→ ←v→ (0.8,0.4) (1.0,1.0) (0.0,1.0) (0.5,1.0) [default] Friday, March 22, 13 38
  • 39. Custom info windows +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google • Create a InfoWindowAdapter class CustomInfoWindowAdapter implements InfoWindowAdapter { @Override public View getInfoContents(Marker marker) { return null; // return null for default InfoWindow } @Override public View getInfoWindow(Marker marker) { return null; // call getInfoContents } } • Attach the adapter to the map Friday, March 22, 13 39
  • 40. Marker and Info Window Events! +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google • Defining Listeners public class MarkerActivity extends android.support.v4.app.FragmentActivity implements OnMarkerClickListener, OnInfoWindowClickListener, OnMarkerDragListener { ... • Registering Listeners map.setOnMarkerClickListener(this); map.setOnInfoWindowClickListener(this); map.setOnMarkerDragListener(this); • Receiving Events public void onMarkerDrag(Marker marker) {} public void onMarkerDragEnd(Marker marker) {} public void onMarkerDragStart(Marker marker) {} public void onInfoWindowClick(Marker marker) {} public boolean onMarkerClick(Marker marker) {} Friday, March 22, 13 40
  • 41. 6. Polylines & Polygons +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 41
  • 42. Slide’s title +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google • Polyline map.addPolyline(new PolylineOptions() .add(LHR, AKL, LAX, JFK, LHR) // LatLng... or addAll(List<LatLng>) .width(5) .color(Color.BLUE) .geodesic(true)); • Polygon map.addPolygon(new PolygonOptions() .addAll(coords) // List<LatLng> .addHole(hole) // List<LatLng> .fillColor(Color.CYAN) .strokeColor(Color.BLUE) .strokeWidth(5) .geodesic(true)); Friday, March 22, 13 42
  • 43. 6. Fragment Support +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 43
  • 44. 6. Fragment Support +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google MultiMapDemoActivity.java public class MultiMapDemoActivity extends android.support.v4.app.FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multimap_demo); } } <LinearLayout xmlns:android=... xmlns:map=... android:id="@+id/map_container" ... <fragment <LinearLayout android:id="@+id/map1" android:id="@+id/map_container2" <fragment android:id="@+id/map2" Friday, March 22, 13 44
  • 45. 7. Tile Overlays +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 45
  • 46. Hello Map and getting started +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Shortcuts: Kick-start Google Maps Android API v2 Development https://www.youtube.com/watch?v=VecPbAK5U4M http://github.com/googlemaps/hellomap-android Friday, March 22, 13 46
  • 47. GIS Trivia 3: Projections c.d. +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Designed by Ben King (http://thenounproject.com/Kinger/) Friday, March 22, 13 47
  • 48. GIS Trivia 3: XKCD Gall-Peters +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google source: http://imgs.xkcd.com/comics/map_projections.png Friday, March 22, 13 48
  • 49. GIS Trivia 3: Gall - Peters projection +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google http://kaskaderc.github.com/ maps_samples/projections/gallpeters.html Friday, March 22, 13 49
  • 50. GIS Trivia 3: XKCD and Projections +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google http://xkcd.com/977/ source: http://imgs.xkcd.com/comics/map_projections.png Friday, March 22, 13 50
  • 51. Maps SDK for iOS Features and Sample +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Maps SDK for iOS Features Friday, March 22, 13 51
  • 52. 1. Basic Maps in 3D, map types, traffic layer +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 52
  • 53. 2. Polylines, Custom Markers, Ground Overlay... +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 53
  • 54. Let’s check sample projects! +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Instead or reiterating sample code let’s see how to use storyboards and look at the event model. Friday, March 22, 13 54
  • 55. Getting started iOS project +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google getting started project Friday, March 22, 13 55
  • 56. Using storyboards +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 56
  • 57. Protocols and Delegates +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google #import <UIKit/UIKit.h> #import <GoogleMaps/GoogleMaps.h> @interface googleMainController : UIViewController<GMSMapViewDelegate> @property (weak, nonatomic) IBOutlet UILabel *mapLabel; @property (strong, nonatomic) IBOutlet GMSMapView *googleMap; ... @end - (void)viewDidLoad { [super viewDidLoad]; self.googleMap.camera = [GMSCameraPosition cameraWithLatitude:41.9015141 longitude:12.4607737 zoom:15 bearing:10.f viewingAngle:37.5f]; self.googleMap.delegate = self; } Friday, March 22, 13 57
  • 58. From the Controller’s perspective +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google We will implement some of the Map delegate functions @interface googleMainController : declared in UIViewController<GMSMapViewDelegate> GMSMapView.h We will tell the map we will be it’s delegate self.googleMap.delegate = self; Friday, March 22, 13 58
  • 59. GMS Map View Delegate methods +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google @protocol GMSMapViewDelegate <NSObject> (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position; - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate; - (void)mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate; (BOOL)mapView:(GMSMapView *)mapView didTapMarker: (id<GMSMarker>)marker; - (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(id<GMSMarker>)marker; Friday, March 22, 13 59
  • 60. Logging activity +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google - (void)mapView:(GMSMapView *)mapView didChangeCameraPosition: (GMSCameraPosition *)position { NSLog(@"You changed camera position to zoom %f, target: %f, %f ", position.zoom, position.targetAsCoordinate.latitude, position.targetAsCoordinate.longitude); } - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate: (CLLocationCoordinate2D)coordinate { NSLog(@"You tapped at %f,%f", coordinate.latitude, coordinate.longitude); } Friday, March 22, 13 60
  • 61. Zoom in out buttons +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google https://github.com/kaskaderc/ios_samples/ - (IBAction)tappedZoomOut:(UIButton *)sender { CGFloat currentZoom = self.googleMap.camera.zoom; if (currentZoom > kGMSMinZoomLevel) { self.googleMap.camera = [GMSCameraPosition cameraWithLatitude:self.googleMap.camera.target.latitude longitude:self.googleMap.camera.target.longitude zoom:currentZoom-1 bearing:self.googleMap.camera.bearing viewingAngle:self.googleMap.camera.viewingAngle]; } } Friday, March 22, 13 61
  • 62. Visualizing JSON data +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Earthquakes on the Move Friday, March 22, 13 62
  • 63. Earthquakes on the Move storyboard +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 63
  • 64. Earthquakes on the Move code +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google #define kUSGSEarthQuakes [NSURL URLWithString:@"http:// earthquake.usgs.gov/earthquakes/feed/geojson/all/hour"] #import <UIKit/UIKit.h> @interface EQTableViewController : UITableViewController @property (nonatomic, strong) IBOutlet UILabel *quakeLabel; @property (nonatomic, strong) NSString *quakeName; @property (nonatomic, strong) IBOutlet UITableView *tableView; @property (nonatomic, strong) NSData* data; @property (nonatomic, strong) NSDictionary* json; @end @interface EQTableViewController (){ - (void)viewDidLoad NSMutableArray *quakeArray; { NSMutableArray *markerArray; [super viewDidLoad]; } [self fetchData]; @end } Friday, March 22, 13 64
  • 65. iOS Demo App : Earthquakes on the Move +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Find out by watching Maps Developer Shortcuts! Shortcuts: Earthquakes on the Move https://www.youtube.com/watch?v=xZt5ZIWWUd0 Friday, March 22, 13 65
  • 66. Launching native Google Maps app +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Android intents Uri uri = Uri.parse("http://maps.google.com/maps?saddr=FROM_LOCATION&daddr=TO_LOCATION"); Uri uri = Uri.parse("geo:13.070984,80.253639"); Intent in = new Intent(Intent.ACTION_VIEW, uri); startActivity(in); iOS URL Scheme [[UIApplication sharedApplication] canOpenURL:     [NSURL URLWithString:@"comgooglemaps://"]]; comgooglemaps://?saddr=Google+Inc,+8th+Avenue,+New+York, +NY&daddr=John+F.+Kennedy+International+Airport,+Van+Wyck +Expressway,+Jamaica,+New+York&directionsmode=transit Friday, March 22, 13 66
  • 67. Google Maps Web Services - Server side +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google 100K requests per 24 hour period ( if billing is enabled ) Places API: Detailed information about (80M+) places across a wide range of categories. 2500 requests per day Directions API: Directions for several modes of transportation (transit, driving, walking or cycling) between locations, including waypoints. Distance Matrix API: Travel distance and time for a matrix of locations. Elevation API: Elevation data for all locations on the surface of the earth, including depth locations on the ocean floor. Geocoding API: Forward and reverse geocoding. Time Zone API: Time offset data for locations on Earth. Friday, March 22, 13 67
  • 68. GIS Trivia 4: Maps Surprises +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Designed by Ben King (http://thenounproject.com/Kinger/) Friday, March 22, 13 68
  • 69. GIS Trivia 4: be surprised +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 69
  • 70. GIS Trivia 4: True size of Africa by Kai Krause +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google full image: http://www.learnnc.org/lp/multimedia/16023 Friday, March 22, 13 70
  • 71. Getting in touch +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google https://developers.google.com/maps/forum/ Friday, March 22, 13 71
  • 72. Issue tracker +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Issue tracker code.google.com Friday, March 22, 13 72
  • 73. Asking questions +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Friday, March 22, 13 73
  • 74. Staying tuned +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google developers.google.com/maps Google Maps API (G+ & Twitter) Google Geo Developers Blog Google Maps API Developers Live Friday, March 22, 13 74
  • 75. Extra tips +Kasia Derc-Fenske kaskaderc Kasia Derc-Fenske | Google Add <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> into AndroidManifest.xml to ensure correct behavior under poor connectivity conditions Friday, March 22, 13 75
  • 76. Kasia Derc-Fenske Thank you! @kdf +Kasia Derc-Fenske // Google kaskaderc @ +alfredomorresi Alfredo Morresi // Google Italy rainbowbreeze Friday, March 22, 13 76