Tải bản đầy đủ - 0 (trang)
Hack 126. Plot Google Calendar Events on a Google Map

Hack 126. Plot Google Calendar Events on a Google Map

Tải bản đầy đủ - 0trang

calendarentry,asshowninFigure11-35.Ifyoudon'tadda

location,thereisnomaplinkprovided—instead,youare

presentedwitha"Clicktoaddalocation"option.

Afeedcontainingeachcalendareventasaseparatefeeditem

isavailablefromeachcalendar.ThefeedformatisAtom,used

bytheGoogleDataAPI(GData)framework.Tofindthe

calendar'sfeed,firstopenthepop-upoptionsmenuassociated

withoneofyourcalendars—there'sadrop-downarrowbyeach

calendarname—andselect"Calendarsettings,"asshownin

Figure11-36.

Towardthebottomofthecalendarsettingsaresomelinksto

variousoutputfeedsfromthecalendar(Figure11-37).The

publicandprivatefeedsarebothread-onlyfeedsthatcanbe

accessedwithoutloggingintoGoogleCalendar.Youhavesome

controloverthecontentofthepublicfeedviatheCalendar's

sharingsettings.Theprivatefeedisafullfeed,andprivateonly

aslongasyoudon'tsharetheURLwithanyoneelse!

GoogleCalendar"CalendarSettings"page;thefeedURLs

canbefoundtowardsthebottomofthepage



AsweknowthatGoogleCalendarcangenerateamapmarker

fromthelocationofanevent,itwouldseemreasonableto

assumethatthisgeocodedinformationwouldbemadeavailable

intheXMLsyndicationfeed,essentiallydefiningitasa

"GeoRSS"XMLfile(RSS,likeAtom,isafeedformat).Ifthat



wereindeedthecase,theGeoRSSfeedURLcouldthenbe

pasteddirectlyintoaGoogleMapssearchbox,andafter

clickingtheSearchbuttonthecalendareventsassociatedwith

particularlocationswouldbeplottedontheGoogleMap,each

withtheirownmapmarker.

Unfortunately,thelocationinformationisnot(currently)

includedinthecalendareventsfeed.

EnterYahoo!Pipes,andinparticularitsLocationExtractortool.

Pipesisavisualcompositiontooltomashupandconvert

