Posted:
Author Photo
Last week Felipe and Michael from the Google Cloud Platform Developer Relations team released a video demonstrating the new Pearson correlation analysis available in Google BigQuery. Their example used more than 70 million flight records to find correlations on departure times, which could be used to predict whether your plane would be late. Specifically, you can find out which set of airports best predict your airport’s possible flight delays the following day.

As you can see from their code (watch the video for context), they’re using iPython Notebook to work with the BigQuery results, and matplotlib to get a quick visual of results. But one aspect that’s hard to see in these results is the spatial relationship of the airports. Maps to the rescue!

My goal was to create a simple visualization, where selecting any airport would highlight which airports you should look at to predict delays the next day. Using the Google Maps JavaScript API I went ahead and did just that:




To create this map, using the same code noted above, we first created a JSON dump of the correlations on departure time for each airport to each other airport. Then, using an article on visualizing earthquakes as a template, I modified the code so that we have a simple dictionary of all airports, keyed by their airport id. Last but not least, I added a function that gets called when an airport marker is clicked in order to restyle all the other airport markers according to their correlation. This method checks the selected season (winter, for example, has different correlations than spring), and highlights correlated markers by setting the color and scale of the circle symbol.


Thanks to BigQuery, running complex correlations over billions or trillions of attributes is surprisingly easy. But don’t forget if your data does have some spatial component, a quick mapping visual can add some great context to your results.

Posted by Josh Livni Maps Developer Relations Team

Posted:
This week we are pleased to announce updates for the Google Maps Android API v2 and the Google Maps SDK for iOS. We’re listening to your feedback, adding features requests that you’ve starred more than 195 times on the issue tracker. This includes cross platform support for map padding, flat markers, and marker rotation, described in the video below:



Full screen maps with map padding
Want to add a translucent Action Bar overlay to your map in Android? Or use a full screen layout in iOS 7? Map padding makes it easy to create full screen maps with custom interface overlays. Google Maps UI controls and attribution will automatically be repositioned in the visible area, and changes to the map camera take padding into account, so you don’t need to do this yourself.


Full screen layout maps are more immersive on Android (left) and iOS 7 (right).

Give your markers a sense of direction
We’ve added a marker rotation property, to allow you to rotate a marker around it’s anchor point. The new flat property allows you make the marker lie flat on the map surface, rather than popping out to face the camera. These two new properties are especially useful for indicating compass directions when the map is rotated or tilted.

Marker animations come to iOS
Time to make your markers move! There are a few ways to animate markers on Android, and today we’re adding the ability to animate marker position and rotation on iOS using the Core Animation framework. Animation for these properties happens automatically, but this can be customized if you’d like something a little different, or turned off entirely. You can also animate the icon of your marker using the existing images and duration properties of UIImage.


Playback GPS routes using flat markers (left), or use animated marker icons (right, iOS only).

Platform specific updates
The latest version of the Google Maps SDK for iOS now officially supports iOS version 6 and above, adding support for iOS 7, and removing support for iOS 5.1. Those of you running maps on mathematically intensive applications will be glad to know we have added ARMv7s support (and we’re investigating ARMv8 as well). For the the full list of new features and bug fixes see the Android and iOS release notes.

We’re rapidly adding new features, so if you had your fingers and toes crossed for a feature that isn’t in this release, please let us know on the issue tracker. Lastly, if you have any technical questions that aren’t answered in the developer documentation, post them to the Google Maps Developer Community on Stack Overflow.

Posted:
In this guest blog post, we hear from Adam Ratana, a hobbyist photographer and software engineer by day, and developer of the Android and iOS Sun Surveyor apps by night. In this tutorial, Adam talks about his creative implementation of custom polylines on Street View panoramas in the Google Maps SDK for iOS.

 As a photography enthusiast, I’m always looking to capture images at the magic hour. My goal when creating Sun Surveyor was to give users an immersive way of visualizing the location of the sun and the moon, making it easy for anyone to figure out when the natural lighting is just right for the perfect shot.

When I set out to build Sun Surveyor, I knew I wanted to give users an easy way of visualizing the location of the sun and the moon. Sun Surveyor has an augmented reality (AR) feature, which overlays sun and moon paths on top of the device camera’s view. This is useful for understanding how light will change over time at a particular location. While I also created a Map View to show the paths on a Google Map for remote locations, it was not as intuitive as augmented reality.

Visualizing the sun and moon paths in augmented reality and map views

When Street View launched in the Google Maps SDK for iOS in v1.4.0 (July, 2013), I couldn’t wait to visualize the sun and moon paths within an interactive panorama. Street View panoramas bridge the gap between Sun Surveyor’s Map View and AR experiences by giving users an augmented reality experience, wherever they want to go.

Sun and moon paths with Street View panoramas

