Geotagged Picasa JSON/KML Output + Driving Directions = Instant Scenic Tours!

Friday, June 29, 2007 at 10:24:00 AM

If you were following the Google blogs yesterday, you would have heard that Picasa now gives you a sleek drag+drop interface for geotagging your photos, and that the Picasa Google data API now outputs the geotagged data using GeoRSS & GML elements. And if you were excited by all that news and immediately visited Picasa to try out the new feature, you might have noticed the big blue KML icon next to a "View in Google Earth" hyperlink. So Picasa now gives developers geotagged photo data both in KML output and the standard Google data API output formats, and that means we map developers have a lot of ways to start playing around with Picasa photos. :)

To start off the Picasa-Maps mashups, I've put together an example that combines a Picasa photo album feed with the Map API's recently announced Driving Directions feature to calculate a driving route that will get you a similar set of photos. Now, no need to be jealous of your friends' pretty landscape albums - just copy them! Try it out below by clicking "Load Album & Route." If you want to be daring, you can try it out with your own geotagged photos by copying and pasting the "View in Google Earth" hyperlink into the box. Note that it will only work in the countries where driving directions can be calculated in the API.

How's it done? First, I pass the URL for the KML output into GGeoXML, which displays the photo markers and info windows. Then, I turn the URL for the KML output into the URL for the JSON output by replacing "alt=kml" with "alt=json-in-script", add a callback with "&callback=loadAlbumJSON", and append a script tag to the page with that new URL. When the JSON is loaded, I parse through it to find all the valid GeoRSS elements, and I add them to a waypoints array. I then use GDirections.loadFromWaypoints to get a route calculated between all the points. Once the directions has loaded, I enable the buttons that allow you to toggle the markers, route, or photos for a better view (I personally prefer no markers). If you want to delve into the code more, view source on the page. Enjoy!

Google Earth Outreach and KML Tutorials

Thursday, June 28, 2007 at 11:32:00 AM

Today, Google launched the Google Earth Outreach program to help non-profit organizations showcase their content in Google Earth using KML. This site is a great resource for non-profits, and also for the rest of us. These are some of the great resources on the site:

Check it out, there's something for everyone!

Validate your KML (Online or Offline!)

Tuesday, June 26, 2007 at 11:42:00 AM

KML is being widely adopted by applications like Mapufacture, ESRI ArcGIS, Yahoo Pipes, NASA WorldWind, Google Earth, Google Maps, Google Maps Mobile, Flickr and Platial. It's now more important than ever to make sure that your KML files are compliant with the KML standards. Here are two ways to validate your KML.

Online Validation with the Feedvalidator

Just go to feedvalidator.org and enter the URL of your KML. The Feed Validator will analyze your KML and where appropriate, will offer suggestions for how to improve your KML. Note that your KML files need to be on a publicly accessible URL to work with feedvalidator.org. If that is a problem for you, then you can install your own copy of Feed Validator (written in Python) and run it on your intranet. Feed Validator also handles RSS and Atom feeds, if you'd like to validate those as well.

Offline Validation with XML Schema

You can also validate your KML against the KML Schema . Many XML editors allow for schema validation, or you can download a validating XML parser like Xerces, libxml and validate your KML on the command line or from within your applications.

Try out the FeedValidator below!

Three new KML resources up

Tuesday, June 19, 2007 at 11:41:00 AM

There are three new useful resources up for those of you who are working with KML (or thinking about working with KML!)

First, there we've added a page to the KML documentation on Google Search for KML Files and GeoRSS Feeds. This guide takes you through the basic ways to make your geo content discoverable by Google, so that it will show up in searches in Google Maps or Google Earth as user-generated content. In particular, it discusses the inclusion of the ATOM elements author and link in KML documents for attribution. You might also want to check out the Developer Day presentation by Pamela Fox and Lior Rion on geo Search and using KML and GeoRSS in the Maps API.

As Pamela mentioned in that presentation, I recently posted an article on Using PHP and MySQL to create KML. This tutorial walks you through creating a MySQL database table, populating it with data, using PHP (4 or 5) to transform it into KML, and overlaying it on a map. This is a useful tutorial if you are storing data in a database and want to show it in Maps or Google Earth, or even just output it for indexing by Google.

Last, Google has published the beta documentation for KML 2.2. New features include PhotoOverlay, ResourceMap, and maxSessionLength.

v2.82: Set Country/Viewport Restrictions in your GClientGeocoder for More Tailored Results

Monday, June 18, 2007 at 6:46:00 PM