variouswebfeeds,andcanbeusedforavarietyofhacks[Hack

#135].

Creatingapipeisaveryvisualprocess—allittakesisaminute

ortwotocreateaYahoo!pipeliketheonepicturedinFigure

11-38,whichacceptstheGoogleCalendarGDataXMLURL,

fetchesthefeedatthatURL,andthenusestheLocation

Extractortoparsethefeed,addinglongitudeandlatitudedata

toafeeditemifitisfoundtocontainalocation.Torunacopy

ofthepipeonyourownYahoo!Pipesaccount,feelfreetoclone

thepipefromthepipe'shomepage:

http://pipes.yahoo.com/ouseful/geocal.

Ifyouprefercreatingthepipefromscratch,thenfollowthese

steps:

1. Createanew(empty)pipe.

2. FromtheUserInputsmenu,dragaURLInputblockonto

thecanvas(aPipeoutputblockwillbeautomaticallyadded

tothecanvas,too).Thepromptfieldshouldcontainthe

labelforthetextboxonthe"homepage"forthepipe.The

nameisthenameofthevariableinthepipe'sURLthatwill

pointtothecalendarfeed;

3. FromtheSourcesmenu,dragaFetchFeedblockontothe

canvas.WiretheoutputoftheURLinputblocktothe

landingpointtotherightofthetextboxinsidetheFetch



feedblock.

4. FromtheOperatorsmenu,dragaLocationExtractorblock

ontothecanvas.WiretheoutputoftheFetchFeedblockto

theinputoftheLocationExtractorBlock;wiretheoutputof

theLocationExtractorblocktotheinputofthePipeOutput

block.



AYahoo!PipethatgeocodesanRSS/Atomfeed,givenits

URL.Thelocationextractoractuallylooksatthetitleand

descriptiontagsforpossiblelocations.



Fromthe"before"and"after"screenshotsofFigure11-39and

Figure11-40,youcanseehowtheLocationExtractorhas

identifiedthelocationandaddedlatitudeandlongitude

coordinatestothefeed.

TheLocationExtractorlookstoboththetitleandthe

descriptionelementsforpossiblelocations.Inthiscase,

aUKpostcodeiscontainedinthedescription,which

meansthatthere'sagoodchancethattheLocation

Extractorwillbeabletoidentifythelocation.



AftertheLocationExtractorblockhasworkedits

geocodingmagic.Notetheappearanceofthey:location

data.



RunningthepipeactuallydisplaystheeventsonaYahoo!map,

asdisplayedinFigure11-41,butyoucanalsogetholdofa

GeoRSSorKMLfeedURLthatcanthenbeusedtoplotthe

calendareventsonGoogleMaps,orinGoogleEarth.



ThegeocalYahoo!Pipesinterface

(http://pipes.yahoo.com/ouseful/geocal).EntertheURL

ofanRSS/AtomfeedsuchasaGoogleCalendarXMLfeed



andthepipewillgeocodethefirstlocationitfindswithin

thetitleanddescriptionelementsofeachfeeditem.



Ifindit'sbesttousethe"GetasRSS"link,whichprovidesa

GeoRSSfeed,forGoogleMaps,andthe"GetasKML"linktouse

asaliveNetworkLinkinGoogleEarth[Hack#122].

WhenyouaddthefeedtoGoogleMapsorGoogleEarth,each

geocodediteminthecalendarfeedislisted,alongwitha

correspondingmarkeronthemap,asshowninFigure11-42.

GoogleMapplottingtheRSSoutputofthegeocalYahoo

pipe.Thepipe'sKMLoutputcanbeviewedinGoogle

Earth.



ThishackcanbeappliedtoeitherpublicorprivateGoogle

Calendarfeeds.However,youthentrustbothYahoo!and

GooglenottosharetheURLofthatprivatefeed,whichis

privateonlybecauseit'shardtoguess.

ViewingPublicGoogleCalendarsinGoogleEarth



AswellasviewingyourowncalendareventsonaGoogleMap,

orinGoogleEarth,youcanalsovieweventsfromotherpublic

calendarslistedinGoogleCalendar.Youcanfindpublic

calendarsbyusingtheSearchPublicCalendarsbutton.

Onceyouhavefoundapubliccalendaryouwanttodisplayona

map,justrunthroughthestepslistedhere:

1. Addthepubliccalendartoyourcalendar.

2. GrabtheXMLURLfromtheCalendarSettingspage.

3. Pasteitintothegeocalpipe

(http://pipes.yahoo.com/ouseful/geocal)andrunthepipe.

4. Grabthe"GetAsKML"URLfromtheYahoo!Pipe"More

Options"menu.

5. UseitasaNetworkLinkinGoogleEarth.

6. Viewthedatesin3Dgeographicalglory!

Ifyoufindthatthelocationextractorisnotworkingas

expected,modifythelocationoftheevent.Unfortunately,you

can'tdirectlychangeanyofthedetailsinsomeoneelse's

calendar,unlessyoumanagetocomeupwithanotherhackto

dealwiththateventuality!



NOTE

YoucanalsouseGoogleSpreadsheetsassourcefileto

generaterich-mediaplacemarksforGoogleEarthor

GoogleMaps.Googleexplainstheprocessinatextand

videotutorialavailableat

http://earth.google.com/outreach/tutorial_mapper.html.

WanttoplotMicrosoftOutlookeventsonthemap,too?

TrytheWindowsapplicationGoogleCalendarSync,

outlinedat

http://www.google.com/support/calendar/bin/answer.py?

answer=89955.



—TonyHirst



Hack127.TurnGoogleEarthIntoa

FlightSimulator

GoogleEarthhasaninterestingfeatureallowingyoutotry

navigatinganairplane.

IfyouhavethelatestversionofGoogleEarthinstalled,then

youhavemorethanjustamapsprogram—youalsohavea

flightsimulator.

TojumpintoGoogleEarth'sflightsimulator,launchtheprogram

andthenpressCtrl+Alt+A(Windows)orCommand+Option+A

(Mac).Adialog,picturedinFigure11-43,popsupandallows

youtochoosebetweenajetfighter(F16)orapropellerplane

(SR22).HittheStartFlightbutton,andtheflightsimulator

windowwillfireup(closeitanytimeyouwantviathe"Exit

flightsimulator"buttonatthetopright,orbyhittingEscapeon

thekeyboard).

Thefullcontroloptionsforthesimulatorcanbeaccessedby

pickingHelp KeyboardShortcutsfromthemenu.Forinstance:

Increasethrust:PageUp

Reducethrust:PageDown

Rudderleft:Shift+leftarrow

Rudderright:Shift+rightarrow

Aileronleft:Leftarrow

Aileronright:Rightarrow

Elevatorpush:Uparrow

Elevatorpull:Downarrow

Theflightsimulatordialog



Enjoythesceneryduringflight,asshowninFigure11-44!

Flying!



NOTE

FormoreGoogleEarthgoodies,alsohavealookat

FrankTaylor'sunofficialGoogleEarthBlogat

http://gearthblog.com.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 126. Plot Google Calendar Events on a Google Map

Tải bản đầy đủ ngay(0 tr)

×