Showing posts with label virtualearth. Show all posts
Showing posts with label virtualearth. Show all posts

Wednesday, 12 August 2009

City2Surf 2009 on RaceReplay.net with Flickr

The world's "largest timed footrace" - Sydney's City2Surf - is now viewable on RaceReplay.net thanks to Silverlight and BingMaps.

There are two 'new' features:

1) Flickr photo integration (try it)

Using the Flickr photo search API, the Silverlight client renders small pink-and-blue dots for photos that are both geo-tagged and tagged:"city2surf". Clicking on the dot will open the Flickr page.



2) Visualizing the entire race (try it)

It is (unfortunately) impossible to animate the 65,000 or so points that would represent every runner and walker taking part in the event. By aggregating the finishers into timebands (and using both size & opacity to represent 'value') you can get some idea of the distribution of participants over time, over the course.



Add yourself!

As always, you can search for and add more 'runners' to the animation. Start typing a name into the autocomplete box, select from the list (optionally choose a color from the color-picker) and click Add runner.

Monday, 6 April 2009

Silverlight VirtualEarth Map Control - with video

Okay - I wasn't going to do any more Silverlight VE Map Control posts... this is definitely the last one! I found some videos on YouTube that I thought suited 'animating' a map so I gave it a try. These would work MUCH BETTER if I had Silverlight-encoded videos that I could sync to/control more easily: but you get the idea...

Sydney City2Surf


Sydney Marathon


p.s. YES I know it's dodgy to have to 'sync' the start of each element manually - but without lots of hassle figuring out if the YouTube video is loaded and running it was the easiest way to proof-of-concept...

Wednesday, 1 April 2009

Silverlight VirtualEarth Map Control - with animation MkII

In recent posts I was working to get the new Virtual Earth Silverlight Map Control (CTP) to:
  1. display (pan/zoom) an <Image> overlay

  2. display (pan/zoom) a <Path> line

  3. animate a set of <Ellipse>s that also (pan/zoom)

  4. animate the map center point to 'track' an <Ellipse>

Turns out this was all possible - there are two examples: New York Marathon and Sydney Half Marathon

Each problem was overcome as follows:

1. Use m:MapLayer.MapRectangle not Height/Width

Any "pixel-specific" measurements applied to the Image will intefere with your Map layout. DO NOT specify Height, Width, Canvas.Left, Canvas.Top - just give the NW and SE corners (latitude,longitude) of the geographic region the image should cover, like this:
<Image Source="map.png" m:MapLayer.MapRectangle="40.8325608405556,-74.1015908473376,40.5722860972124,-73.843755459154"...

2. Use m:MapPolyline not Path

Although it was possible to keep the Path inside a Canvas element and place it with MapRectangle, it did not scale well since the Path Data is effectively tied to pixel coordinates. It is possible to write code to manually scale the line, but it was much easier to re-express the line with points specified by Latitude,Longitude in a m:MapPolyline like this:
<m:MapPolyline Stroke="Red" Locations="-33.863502543277534,151.20294570922852...

3. Use m:MapLayer.Position and a custom attached property

Positioning the Ellipses was easy using m:MapLayer.MapPosition, however animating this property was a little tricky. MapPosition is of Type Location but the Latitude and Longitude properties are not easily accessible as the TargetProperty of an animation, so I needed to write custom attached properties and set them as the target in code.
<Ellipse Fill="#FFFF0000" Width="11" Height="11" m:MapLayer.MapPosition="-33.863502543277534,151.20294570922852" m:MapLayer.MapPositionMethod="Center"...

4. Use m:Map.Center and a custom (hacked) attached property

Making the Map 'viewport' itself animate proved slightly trickier again. I created another attached property (code for all properties here) for some reason only one 'axis' (Longitude) would animate.

When I removed the Longitude property, then the Latitude position would animate... but I could not get them both animating together. Figuring it was a timing issue, rather than try to "set" both properties when they Changed, Latitude gets stuffed into a static field and then set in the LongitudeChanged handler - seems to work but not sure if it's a good idea (obviously it would break if you tried to animate two maps at the same time!)

More info on the final example - no more Map Control posts for a while...

Friday, 27 March 2009

Silverlight VirtualEarth Map Control - with animation

UPDATE: The Microsoft devs were right - it is possible (and not a bug). The 'complete' sample now keeps the image, course line and animated objects visible during all panning and zooming operations - try out
animation with Silverlight Virtual Earth Map Control!

I've made some progress with my first Silverlight Virtual Earth Map Control project...

Try it out (deprecated) latest

Here are some screenshots of the zoom/animation in action:



