We’re always interested to hear how you’re using the Maps APIs, so let us know if you’ve got something cool to show by tagging +Google Maps API on your posts (or comment right here!). For technical questions that aren’t answered in the developer documentation, check out the Google Maps developer community on Stack Overflow. Don’t forget to tell us what you’d like to see in the next release using the Google Maps API issue tracker.



Posted by Daniel Schramm, Associate Product Manager, Google Maps Mobile APIs A new version of Google Play services is currently rolling out to devices. You can start developing for it now using the latest Google Play services SDK along with the new Android 4.4 (KitKat) emulator. Read on to find out about the new features added for the Google Maps Android API v2.





Whether your app tracks ghost sightings, shows witch flight paths, or guides users to the nearest zombie-proof safehold, sometimes the best way to highlight important information is to de-emphasise some elements of your app. The new alpha property for Markers allows you to fade markers in and out as they become more or less important.



You can further tailor the map to your use case using the new setBuildingsEnabled() method to control the visibility of 3D buildings. This is especially useful when you want to highlight your own content. We’ve also made it possible to easily change ground overlay images with the new setImage() method.





Lastly, we’ve added an OnMapLoadedCallback callback interface to notify you when the map has finished rendering. The following example code shows how this callback can be combined with the snapshot feature to ensure the snapshot captures the fully rendered map:



We’re always interested to hear how you’re using the Maps APIs, so let us know if you’ve got something cool to show by tagging +Google Maps API on your posts (or comment right here!). For technical questions that aren’t answered in the developer documentation, check out the Google Maps developer community on Stack Overflow. Don’t forget to tell us what you’d like to see in the next release using the Google Maps API issue tracker.



Posted by Daniel Schramm, Associate Product Manager, Google Maps Mobile APIs

You’ll notice that we’re not including the actual fragment in the layout - we add the Fragment at runtime, because we don’t want to pay the cost of the fragment transaction and add all the markers on the map, unless the user requests it.



You’ll also notice a bit of a hack at the bottom of the layout. In testing, we found that the MapFragment would leave a black box artifact on the screen on certain devices when the user opened our sliding menu navigation. Adding a simple FrameLayout “above” the map seems to fix the problem.



Extending SupportMapFragment makes it much easier to separate the map display logic from our Activity and list fragment. Our SupportMapFragment (and its inner classes) is responsible for:


  • Adding markers representing each available hotel

  • Customizing the GoogleMap UI options

  • Centering and animating the map to show the added markers

  • Showing an info window when a marker is clicked

  • Launching an Intent to display more details when an info window is clicked


Next up, we’ll talk about how we add markers to the map and keep memory usage down.



Managing Markers

One of the challenges in migrating from v1 to v2 of the Google Maps Android API was figuring out the best way to know which hotel’s info to display when a marker is tapped. To solve this, we place each <Marker, Hotel> pair in a HashMap when adding the markers to the Google Map. Later, we can use this HashMap to look up a marker's corresponding hotel info.



The code snippets below illustrate how we do it.






This HashMap allows us to look up the selected hotel in our InfoWindowAdapter, enabling us to display more information about it.






We place quite a few markers on the map for hotel results and each marker can have a different custom image. It's really easy to run out of memory and we were getting quite a few OutOfMemoryExceptions early in development. To manage memory more effectively, we made sure we didn't create a new new Bitmap and BitmapDescriptor for every marker placed on the map. We also ensured that the resources were recycled after we were done with them.






When the user taps a marker, we want to show more information; that’s where info windows come in handy.





Introducing Info Windows


Aside from simply viewing the location of all available hotels on a map, users are typically interested in the name and price of the hotel. The architecture for implementing this information window changed considerably from version 1 to version 2 of the Google Maps Android API.








Before: Info windows in the Google Maps Android API v1





When using v1 of the Google Maps Android API, our app displayed more detailed hotel information in a custom info view when the user tapped on a hotel marker. That custom view displayed the hotel name and price, and triggered a custom animation when the view was added to the screen. This animation made it appear that the view was growing from inside the pin on the map.





We achieved this effect by setting the LayoutParams to MapView.LayoutParams.BOTTOM_CENTER and MapView.LayoutParams.MODE_MAP, which centered the bottom of the custom view on top of the tapped hotel marker.





With the introduction of the Google Maps Android API v2, MapView.LayoutParams.MODE_MAP was removed, so we explored alternative treatments to show the hotel information when the user clicks on a result. For our purposes, the best alternative was to use the new info window interface.







