Adding Push Pins

Jul 8, 2008 at 4:04 PM
Anyone added push pins onto the map and load them and load them at runtime?

If so, could you spare some code snippet?
Jul 8, 2008 at 9:29 PM
Pushpins are not exactly added onto the (multiscaleimage) map, but to a Canvas.

1. Create a canvas and add your pins to that canvas, and then calculate x,y points.

E-x to add pin @ Australia

LatLong latLong =

new LatLong { Latitude = -22.7777, Longitude = 131.7777 };


//get the absolute pixel postion for the supplied latlong


Point p = MapHelper.LatLongToPoint(latLong, MSI);
pin.SetValue(Canvas.TopProperty, p.Y - (pin.InfoPath.ActualHeight/2));
Canvas.LeftProperty, p.X - (pin.InfoPath.ActualHeight/2));

this 'pin' is the one u have added to the Canvas @ Step 1.




Jul 9, 2008 at 6:22 AM
Edited Jul 9, 2008 at 6:24 AM
This assumes that the canvas that overlays the MSI (the one your adding the "Pins" to) originate from the same (0,0 - top left corner of both elements are exactly on top of each other) position.  Make sure that if you move your MSI  around that the canvas that you overlay things in also moves with it otherwise your coordinate system will be all off!
Jul 9, 2008 at 8:08 AM
Absolutly! So would there ever be a need to have the canvas not perfectly aligned with the MSI?
I kind of assumed this would be the case for the canvas and the adorner layer (new to me, explained well here), they should be at 0,0 and 100% height and width (set by not specifing a height or width)
Jul 9, 2008 at 4:32 PM
How do I create the Canvas to overlay the MSI then. Bear with me, I'm struggling through the code...
Jul 10, 2008 at 1:31 AM
If you take a look at the prototype folder there is a sample silverlight/web project. (Remembering it is still early days here).
Look at the silverlight project there is a sample behavour class "PrototypeBehaviour.cs", it is a demonstration of how you can provide a custom behaviour to control aspects of the map. In this case it listens for a mouse click with the "Alt" key held down. It then provides the nessesary code to add our (in need of a face lift) default pin.
From here you could build your own shape to replace our dorky default pin (I can knock it as i made it, please will someone make a cool pin for us...). Of coarse this could occur from a button click or on map load or from an XML stream...
So this kind of shows the concept here, we will have this awesome control that you can easily extend to do exactly what you need. Clearly we also want to provide some killer default behaviours, UI and shapes so please let us know how you go!
Jul 10, 2008 at 1:35 AM
Hi Craig by default in the sample the canvas that contains the shapes is already overlaying the MSI. The should already be positioned over each others 0,0 coordinate.

In the latest build the DeepEarthPrototype project the adorner layer (layer where the pins are added to) is dynamically created and positioned over the MSI. No need for you to do anything!

Sep 4, 2008 at 10:19 PM

Can you please give me a snippet of how the pushpins are created in deep earth? I am new to both deep zoom and virtual earth.


Sep 4, 2008 at 10:30 PM
okay, i figured myself how to add the pushpin. Here is the snippet.

if (shapeLayer == null)
                shapeLayer = new ShapeLayer { ID = "PUSHPIN2" };

            Point pushpinPoint = new Point(100, 0);
            Pushpin pushpin = new Pushpin { Point = pushpinPoint };

Sep 5, 2008 at 1:20 AM
"MapHelper" class, is this your own class as I am not able to find this in the project
or has this class now been renamed or something..?