The Artima Developer Community
Sponsored Link

Java Buzz Forum
Google Maps says "Take That" to Powerpoint

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Google Maps says "Take That" to Powerpoint Posted: May 24, 2007 12:24 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Google Maps says "Take That" to Powerpoint
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement

A few of us were laughing at the powerpoint gurus that had fun with animating Google Maps markers for a presentation.

Then I realised that we can of course do animations with the Maps API itself!

I pinged Pamela Fox, who is my goto person for anything Google Map-ish, and with a couple lines of code she made the locations for Google Developer Day spread out.

The tweak took:

Setup the points

The createMarker function now sets up some meta data:

  var tempPoint = new GLatLng(37, -122);
  var marker = new GMarker(tempPoint, markerOpts);
  marker.pt = point;
  var latAway = point.lat() - tempPoint.lat();
  var lngAway = point.lng() - tempPoint.lng();
  marker.latTravel = latAway/50.0;
  marker.lngTravel = lngAway/50.0;

Animate the beasts

animateMarkers does the work of moving the marker a little and then calls itself via a setTimeout.

function animateMarkers() {
  for (var i=0; i < cm_mapMarkers.length; i++) {
    var curMarker = cm_mapMarkers[i];
    var curPoint = curMarker.getPoint();
    var newPoint = new GLatLng(curPoint.lat() + curMarker.latTravel, curPoint.lng() + curMarker.lngTravel);
    cm_mapMarkers[i].setPoint(newPoint);
  }

 cm_frameNumber++;
 if (cm_frameNumber < 50) {
   setTimeout(animateMarkers, 20);
 }
}

Kick is all off

Then we kick it all off from a simple:

setTimeout(animateMarkers, 1000);

Tweaking the animation

You can mess with the variables for when it starts, how often to redraw (to set the frame-rate), and the amount to move to get different effects. Sometimes on Firefox it stutters. I guess this shows that we don't have a nice concurrent GC as Java 6 does.

Next, we will have hello kitty float randomly around the screen singing in the language of the country.... but in all seriousness, you can do some interesting things on top of the maps. You can even use canvas or SVG.

GDD Animation

Read: Google Maps says "Take That" to Powerpoint

Topic: RubyFX Script Announced at RailsConf Previous Topic   Next Topic Topic: Handy Method Parameters List Lookup

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use