After: Info windows in the Google Maps Android API v2




Creating an InfoWindowAdapter is pretty straightforward. The API provides two ways to populate the info window; either by supplying the contents of the info window (shown in the default window stylec) or creating a full View. Because we wanted to have a custom window background, loaded from a 9-patch, we opted to build a complete View for the info window by overriding the getInfoContents() method to return null, and by returning a custom View from getInfoWindow().





Here’s a sample of our code:







We could further simplify this code by having our HotelView take a Hotel model as a parameter in the constructor.





A caveat with info windows is that even though they are populated by the returned View, the info window is not treated like a *live* View object. The system will call the view’s draw() method only once, then use that cached rendering as the user continues to interact with the map. Our existing animation didn’t work in the Google Maps Android API v2, but we decided to be consistent with the platform and remove the animation rather than try to hack around this limitation.





We <3 Google Maps Android API v2


Upgrading from version 1 to version 2 of the Google Maps Android API was virtually painless and fun to do! The introduction of MapFragment helped us separate the map display logic from the rest of the code and made code reuse much easier. Using custom info views was very straightforward with the new info window interface. We look forward to adding even more Google Map features to our app.



Posted by Monica Tran, Maps Developer Marketing



Monika Szymanski is a Lead Engineer on the Android team at Orbitz, where she works on apps that are friendly, fast, and easy to use. In her free time, she enjoys outdoors, running, red wine, and anything chocolate.



Mike Kelley is a Software Engineer at Orbitz, where he works on Android travel tools to help people travel smarter. He's a Michigan grad, transportation and technology enthusiast and craft beer buff. Some of Mike's ideas and projects live online at theelfismike.com.



Orbitz Worldwide (NYSE: OWW) is a leading global online travel company that uses innovative technology to enable leisure and business travelers to search for, plan and book a broad range of travel products and services including airline tickets, hotels, car rentals, cruises, and vacation packages. Orbitz Worldwide owns a portfolio of consumer brands that includes Orbitz, CheapTickets, ebookers, and HotelClub. Also within the Orbitz Worldwide family, Orbitz Partner Network delivers private label travel solutions to a broad range of partners including many of the world's largest airlines, and Orbitz for Business delivers managed corporate travel solutions for corporations.

In today’s guest blog post, we hear from Monika Szymanski and Mike Kelley, of Orbitz' Android engineering team, who recently migrated from version 1 to version 2 of the Google Maps Android API.





About Orbitz

Nearly 30% of Orbitz.com hotel bookings are now made via mobile devices, fueled in part by the growth of the Android platform. The recently released 3rd-generation update of the Orbitz - Flights, Hotels, Cars app for Android brings major speed and ease of use improvements along with the latest Android UI design patterns to the app. The Google Maps Android API v2 is also integrated into the hotel search experience. Read on to find out how we did it, with tips and sample code along the way.



Migrating from v1 to v2 of the Google Maps Android API

While users of the Orbitz.com Android app will notice some changes to the app’s user interface for maps, the changes to our code are more than skin deep. New classes offered in v2 of the Google Maps Android API like MapFragment and SupportMapFragment, the transition from ItemizedOverlays to Markers, and the addition of a well-supported info window pattern have made including a Google Map in an Android app much easier.





Say hello to the 3rd generation of Orbitz - Flights, Hotels, Cars app, using the Google Maps Android API v2




Featuring Fragments

Prior to the introduction of MapFragment (and SupportMapFragment) in v2, we had to write a lot of code to manually show/hide the map view in our app. Only one instance of MapView could be created per activity, so we had to be overly clever about persisting that instance in our Activity. Lack of proper Fragment support was a common pain point for developers integrating v1 of the Google Maps Android API in their application.



When Fragment support was added in v2, we essentially rewrote our map code to take advantage of the new features of MapFragment. Let’s start by taking a look at our hotel results Activity layout:



You’ll notice that we’re not including the actual fragment in the layout - we add the Fragment at runtime, because we don’t want to pay the cost of the fragment transaction and add all the markers on the map, unless the user requests it.



You’ll also notice a bit of a hack at the bottom of the layout. In testing, we found that the MapFragment would leave a black box artifact on the screen on certain devices when the user opened our sliding menu navigation. Adding a simple FrameLayout “above” the map seems to fix the problem.



Extending SupportMapFragment makes it much easier to separate the map display logic from our Activity and list fragment. Our SupportMapFragment (and its inner classes) is responsible for:


  • Adding markers representing each available hotel

  • Customizing the GoogleMap UI options

  • Centering and animating the map to show the added markers

  • Showing an info window when a marker is clicked

  • Launching an Intent to display more details when an info window is clicked