Implementing a sun path Overlay on Street View
I took a creative approach to working with the Google Maps SDK for iOs.  While polylines can be implemented in Map View, this isn’t yet possible in a Street View panorama. To display paths and other items that move with the Street View panorama, I needed to:
  1. Create an overlay on top of the panorama upon which to draw the items
  2. Synchronize the positions of the overlay items with the panorama as it moves
  3. Determine which data are visible and where on the screen to draw them
For this tutorial, I have provided a sample project that will get anyone started doing the same. Let’s walk through the steps.

I. Creating an Overlay

In our main UIViewController, we add a subclass of UIView for the overlay, make its background color transparent, and place the GMSPanoramaView below it in the view hierarchy.


Representing Overlay Items
We represent the overlay items with a protocol having two methods: updateWithPanoramaView and draw. The updateWithPanoramaView method updates an item’s screen location geometry, while draw draws it to the current graphics context.

We store all items to be drawn in a collection, update their positions based on the panorama position, and draw the collection in our view’s standard drawRect method.

If we want to make sure these items are drawn in a certain order that might change based on the data, we can add z-indexes to them and then sort the collection by z-index after we update them and before drawing.

II. Syncing the Overlay with the Panorama
To make sure this overlay view stays updated as the panorama moves beneath it, we can update the view’s data in an implementation of GMSPanoramaViewDelegate’s didMoveCamera method. We can use a CADisplayLink to ensure the overlay view is redrawn at regular intervals, and use a flag to make sure it is only redrawn when necessary.


Optimization
CoreGraphics can be a bottleneck. [UIBezierPath strokePath] and [NSString drawAtPoint] are expensive as you can see by profiling with Instruments. For performance intensive applications, an alternative is to use OpenGL. Avoiding overdraw is always a good idea, so the first optimization, if needed, is to carefully examine what is being drawn to the screen, and draw only what is necessary.

III. Mapping data to the panorama view
The GMSProjection class has a pointForCoordinate method that returns the screen pixel location for a coordinate on the Map. This is useful for overlaying elements on top of a GMSMapView, and is used in the Sun Surveyor Map View to draw text related to sun and moon paths on top of the Map.

GMSPanoramaView has a similar method, pointForOrientation. This method allows us to query the panorama for a screen pixel location given a GMSOrientation (bearing and pitch tuple) relative to the panorama location, where the camera is stationed, at ground level. This is useful to make sure an item we overlay onto the view remains in the same location relative to the scene, even as the camera moves and the view shifts.

Because the camera has a Field of View that determines what is visible on the screen, some orientations are not visible (such as behind the camera position). pointForOrientation helpfully returns NAN (not a number) for such orientations, so we know the given orientation is not visible.

With sun path data already expressed in terms of orientation relative to the ground level of the viewer, drawing corresponding paths with screen pixel locations is easy. We map our data with pointForOrientation, and draw what is visible by checking the result for NAN.



The sample project uses a panorama of Sydney, Australia, looking west, with a sun path for 12/20/2013.


Bonus: altering the Field of View
Version 1.4.1 of the SDK added support for changing the GMSPanoramaCamera’s field of view (FOV). The field of view determines how much of the scene is visible on a device screen, as well as how much distortion around the edges of the view is present. Smaller values for FOV are the equivalent of having a telephoto lens on a real camera: it brings distant objects closer.


Left: FOV of 60 degrees. Middle: 90 degrees (default). Right: 130 degrees.


Street View Panoramas are awesome and easy
The Street View panorama viewer in the Google Maps SDK for iOS is an example of a great API. The GMSPanoramaView class is simple to understand and use. In the course of a weekend, I was able to deliver a fun, interactive and highly requested feature to Sun Surveyor’s iOS users. I can’t wait to see what people are able to do with this new Street View Panorama feature in my app, and I look forward to seeing all the other implementations that others develop!

Stonehenge, as seen from a Street View panorama in Sun Surveyor


Posted by Monica Tran, Google Maps API

Sun Surveyor visualizes the sun and moon in a variety of ways for photographers, filmmakers, solar industry professionals, architects, homebuyers, gardeners, and anyone needing to predict or understand the movement of the sun and moon.

Adam Ratana is a Carnegie Mellon University graduate living in, and loving, Pittsburgh, PA. He produces dance music as a member of Pittsburgh Track Authority, enjoys photography, traveling with his wife, and writing fun software in his free time. Adam also enjoys attending the Pittsburgh Cocoaheads chapter meetings.

Posted:
Author Photo
It’s been a few weeks since the last Fab Friday post. The team has been hard at work on a couple of new videos for you. Take a look:

First up is The Mobile Experience, a new series where Paul Saxman talks about mobile map design. In this episode, Paul talks about building a smartphone interface for browsing a collection of places on a map that can be browsed one handed.


Paul posted his Google Maps Android API v2 code on GitHub.

Next up, we have an episode of DevBytes: Maphacks on animating markers. Ankur Kotwal and Chris Broadfoot talk about the latest techniques for marker animation on the Google Maps Android API v2.


That’s all for this week, have a great weekend and happy mapping!

Posted by Mano Marks, Maps Developer Relations Team