The code and xaml also online - I needed to (well, I think I needed to) use the ViewChangeEnd event to re-calculate various offsets and dimensions to keep the animation and overlay image sychronised with the Map Controls' zoom behaviour (even though panning worked without modification).

Sunday, 21 September 2008

SilverlightEarth updated for rc0

If you have been updating your Silverlight 2.0 beta 2 for Release Candidate 0, you will probably be familiar with this error "Failed to load the application. It was built with an obsolete version of Silverlight":

Even if your code is 100% RC0 'compatible', you need to re-compile your Silverlight assemblies with the RC0 Silverlight Tools for Visual Studio.

For example, SilverlightEarth.com/2 is updated for RC0, and SilverlightEarth.com/2b2 still hosts the beta2 bits. Although no code changes were required (or made), there a minor visual differences that I have yet to correct (the height of the radio-button StackPanels, for example).

SilverlightEarth.com hosting OpenStreetMap with the Google StreetView overlay

Slightly OT: GIS in XML blog posted recently about
Virtual Earth - DeepEarth - Deep Pockets. Basically it calculates a cost of approx. $1.25 per viewer if licensing Microsoft's Virtual Earth tiles for use in DeepEarth (Silverlight 2.0 map tile client)... although Microsoft can't be too concerned since they have it listed in their Community Gallery!

Luckily silverlightearth.com/2 offers OpenStreetMaps and NASA Blue Marble imagery...

Way OT: the Deep Zoom Tag Cloud example also updated for RC0

Wednesday, 14 November 2007

Virtual Earth 6 - new map 'shading'

Microsoft Virtual Earth 6 has been released - along with various different improvements to the "UI" (javascript and the controls that drive it), one noticable difference is the addition of 'topographical shading' in Road view. Here's the Golden Gate Recreation Area 'before' and 'after'...



Of course, SilverlightEarth.com now uses the new tiles - visit San Francisco and switch between (road) and (roadshade) views.

Seems to be available "down under", but only to zoom '13' and no closer...

(thanks to via windows live and Darren Neimke for the heads-up)

Monday, 12 November 2007

Silverlight 'map tile client' finds a home - SilverlightEarth.com

While the map tile client isn't quite yet for release, I'd already paid for the domain so decided to post it anyway... which means

SilverlightEarth.com

is now LIVE! Granted the dragging still doesn't work; but keyboard (arrows, page up, page down to zoom and pan) does, and the mouse-wheel zooms too. The search box 'searches' and the 'link to this page' does just that.

What's still to come? Well centering the search location for a start, then proper drag-panning on mouse-still-down. After that - maybe uploading some form of geo-coded Xaml to overlay directly on the map... and finally animation a-la RaceReplay.net.

While I had already started working on the 'tile client' before coming across FlashEarth, that is basically the kind of result I'd like to get from Silverlight. Of course, since the Silverlight 1.0 version is (will be) Javascript-based, the code will be easily available for all to see...

Tuesday, 16 October 2007

Pretty Xaml and Search

The Silverlight Virtual Earth/Google Maps tile client v0.9 now has a few more features:
  • Search box to 'geocode' a search term and set the map to that location (eg. search for sydney cricket ground or london eye)
  • Search also accepts latitude, longitude coordinates (searching for 51.505,0.0 will get you pretty close to Greenwich)
  • Xaml controls for the map type, pan and zoom controls

Note that the search results currently default to map zoom '9' -- you should see the flag marker on the map in the top-left -- simply select zoom 14/15/16 to get closer to your target. This will be updated in a future version.

silverlightearth

Xaml tidbit: I expected to have to draw a custom path for the round-corner-rectangles, but turns out that is a supported shape-type... drawing them is as simple as

<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Fill="#88000066" Stretch="Fill" Stroke="#444444FF" Width="130" Height="65">
<Path.Data> <RectangleGeometry Rect="10,50,130,65" RadiusX="5" RadiusY="5" /> </Path.Data> </Path>

where the RadiusX and RadiusY attributes add the rounded corners.



UPDATE: one of the 'fun' things about being able to switch between Google and Microsoft maps is seeing the differences in imagery. Here is Millenium Park (Chicago) in Google (under construction) and Virtual Earth (finished!):

Friday, 21 September 2007

Silverlight-map integration progress v0.8

TileClient08 is the latest of my efforts to integrate Silverlight with Virtual Earth/Google Maps. The improvements are all focused on the Earth maps (not Moon/Mars for now).

TileClient08_road TileClient08_satellite