In the latest v2.82 release of the API, we've added 2 additional functions to the GClientGeocoder: setViewport, and setBaseCountryCode. These two functions will help you instruct the geocoder to prefer results within a certain area or country (but not to restrict the results).

In the example below, you can test out the influence of setBaseCountryCode. Enter a country code in the first box and the address in the second, and then change the country code and see if the result changes. The 2-character country code must be ISO-compliant and correspond to a Google Maps domain (e.g. "US" for google.maps.com, "AU" for google.maps.com.au). Hint: Try out "Syracuse" for "IT" vs. "US" or "Toledo" for "ES" vs. "US".

In this next example, you can test out the influence of setViewport, which is typically more powerful than setBaseCountryCode. Here, I've modified the just-released DragZoomControl to let you continually drag rectangles on the map. After you've finished drawing a rectangle, it will pass the GLatLngBounds of that rectangle to GClientGeocoder.setViewport, and then fire off a request to geocode the address in the text box. Try dragging rectangles of various sizes for the same address to understand the full effect of setViewport.

Note: Remember that you'll need to specify v=2.x in your script tag to use the new functions for the next few weeks, since they're new features. More information on API script versioning is here.



API v2 Latest (v=2.x): 2.82
API v2 Default (v=2): 2.81

Add Traffic to Your Mashup (Button + Legend, too)!

Friday, June 15, 2007 at 11:31:00 AM

When traffic was released in Google Maps to the celebration of cranky drivers everywhere, API developers immediately asked if they could include this useful overlay in their maps as well. Well, we heard the call and quietly released GTrafficOverlay in the API v2.81 (along with driving directions). The following line of code will add the traffic overlay to your map, which will show colored lines on major roads indicating traffic speeds wherever data is available:

map.addOverlay(new GTrafficOverlay());

Now that you've happily got Traffic on your map, you may be wondering how to add the Traffic button to your GMapTypeControl. The traffic button option isn't available through the API, but is now available through the open source Google Maps API Utility Library in ExtMapTypeControl. In this GControl extension, you have the option (through options sent in the constructor) to mimic GMapTypeControl exactly, add a Traffic button to it, or add a Traffic button that includes a drop-down legend. The drop-down legend may help your users understand what the colored traffic lines indicate, as found in the Google Maps help.

Here's an example of ExtMapTypeControl with the traffic button and legend:

You can also use ExtMapTypeControl as a basis for creating a GMapTypeControl customized to your website's look&feel. Just download it to your server, tweak the styles used for the buttons, and presto - a GMapTypeControl all your own.

Enjoy, and please let us know in the forums if you run into any issues with GTrafficOverlay or ExtMapTypeControl.

LocalSearch Control: Letting users search your map just got easier (and slick looking)!

Tuesday, June 12, 2007 at 1:19:00 PM

Over at the AJAX Search API blog, they've announced the LocalSearch control for Maps API sites. This is a nifty GControl extension that adds a search box to your map. When visitors to your maps mashup enter a query, the local business results from Google are plotted on the map (and optionally, in a list overlaid on the map). The best part is that you can add this Local Search Control to your map with just one line of code:

map.addControl(new google.maps.LocalSearch());

If you have questions about the AJAX Local Search API, please post in their forum. If you have any questions about Google Maps API or creating your own custom controls, please post in the Maps API forum. Enjoy making searching easier for your mashup users!

Got a Maps Mashup? Make it a Mapplet!

Thursday, June 07, 2007 at 1:39:00 PM

Hopefully, all of you maps developers out there have heard of Mapplets (through the blog post, Where2.0 announcement, or Developer Day talks). Mapplets are Google Gadgets that are made especially so that they can be loaded by a user on maps.google.com, and have access to the main shared map. Users can load multiple Mapplets simultaneously for a quick and easy way to mashup content from multiple sources - like loading the ChicagoCrime mapplet with a housing search Mapplet to help them buy a house in a burglary-free part of town. You can check it for yourself at:
maps.google.com/preview

So why would you, the developer, want to convert a Maps API mashup into a mapplet? Here are a couple reasons to motivate you:

  • Mapplets help you instantly reach millions of Google users. Just as with normal Google Gadgets, users can browse through the Mapplet gallery to find what interests them. Once they've added a Mapplet, it gets bookmarked in their Mapplets tab so they can quickly load it each time they visit Google Maps.
  • Mapplets are hosted on Google servers, so those millions of users can use your Mapplet without you having to worry about server bandwidth. The Google Gadgets infrastructure handles fetching content for you and provides aggressive caching and server side storage of user state for you. Code an amazing Mapplet, and Google will take care of distributing it to the world for you.
  • Mapplets are a great vehicle for driving traffic to your main mashup. A user casually tries out your Mapplet, finds some useful information, and then decides to visit your main site for a more in-depth experience. If driving traffic to your site is a motivation, you may want to include a linked logo in your Mapplet, and describe what additional features are available on your main site.

