Tampilkan postingan dengan label Google Maps. Tampilkan semua postingan
Tampilkan postingan dengan label Google Maps. Tampilkan semua postingan

Kamis, 24 September 2015

Always-on Android Wear apps with the Google Maps API

Originally posted on the Geo Developers Blog


Posted by Ankur Kotwal, Developer Advocate


Some Android Wear apps are most useful when they are always available to the user, even at a glance. Now, with Google Play Services 8.1, the Google Maps Android API supports ambient mode, the API that provides always-on capabilities. In ambient mode, the map adjusts its style to provide a simplified, low-color rendering of the map. All markers, objects, and UI controls disappear, keeping the map on the screen while letting the user know that it is not currently ready to accept user input. An important advantage is the camera position and zoom level are retained, thus keeping the user’s context within the map.


The screenshot below show how maps appear in interactive mode and in ambient mode.




To implement ambient mode in your maps, follow these steps:


  1. Set your your targetSDKVersion to 22 or higher


  2. Add the following dependencies to build.gradle for your app to add the wearable support library.
     dependencies {
        compile 'com.google.android.support:wearable:1.2.0'
        provided 'com.google.android.wearable:wearable:1.0.0'
     }


  3. Add the wearable shared library entry into the wearable app manifest:
    <application>
      <uses-library android:name="com.google.android.wearable"
                    android:required="false" />
      ...
    </application>
    



  4. Add the WAKE_LOCK permission to the handheld and wearable app manifest:
    <uses-permission android:name="android.permission.WAKE_LOCK" />



  5. Have your Activity extend WearableActivity. This will provide the overrides that notify your app when the wearable enters, exits and provides screen updates in ambient mode.



  6. In the onCreate() method of your activity, call the setAmbientEnabled() method. This tells the framework that the app should enter ambient mode rather than returning to the watch face.


  7. Set your map to support ambient mode. You can do this by setting the attribute map:ambientEnabled="true"
in the activity's XML layout file, or programmatically by setting GoogleMapOptions.ambientEnabled(true). This informs the API to pre-load necessary map tiles for ambient mode.



  • When the activity switches to ambient mode, the system calls the onEnterAmbient() method in your wearable activity. Override onEnterAmbient() and call MapFragment.onEnterAmbient() or MapView.onEnterAmbient(). The map changes to a non-interactive, low-color rendering of the map.




  • When in ambient mode, your app can update the display every minute by overriding onUpdateAmbient(). If you need more frequent updates, check out this guide.




  • When the activity leaves ambient mode, the system calls the onExitAmbient() method in your wearable activity. Override onExitAmbient() and call MapFragment.onExitAmbient() or MapView.onExitAmbient(). The map returns to the normal rendering and is now ready to accept user input.





  • With always-on maps on Android Wear, you can now show maps at a glance. For more information on these APIs check out the documentation and the sample code.

    Kamis, 19 Maret 2015

    Hello Places API for Android and iOS!



    Posted by Jen Kovnats Harrington, Product Manager, Google Maps APIs



    Originally posted to Google Geo Developers blog



    People don’t think of their location in terms of coordinates on a map. They want context on what shops or restaurants they’re at, and what’s around them. To help your apps speak your users’ language, we’re launching the Places API for Android, as well as opening a beta program for the Places API for iOS.



    The Places API web service and JavaScript library have been available for some time. By providing native support for Android and iOS devices, you can optimize the mobile experience with the new APIs by taking advantage of the device’s location signals.



    The Places APIs for Android and iOS bridge the gap between simple geographic locations expressed as latitude and longitude, and how people associate location with a known place. For example, you wouldn’t tell someone you were born at 25.7918359,-80.2127959. You’d simply say, “I was born in Jackson Memorial Hospital in Miami, Florida.” The Places API brings the power of Google’s global places database into your app, providing more than 100 million places, like restaurants, local businesses, hotels, museums, and other attractions.





    Key features include:



    • Add a place picker: a drop-in UI widget that allows your users to specify a place

    • Get the place where the user is right now

    • Show detailed place information, including the place’s name, address, phone number, and website

    • Use autocomplete to save your users time and frustration typing out place names, by automatically completing them as they type

    • Make your app stand out by adding new places that are relevant to your users and seeing the places appear in Google's Places database

    • Improve the map around you by reporting the presence of a device at a particular place.


    To get started with the Places API for Android, watch this DevByte, check out the developer documentation, and play with the demos. To apply for the Places API for iOS beta program, go here.