Next up, we’ll talk about how we add markers to the map and keep memory usage down.



Managing Markers

One of the challenges in migrating from v1 to v2 of the Google Maps Android API was figuring out the best way to know which hotel’s info to display when a marker is tapped. To solve this, we place each <Marker, Hotel> pair in a HashMap when adding the markers to the Google Map. Later, we can use this HashMap to look up a marker's corresponding hotel info.



The code snippets below illustrate how we do it.






This HashMap allows us to look up the selected hotel in our InfoWindowAdapter, enabling us to display more information about it.






We place quite a few markers on the map for hotel results and each marker can have a different custom image. It's really easy to run out of memory and we were getting quite a few OutOfMemoryExceptions early in development. To manage memory more effectively, we made sure we didn't create a new new Bitmap and BitmapDescriptor for every marker placed on the map. We also ensured that the resources were recycled after we were done with them.






When the user taps a marker, we want to show more information; that’s where info windows come in handy.





Introducing Info Windows


Aside from simply viewing the location of all available hotels on a map, users are typically interested in the name and price of the hotel. The architecture for implementing this information window changed considerably from version 1 to version 2 of the Google Maps Android API.








Before: Info windows in the Google Maps Android API v1





When using v1 of the Google Maps Android API, our app displayed more detailed hotel information in a custom info view when the user tapped on a hotel marker. That custom view displayed the hotel name and price, and triggered a custom animation when the view was added to the screen. This animation made it appear that the view was growing from inside the pin on the map.





We achieved this effect by setting the LayoutParams to MapView.LayoutParams.BOTTOM_CENTER and MapView.LayoutParams.MODE_MAP, which centered the bottom of the custom view on top of the tapped hotel marker.





With the introduction of the Google Maps Android API v2, MapView.LayoutParams.MODE_MAP was removed, so we explored alternative treatments to show the hotel information when the user clicks on a result. For our purposes, the best alternative was to use the new info window interface.







After: Info windows in the Google Maps Android API v2




Creating an InfoWindowAdapter is pretty straightforward. The API provides two ways to populate the info window; either by supplying the contents of the info window (shown in the default window stylec) or creating a full View. Because we wanted to have a custom window background, loaded from a 9-patch, we opted to build a complete View for the info window by overriding the getInfoContents() method to return null, and by returning a custom View from getInfoWindow().





Here’s a sample of our code:







We could further simplify this code by having our HotelView take a Hotel model as a parameter in the constructor.





A caveat with info windows is that even though they are populated by the returned View, the info window is not treated like a *live* View object. The system will call the view’s draw() method only once, then use that cached rendering as the user continues to interact with the map. Our existing animation didn’t work in the Google Maps Android API v2, but we decided to be consistent with the platform and remove the animation rather than try to hack around this limitation.





We <3 Google Maps Android API v2


Upgrading from version 1 to version 2 of the Google Maps Android API was virtually painless and fun to do! The introduction of MapFragment helped us separate the map display logic from the rest of the code and made code reuse much easier. Using custom info views was very straightforward with the new info window interface. We look forward to adding even more Google Map features to our app.



Posted by Monica Tran, Maps Developer Marketing



Monika Szymanski is a Lead Engineer on the Android team at Orbitz, where she works on apps that are friendly, fast, and easy to use. In her free time, she enjoys outdoors, running, red wine, and anything chocolate.



Mike Kelley is a Software Engineer at Orbitz, where he works on Android travel tools to help people travel smarter. He's a Michigan grad, transportation and technology enthusiast and craft beer buff. Some of Mike's ideas and projects live online at theelfismike.com.



Orbitz Worldwide (NYSE: OWW) is a leading global online travel company that uses innovative technology to enable leisure and business travelers to search for, plan and book a broad range of travel products and services including airline tickets, hotels, car rentals, cruises, and vacation packages. Orbitz Worldwide owns a portfolio of consumer brands that includes Orbitz, CheapTickets, ebookers, and HotelClub. Also within the Orbitz Worldwide family, Orbitz Partner Network delivers private label travel solutions to a broad range of partners including many of the world's largest airlines, and Orbitz for Business delivers managed corporate travel solutions for corporations.


Map of the Week: Citymapper Android App