It uses Microsoft Virtual Earth tiles for the 'road' view and Google tiles for the satellite view. The navigation is still a bit clumsy (centering isn't quite there yet), so the best way to give it a try is:

- click one of the city locations (Sydney, New York, London, Tokyo) and navigate around from there (up/down/left/right/in/out)

- click (once!) to set a flag and then zoom in (with the nav-link, or mousewheel). You'll notice the flag/centerpoint "dance around" a bit - just trust that it will try to keep the location in the viewport

- use the Long/Lat/Zoom inputs to go direct to any location on Earth

The slightly odd behaviour is due to the reliance on the tile-grid to lay out the images. Once I have the math worked out to make the grid of images larger (and clipped by) the viewport, it should all work a lot more smoothly. I've also fixed the (previously unknown) IE-bug: you can't treat strings as arrays apparently, so I had to make

quadkey[quadkey.length-1]


into



quadkey.charAt(quadkey.length-1)


for the Virtual Earth tiles to load in IE.



WARNING: I've just noticed (after lots of testing today) that Google's servers will eventually think you're attacking their image server if you download too many tiles too quickly (I wonder if/how Silverlight caches images?).



If you see 'Image not available at this zoom level' always on the earthsat view, Google is probably blocking the images. Click this image link to check - http://kh0.google.com/kh?n=404&v=20&t=tsrrtsqrssqqtts - you'll either see the image, or get a CAPTCHA test... haven't noticed Virtual Earth not serving images (yet...)



WOT: This post was my first using Live Writer... so far so good (although the spacing is a bit whack around the code)

Thursday, 13 September 2007

Silverlight, Virtual Earth and Google Moon

Slow progress is being made with tiles from Virtual Earth, Google Moon & Mars, and custom Venus images hosted in a generic Silverlight Map Viewer -- panning kinda works (in addition to zoom)! It's clunky, tile-at-a-time panning (no smooth drag metaphor, yet) but it (mostly) works.

Earth (VirtualEarth tiles)
Moon (Google Maps tiles)
Mars (Google Maps tiles)
Venus (custom tiles)

OK, if you visited the demo you'll know it's not quite done yet... specifically when you zoom in, the zoomed coordinates (row/col) are based on the previous zoom level, so they tend (erroneously) towards the top-left of the map; zooming out sometimes breaks around the edges too... although this is a 'silverlight' project, so far there's only a sprinkling of Xaml - it's mostly math & javascript!

UPDATE: 'earth' view doesn't seem to work in IE. Not sure why... give it a go in Firefox.

Thursday, 16 August 2007

Try doing THIS with javascript-driven maps



OK, I'm still working on getting the tile-grid 'working' beyond a simple 2x2 fixed quadkey BUT that doesn't mean we can't play around with the display capabilities of a Silverlight-hosted map control.

No, there's no business application per-se for randomly animating, zooming and translating the map tiles like this, but it looks cool (view larger image)

[OT] BTW, apparently there are some element names that "just don't work", this being one of them: <Storyboard x:Name="TimelineTranslate" RepeatBehavior="1x">. Had me confused for a minute when a SILVERLIGHT ERROR "TimelineTranslate has no properties" was thrown - but a simple name change and the animation worked.

Wednesday, 15 August 2007

Virtual Earth custom tile client (in Silverlight)



While RaceReplay.net works "acceptably" overlaying Silverlight and Virtual Earth to visualize animated/map data, it would be even better (smoother, easier to synchronize) if there was a Virtual Earth client in Silverlight, rather like this Flash map client for Yahoo Maps.

So, using tips from these instructions on
rolling your own tile server here is a first attempt at a Silverlight Virtual Earth Tile Client. I could post the source code - but as with all Silverlight 1.0 stuff, it's right there on the page!

The real question is - how much work to get from here to something that actually works?

Thursday, 9 August 2007

RaceReplay 'RC1' (now with Silverlight & Virtual Earth)


www.racereplay.net release 3 is now live:The Designer will be mortified that I've munged the beautiful work he did by adding those dodgy arrows, but I'm sure you'll agree it's a big improvement!

Tuesday, 10 July 2007

Synchronized dragging: Silverlight and Live Maps/Virtual Earth

Further to this post on Synchronizing Live Maps & Silverlight canvas, you can now pan by dragging rather than just using the rather clumsy up/down/left/right links: both the Silverlight Canvas containing the animation AND the underlying Microsoft Live Maps can be dragged (together)!

You can try out the demo of a Silverlight & Live Maps overlay with synchronized dragging to pan (it's not yet integrated into RaceReplay.net).

It was a relatively simple implementation of the sample code provided by then Silverlight Mouse Support documentation on MSDN. As with most Silverlight stuff, you can just View Source to see how it works...

Look out MapCruncher (joking!)

UPDATE: zooming now works too. When 'implementing' the Mouse Support example, I blindly copied
    canvasT.X = canvasPixel.x;
canvasT.Y = canvasPixel.y;
into onMouseUp(), forgetting that I was also updating
        sender["Canvas.Left"] += currX - beginX;
sender["Canvas.Top"] += currY - beginY;
in onMouseMove(). Oops. Better to update that same property and avoid applying the 'transformation' twice...
    sender["Canvas.Left"] = canvasPixel.x;
sender["Canvas.Top"] = canvasPixel.y;
Also added a new cursor to indicate the map is 'draggable' - unfortunately Silverlight has a limited set of cursors to choose from, so the hand-pointing is used rather than open-hand.

Saturday, 23 June 2007

Synchronise Live Maps & Silverlight canvas


If you overlay a location-specific Silverlight canvas on a Live Map (or is it Virtual Earth?, you'll probably want to 'synchronise' the canvas with the underlying map as it is panned/zoomed.

Although it might seem a tough task, with the help of the Virtual Earth 5 SDK it's relatively easy.

Firstly, check out the end result - a Silverlight canvas/animation that zooms and pans with the Live Map underneath it.

To accomplish the effect, I needed to:

0. Load the map and Silverlight controls
map = new VEMap('myMap');
map.LoadMap(
new VELatLong(-33.865052673579655, 151.22375965118408),
16, VEMapStyle.Hybrid);
//...
Sys.Silverlight.createObject( "xaml/Domain.Xaml", ...
Remembering to set isWindowless:'true' and the position of the elements so they float together.

1. Add Scale and Translate Transforms to the canvas
lt;Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"
x:Name="canvasScale" />
<TranslateTransform X="0" Y="0"
x:Name="canvasTranslate" Name="canvasTranslate" />
</TransformGroup>
</Canvas.RenderTransform>
(this was the only change required to the Xaml). You will use the x:Names later to make it easy to transform the canvas.

2. Determine the lat-long of the canvas

So that you can always position it accurately, regardless of how the map has been panned or zoomed. In this case, the top-left of the canvas should be is at 33.858210507117995, 151.2127733230591, and the map center when loaded is -33.865052673579655, 151.22375965118408.

3. Support panning
Simply shift the map and canvas by the same pixel delta, eg. simply call the Pan function on the map object, and modify the named TranslateTransform on the canvas.
function MoveNorth()
{
map.Pan(0, -100);
var sl8 = document.getElementById("WpfeControlHost_1");
var canvasT = sl8.content.findName("canvasTranslate");
//canvasT.X = canvasT.X - 100;
canvasT.Y = canvasT.Y + 100;
}

4. Support zooming
Other than a little bit of hardcoding, the zoom javascript is pretty simple
function ZoomIn()
{
map.ZoomIn();
var zoom = map.GetZoomLevel();
media_scale(zoom);
return false;
}
function media_scale(zoomLevel)
{
var sl8 = document.getElementById("WpfeControlHost_1");
var canvasT = sl8.content.findName("canvasTranslate");
var canvasS = sl8.content.findName("canvasScale");

var canvasLatLong = new VELatLong(-33.858210507117995, 151.2127733230591);
var canvasPixel = map.LatLongToPixel(canvasLatLong);

canvasT.X = canvasPixel.x;
canvasT.Y = canvasPixel.y;

if (zoomLevel == 17)
{
canvasS.ScaleX = 2;
canvasS.ScaleY = 2;
}
else if (zoomLevel == 16)
{
canvasS.ScaleX = 1;
canvasS.ScaleY = 1;
}
else if (zoomLevel == 15)
{
canvasS.ScaleX = 0.5;
canvasS.ScaleY = 0.5;
}
else if (zoomLevel == 14)
{
canvasS.ScaleX = 0.25;
canvasS.ScaleY = 0.25;
}
else if (zoomLevel == 13)
{
canvasS.ScaleX = 0.125;
canvasS.ScaleY = 0.125;
}
else if (zoomLevel == 12)
{
canvasS.ScaleX = 0.0625;
canvasS.ScaleY = 0.0625;
}
// haven't supported tinier zoom levels - might need to just hide content?
}

As long as your canvas and map loaded 'in sync', the panning should work without trouble, and if the top-left lat-long of your canvasis set, zooming should work too. Note that the scale-factors will depend on what 'resolution' your original Xaml was drawn in - I was tracing a map at zoom level 16 (as you can see).

There's a lot more you could add to this - including animating the zoom and supporting 'drag' for the canvas and map...


Thursday, 21 June 2007

Silverlight/Live Maps overlay

sydney landmarks is based on
Using Opacity with a Silverlight / Virtual Earth Mashup (Remix) - in addition to changing the locations it's also using v5 of the map sdk (rather than v4).

The idea is to eventually get RaceReplay.net working with 'live' maps rather than using embedded images.

No source is "posted" - it's all right there in the browser for the View Source Reflector tool for Silverlight to see.