Now that you're ready and eager to create a Mapplet version of your site, skim through the Mapplets documentation and check out the just released "Converting a Maps API Mashup into a Mapplet" conversion guide. Let us know in the forums if you run into any issues in converting your site into a Mapplet, or just post a link to let everyone know about your cool Mapplet. We look forward to seeing the thousands of Maps API mashups out there represented in the Mapplets directory.

DragZoomControl v1.0: Easier zooming, coming right up!

Wednesday, June 06, 2007 at 10:00:00 PM

Do you ever have the experience where you're sitting there staring at a map, and you know exactly the area you want to zoom onto, but it takes you 3 double clicks, 5 pans, and some scroll wheel action to get there? At those times, I always wish I had something which would let me just drag a rectangle on the map to zoom in.

Luckily, developer Andre Lewis realized the need for a drag-to-zoom control last year and introduced GZoom to the community, with a great response. The GZoom control is now named DragZoomControl and is the latest offering in the Google Maps API Utility Library open source project. In the library, you'll find full documentation, multiple examples, and even a compressed version of the javascript source for the bandwidth-wary. DragZoomControl is highly customizable (check out this interactive options playground for it) - but if you need to customize even more, just download the source to your server and tinker to your heart's delight!

Below is an example that combines the open-sourced MarkerManager with DragZoomControl for a rather pleasing drag-to-zoom-to-discover-more-markers experience. Click the magnifying glass to get your drag on. (Note: Weather markers are randomly generated- so don't be surprised if you see a sunny London!)

As always, please report any issues you find in the Maps API Google Group, and consider joining the open-source project if you'd like to work on extending DragZoomControl further.

New KML Developments and Documentation

Monday, June 04, 2007 at 8:51:00 AM

As we announced at Where 2.0 and Google Developer Day, there are two exciting new developments in KML.

  1. There's new documentation, at code.google.com/apis/kml. For instance, we now have a page on Google's search for KML files, and how to best publish your KML files so that Google will index them. In particular KML will be extended to include Atom Syndication format atom:author and atom:link elements for attribution. This will allow you to assign attribution to your KML files on a Feature by Feature level. Google chose to use the Atom elements because of our commitment to open standards.
  2. There's a new beta reference for KML 2.2. This is in a very early stage, and Google Earth and Maps do not yet support new elements in KML 2.2, but it gives you an idea what we're thinking about. Particularly, check out the references for PhotoOverlay, Camera, and the new Atom elements in Feature.

Developer Day Maps API + KML Recap

Saturday, June 02, 2007 at 6:00:00 PM

  1. Maps API Introduction

    This presentation was given for all those attendees who were new to the Maps API. Speakers worldwide demonstrated how easy it is to create a map, and how powerful the API is. Check out the talks in Mountain View, São Paulo, Tokyo, Beijing, or Sydney. You can also go through the interactive slideset.

  2. New Maps API Features

    This week we released v2.81 of the Maps API, and with that came two new features: traffic and driving directions (one of the most requested API features). In the session, we demonstrated the simple and sophisticated uses of the new GDirections, GRoute, and GStep classes. We also discussed features introduced in the past year, and an upcoming feature that will let developers monetize their maps more easily. Check out the talks in London, or Mountain View. You can also go through the interactive slideset.

  3. Mapplets

    At this year's Where2.0, the conference for the geo community that took place right before our own Google Developer Day, we announced Mapplets. Mapplets let users mash together the Google Gadgets API with the Google Maps API to create mini maps applications that users can embed onto one shared map on maps.google.com. Mapplets are a good thing for users as they'll be able to easily combine data from mashups together by loading multiple mapplets, and they're a great thing for developers as they'll expose more the huge Google Maps user base to your mashups. Check out the talks in Mountain View, Tokyo, Moscow, Sydney.

  4. KML

    In the KML presentations, we announced the KML2.2 schema and discussed new features like attribution, which helps Google respect authorship when indexing your KML files. Check out the talks in Mountain View, São Paulo, Sydney, Madrid, Hamburg, or Paris.

  5. geo search:

    In a US-only session titled "geo search & KML/GeoRSS in Mashups," we announced that Google geo search (formerly known as KML search) will now index GeoRSS files, and that it would respect attribution in both formats. We then discussed techniques for using GeoRSS/KML in mashups. If you're a mashup developer looking to increase traffic to your website, you should check out the tips in this presentation. Check out the talk.