Why we like it: Citymapper is a great example of combining Google’s data and basemap with an app developer’s own data and making a slick, useful interface. Citymapper helps Londoners get around by showing them locations of tube stations, bus routes, taxi fares, the status of transit lines, and much more. It’s built on top of the Google Maps Android API v2 and our Directions and Geocoding services.






It all starts with figuring out what you want to do.







From there you can get walking, biking, transit, or taxi directions. It’ll even tell you how many calories you’ll burn, or how much the taxi should cost.








You can also get information on Tube closures.








And play with a rampaging Android.







You can save your favorite lines and stations in the app as well, allowing you to customize your experience. All around, this is a great combination of our maps with highly localized data.






Posted by Mano Marks , Maps Developer Relations Team


M(app) of the Week: Airbnb for Android



Why we like it: In addition to getting a visual and functional refresh and Google Wallet integration , the Airbnb app for Android now includes some advanced map marker features, such as custom marker images and marker clustering . The Airbnb team added these features to their app using the Google Maps Android API v2 .











When searching for a place to stay, each location is displayed on a map with a marker indicating its price per night. Using custom marker images to show additional information on the map helps users make decisions based on multiple, important variables (e.g. price and location) more rapidly. With the Maps API, you can create custom markers from bitmaps that you dynamically draw or load over the wire, or from static assets that you package with your application.









The Airbnb app also uses the Projection class to determine which markers would visually overlap, and replaces them with a single cluster marker that shows how many places it represents. Marker clustering allows developers to control the visual complexity of the map and improve app performance by reducing the number of makers that are displayed simultaneously. As the user interacts with the map, the marker clustering dynamically changes, which is a great experience for exploring the information displayed on the map.



Marker clustering is also a excellent technique for capturing a third important piece of information about places, which is density. In the above map of San Francisco, you can see that there are a number of Airbnb places listed in the Mission and Noe Valley neighborhoods, which might indicate that these are interesting places to visit and explore (they are!).



If you want to read more about the technical and visual enhancements that the Airbnb team made to their Android app, be sure to visit their Nerd Blog !



Posted by Paul Saxman , Maps Developer Relations Team

[Mano Marks is away for the holidays, so this week Paul Saxman shares the highlights of the week in this Fab Friday post.]



<Begin Festive Jingle>



On Tuesday, a team of Google engineers launched the Google Santa Tracker site along with a Chrome extension and an Android app . You can visit the site now to play Santa approved games and hunt for some other fun experiences, but be sure to check out the site and Android app on Christmas Eve to track Santa with Google Maps and Google Earth.







The Google Santa Tracker site is pure HTML5 and uses the Google Maps JavaScript API . The Android app uses the recently released Google Maps Android API v2 , so be sure to try out Santa tracking in vector-based 3D!









Late last week, I joined Ankur Kotwal and Tony Chan on their ADL+ show to discuss how to get started with the Google Maps Android API v2. We covered the basics of how to get a Google Maps API key, configuring an app’s manifest, controlling the map camera, and using markers and info windows. The slides for the show, which include plenty of code snippets, were posted separately.






If you’re craving even more code, support for the Google Maps Android API v2 was recently added to the the open source My Tracks app for Android . My Tracks uses many of the key features of the API, including markers, camera events, and polylines. If you’re interested in the new API, the MyTracksMapFragment class is a great place to start browsing the code.



Also in the news , Red de Juderías de España has built a website for exploring more than 500 Jewish heritage landmarks in Spain. The interactive map on the site uses the Google Maps JS API and includes custom map styling , overlays , and Street View panoramas . The site is a great inspiration to learn more about Spain’s Jewish history, and for building websites with beautiful interactive maps.



</End Festive Jingle>



Posted by Paul Saxman , Google Maps Developer Advocate and Adjunct Santa Helper

Map of the Week: Skyvi

Why we like it: Skyvi uses the Google Places API to help users find nearby points of interest while on the go. Users simply speak their request into their Android phone while Skyvi is running to get voice guided, turn-by-turn directions from the Google Maps for Android app.



[Editor’s note: For this week’s “Map of the Week” post, we’ve asked Sarah Montgomery of Blue Tornado to write a guest blog post about how her team used the Google Maps APIs to create Skyvi. - Paul Saxman]



Skyvi is a fast voice application for Android that lets you perform various tasks by voice input alone! Whether you want to find somewhere to eat or update your social network status, you can get things done by speaking to your phone.







Users can voice a command to find a point of interest such as 'find an Italian restaurant' or 'where can I get a haircut'. Skyvi then retrieves the user’s current GPS coordinates from the Android platform and queries the Google Places API with the search keywords and coordinates. The Google Places API returns a list of locations for the user to select from. Upon choosing a location, Skyvi uses an Android Intent to pass the GPS coordinates to Google Maps Navigation, which then directs the user along the route.



