Thursday, 23 August 2007

"Moon"light - Silverlight and moontiles

Turns out the lat-long algorithm works on the moon too!

The Apollo landing co-ordinates on faqs.org were mapped in the Silverlight TileClient straight from JSON...
 
var landings = eval('['
+' {"Name":"Apollo11","Y":0.67, "X":23.49}'
+',{"Name":"Apollo12","Y":-3.20, "X":-23.38}'
+',{"Name":"Apollo14","Y":-3.67, "X":-17.47}'
+',{"Name":"Apollo15","Y":26.10, "X":3.65}'
+',{"Name":"Apollo16","Y":-8.99, "X":15.52}'
+',{"Name":"Apollo17","Y":20.16, "X":30.77}'
+']')

Here are the points, mapped with yesterday's Javascript function CoordinateFromLongLat() and overlaid on the 'real' moon.google.com... 
 
The JSON is injected into the Silverlight Canvas using CreateFromXaml() method,

var plugin = document.getElementById("SilverlightControl");// landings is the JSON arrayvar coord = CoordinateFromLongLat(landings[0], world);var xaml = flagXaml (landings[0].Name, coord.X, coord.Y);var xamlC = plugin.content.createFromXaml(xaml); canvas.children.add(xamlC);

Where the Silverlight plugin was instantiated like this:

Silverlight.createObjectEx({ source: 'TileClient.xaml', parentElement: document.getElementById("SilverlightControlHost"), id:'SilverlightControl', 

I mention that because most of the samples discussing CreateFromSilverlight() expect the call to come from an event handler, where the sender argument has the getHost() method available.


 
UPDATE 28/8: the Silverlight-moontile client now zooms in and out (but no panning yet...)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.