As a result, users are able to discover a point of interest and get seamlessly navigated there just by speaking commands. We are excited that, by incorporating the Google Places API into our app, our users no longer need to handle their phones or GPS devices while they drive.



It was quick and easy to integrate the Google Places API into our app, taking only a couple of hours. Google Maps saved us from investing in base map data, and the API allows us to suggest relevant search results based on Google's data, which is already used by millions of people.



Posted by Paul Saxman, Google Maps Developer Relations Team



(Cross posted on Google Maps Lat Long Blog)



Today we’re launching an update to the Google Maps Android API, which gives developers the ability to use Google’s comprehensive, accurate and useful maps to build beautiful Android apps. The updated API is easy to use and features vector-based maps that load quickly and enables users to easily navigate 2D and 3D views, and tilt and rotate the map with simple gestures.



With the new version of the Google Maps Android API, developers can utilize Google Maps to its fullest. We’ve incorporated many of the highly-requested features developers want, such as:


  • More dynamic and flexible UI designs for large screen Android devices, such as tablets, using Android Fragments



  • Adding more Google Maps layers in their apps including satellite, hybrid, terrain, traffic and now indoor maps for many major airports and shopping centers



  • The ability to create markers and info windows with less code


Some of our favorite apps already use Google Maps, such as Trulia, Expedia Hotels and FlightTrack. Soon, when you upgrade to the latest version of these apps, you’ll experience the new API and maps as rich as those in Google Maps for Android.








With the latest Google Maps Android API, Trulia Android app users can search for a place to buy or rent in 3D.



To hear from these developers about their apps and migration to the new version of the API, check out the following Google Developers Live video below.






More than 800,000 sites around the world use our mapping APIs to create amazing and useful apps. We hope you enjoy using this new addition to the Google Maps API family and building mapping experiences that were never before possible on a mobile device.



To get started, follow the Google Maps Android API v2 documentation and reach out to the developer community if you have questions on building your app with this API.



Posted by Andrew Foster, Senior Product Manager, Google Maps

Map of the Week: runtastic PRO

Why we like it: runtastic is using Google Earth to show a user 3D Earth View video playback of every run or GPS activity they track with runtastic PRO for Android. In addition to retracing a route, runtastic displays the time, pace, elevation, places of interest, and more. Users can also choose to review their activities with three zoom levels and three playback speeds.


[Editor’s note: For this week’s “Map of the Week” post, we’ve asked Stephan Brunner, Head of Android Development at runtastic, to write a guest blog post about what his team used to create runtastic Earth View - Paul Saxman]


Whether you’re running your first half marathon, biking across the Golden Gate Bridge, or hiking in Nepal, runtastic’s Google Earth playback feature allows you to hold on to the memory and imagery of your activity.


How do we make this happen? The runtastic app captures GPS coordinate data and transforms it into a KML file, and then starts the Google Earth app with an Android Intent, passing a reference to the file in the Intent URI. The Google Earth app loads the track and takes it from there.






The <gx:Track > and <gx:Tour > extension to KML are the perfect tools for making the new 3D experience happen. The <gx:Track> element contains the entire GPS data recorded by the runtastic app, and <gx:Tour> defines the camera animations, overhead view and angle. The Google Earth app matches the elements of both lists using the time-span information from each list element. The result is a smooth animation of the track being painted based on the data from a run, which makes the user feel like they’re flying along it!





With this great new 3D Earth View, we think that there is no reason to stay on the couch. Get out there and record some amazing activities!



Posted by Paul Saxman, Google Maps API Developer Relations Team

Just in time for your holiday coding enjoyment, we have three new articles to get you started on adding maps to mobile and using App Engine for spatial search.



Overview of Mobile Development Options for the Google Maps API

Putting a map on a phone seems natural these days. This article goes over the options for developing a Google Map for a mobile application.



Loading a Maps API site in a Native Android Application

Google Maps API Version 3 was designed to be used in a mobile environment. If you want to include a V3 page in a native Android application, this is how to get started.



Geospatial Queries with Google App Engine using GeoModel

Many developers are moving their applications to cloud computing. Here's how to get started with geospatial queries building on Google App Engine.



So enjoy your holidays, and I look forward to seeing your apps in January!



Posted by Mano Marks, Geo APIs team

AltStyle によって変換されたページ (->オリジナル) /