Johannes Kebeck's Blog
09-25-2007, 12:50 PM
<p><strong>Set up the Framework and add Individual Shapes</strong> <p>In this part we will set the framework for our sample applications and provide the first module which adds individual VEShape-objects to the map. To make it a bit more interesting we will not just add any content but (near) real-time information from a traffic cam. <p>As mentioned in part 1 the VE MapControl is an AJAX control and since I like the idea of partial page-updates so much we will embed our samples not just in a simple HTML-page but in an AJAX-enabled ASP.NET page. Microsoft provides ASP.NET AJAX as an extension to its Visual Studio. It is available for <a href="http://asp.net/ajax/">free download</a> and you can also download for free the ASP.NET AJAX Control Toolkit which provides a number of valuable controls. <p>Once you have installed the ASP.NET AJAX extensions and the ASP.NET AJAX Control Toolkit you have 2 new templates in your Visual Studio. We are going to develop an 'ASP.NET AJAX Control Toolkit Web Site' so that is the template we select: <p><a href="http://blu1.storage.msn.com/y1pgaVuGim1rV2ZhEwOqGzst_Uql-Z7D9F3btgun5ipb9NNIKyD5r2_Wioo9lFfjxtIKkgAdgCX2mVb-iO3qN0bMNBQu1xz5OE5"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=01-small src="http://blufiles.storage.msn.com/y1pLfDzppuxasgSsmtWQVL0FxTnzzTDeqsyR0zZB7BUihKeHYF LafWmphmNsJ9Qk9zJRsAF0vTqdJo" border=0></a> <p>The wizard will automatically generate a new project, add the necessary DLL's, the modifications in the web.config and also add ScriptManager to the Default.aspx page: <p><a href="http://blufiles.storage.msn.com/y1pLfDzppuxashTzT9PcEUgpd0UfdyQFUy575IiPeivYQtBXv8 scfhCOaO1WiRT7chuw_xiKfOar80"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=02-small src="http://blufiles.storage.msn.com/y1pLfDzppuxashvSBKJzT_Dpmx6kE05DfMxqbvv635aSjT3Ttv 1kRQ5Dofuixpn6I5sC7ZOMRXey3M" border=0></a> <p>This ScriptManager is the first important part to AJAX-enable our web site. Now we start adding content. We do that within 3 <div> elements. <ul> <li>The first one is basically a header and just for design. <li>The second one - divAccordion - will host an 'Accordion' from the ASP.NET AJAX Control Toolkit. This is a nice option for our sample applications since we can easily group content types in different panes and hide inactive panes in a way that we only see the header. You will find some explanations and a preview of the Accordion-control <a href="http://asp.net/AJAX/AjaxControlToolkit/Samples/Accordion/Accordion.aspx">here</a>.We define styles for the header and the content part of the accordion in a CSS and assign these styles to the control. The last parameter of the accordion - AutoSize="Fill" - makes sure that the Accordion always uses all available space in the <div> element. Then we add an 'AccordionPane' to the control and within this pane we embed an HTML-control of type checkbox.*Next we attach the JavaScript function 'AddShapes' to the onclick-event of this control and send a couple of parameters to this function. We will have a look at the meaning of these parameters a little bit later. And finally we create a hyperlink which executes another JavaScript and centers the map on the location where we added the pin. <li>The third <div> element will host our Virtual Earth Map.</ul><pre><span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">div</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="position:absolute; top:0px; left:0px; width:100%; height:60px;"</span> <span style="color:rgb(255,0,0)">class</span><span style="color:rgb(0,0,255)">="header">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">table</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="width:100%"</span> <span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">tr</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="vertical-align:top">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">td</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="width:140px; min-width:140px"><</span><span style="color:rgb(163,21,21)">img</span> <span style="color:rgb(255,0,0)">src</span><span style="color:rgb(0,0,255)">="IMG/VirtualEarth.gif"</span> <span style="color:rgb(255,0,0)">alt</span><span style="color:rgb(0,0,255)">="Virtual Earth Logo"</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="margin-left:5px;"</span> <span style="color:rgb(0,0,255)">/></</span><span style="color:rgb(163,21,21)">td</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">td</span><span style="color:rgb(0,0,255)">><</span><span style="color:rgb(163,21,21)">h1</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="min-width:400px"></span>Virtual Earth Demos<span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">h1</span><span style="color:rgb(0,0,255)">></</span><span style="color:rgb(163,21,21)">td</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">td</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="width:140px; min-width:140px; text-align:right"><</span><span style="color:rgb(163,21,21)">a</span><span style="color:rgb(0,0,255)">></span>Version 5<span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">br</span> <span style="color:rgb(0,0,255)">/></</span><span style="color:rgb(163,21,21)">a</span><span style="color:rgb(0,0,255)">></</span><span style="color:rgb(163,21,21)">td</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">tr</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">table</span><span style="color:rgb(0,0,255)">>
</</span><span style="color:rgb(163,21,21)">div</span><span style="color:rgb(0,0,255)">>
<</span><span style="color:rgb(163,21,21)">div</span> <span style="color:rgb(255,0,0)">id</span><span style="color:rgb(0,0,255)">="divAccordion"</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="position:absolute; top:60px; left:0px; width:240px; margin-left:5px;">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">ajaxToolkit</span><span style="color:rgb(0,0,255)">:</span><span style="color:rgb(163,21,21)">Accordion</span> <span style="color:rgb(255,0,0)">ID</span><span style="color:rgb(0,0,255)">="Accordion1"</span> <span style="color:rgb(255,0,0)">runat</span><span style="color:rgb(0,0,255)">="server"</span> <span style="color:rgb(255,0,0)">HeaderCssClass</span><span style="color:rgb(0,0,255)">="accordionHeader"</span> <span style="color:rgb(255,0,0)">ContentCssClass</span><span style="color:rgb(0,0,255)">="accordionContent"</span> <span style="color:rgb(255,0,0)">AutoSize</span><span style="color:rgb(0,0,255)">="Fill">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">Panes</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">ajaxToolkit</span><span style="color:rgb(0,0,255)">:</span><span style="color:rgb(163,21,21)">AccordionPane</span> <span style="color:rgb(255,0,0)">ID</span><span style="color:rgb(0,0,255)">="paneIndividualShapes"</span> <span style="color:rgb(255,0,0)">runat</span><span style="color:rgb(0,0,255)">="server">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">Header</span><span style="color:rgb(0,0,255)">></span>Individual Shapes<span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">Header</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">Content</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">input</span> <span style="color:rgb(255,0,0)">id</span><span style="color:rgb(0,0,255)">="cbTrafficCams"</span> <span style="color:rgb(255,0,0)">type</span><span style="color:rgb(0,0,255)">="checkbox"</span> <span style="color:rgb(255,0,0)">onclick</span><span style="color:rgb(0,0,255)">="AddShapes('cbTrafficCams',pplTrafficCam,VEShapeTyp e.Pushpin,51.501002490610155,-0.1260852813720587,'Parliament Square','<img src=\'http://www.tfl.gov.uk/tfl/livetravelnews/trafficcams/cctv/546501.jpg\'/>','<img src=\'Camera.png\'/>' )"</span> <span style="color:rgb(0,0,255)">/><</span><span style="color:rgb(163,21,21)">a</span> <span style="color:rgb(255,0,0)">href</span><span style="color:rgb(0,0,255)">='javascript:ShowLocation(51.50192414334902, -0.13169646263123205, 17);'></span>Traffic Cams<span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">a</span><span style="color:rgb(0,0,255)">><</span><span style="color:rgb(163,21,21)">br</span> <span style="color:rgb(0,0,255)">/>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">Content</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">ajaxToolkit</span><span style="color:rgb(0,0,255)">:</span><span style="color:rgb(163,21,21)">AccordionPane</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">Panes</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">ajaxToolkit</span><span style="color:rgb(0,0,255)">:</span><span style="color:rgb(163,21,21)">Accordion</span><span style="color:rgb(0,0,255)">>
</</span><span style="color:rgb(163,21,21)">div</span><span style="color:rgb(0,0,255)">>
<</span><span style="color:rgb(163,21,21)">div</span> <span style="color:rgb(255,0,0)">id</span><span style="color:rgb(0,0,255)">="divMap"</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="position:absolute; top:65px; left:250px; width:400px; height:400px;"></</span><span style="color:rgb(163,21,21)">div</span><span style="color:rgb(0,0,255)">>
</span></pre><a href="http://11011.net/software/vspaste"></a>
<p>In the <head> of our site we include the JavaScript which implements the Virtual Earth MapControl and also a second one - MyScript.js - which will contain our own code. Well, and of course we also have to include the CSS.<pre><span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">head</span> <span style="color:rgb(255,0,0)">runat</span><span style="color:rgb(0,0,255)">="server">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">title</span><span style="color:rgb(0,0,255)">></span>Virtual Earth Demos<span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">title</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">meta</span> <span style="color:rgb(255,0,0)">http-equiv</span><span style="color:rgb(0,0,255)">="Content-Type"</span> <span style="color:rgb(255,0,0)">content</span><span style="color:rgb(0,0,255)">="text/html; charset=utf-8"</span> <span style="color:rgb(0,0,255)">/>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">link</span> <span style="color:rgb(255,0,0)">rel</span><span style="color:rgb(0,0,255)">="shortcut icon"</span> <span style="color:rgb(255,0,0)">href</span><span style="color:rgb(0,0,255)">="IMG/favicon.ico"</span> <span style="color:rgb(0,0,255)">/>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">script</span> <span style="color:rgb(255,0,0)">src</span><span style="color:rgb(0,0,255)">="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"</span> <span style="color:rgb(255,0,0)">type</span><span style="color:rgb(0,0,255)">="text/javascript"></</span><span style="color:rgb(163,21,21)">script</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">script</span> <span style="color:rgb(255,0,0)">src</span><span style="color:rgb(0,0,255)">="JS/MyScript.js"</span> <span style="color:rgb(255,0,0)">type</span><span style="color:rgb(0,0,255)">="text/javascript"></</span><span style="color:rgb(163,21,21)">script</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">link</span> <span style="color:rgb(255,0,0)">href</span><span style="color:rgb(0,0,255)">="CSS/StyleSheet.css"</span> <span style="color:rgb(255,0,0)">rel</span><span style="color:rgb(0,0,255)">="stylesheet"</span> <span style="color:rgb(255,0,0)">type</span><span style="color:rgb(0,0,255)">="text/css"</span> <span style="color:rgb(0,0,255)">/>
</</span><span style="color:rgb(163,21,21)">head</span><span style="color:rgb(0,0,255)">></span></pre><a href="http://11011.net/software/vspaste"></a>
<p>Now we*attach our first 2 JavaScript-functions to the body of our web site. One which is being executed when we load the page and another one which is always executed when we resize the browser window. We will use the former to load the Virtual Earth map and the latter to resize our controls in order to use all available screen estate.<pre><span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">body</span> <span style="color:rgb(255,0,0)">onload</span><span style="color:rgb(0,0,255)">="GetMap();"</span> <span style="color:rgb(255,0,0)">onresize</span><span style="color:rgb(0,0,255)">="Resize();"></span></pre><a href="http://11011.net/software/vspaste"></a>
<p>Now let's have a look at our JavaScript - MyScript.js. We define the map as a global variable so that we can access this object from different functions:<pre><span style="color:rgb(0,0,255)">var</span> map = <span style="color:rgb(0,0,255)">null</span>;</pre><a href="http://11011.net/software/vspaste"></a>
<p>The function that will be executed when we load the page is the function GetMap(). It*instantiates the Virtual Earth MapControl in our <div>-element with the ID 'divMap' and then loads the map centered on the latitude and longitude as shown below. We also determine the zoom-level (18) and the style ('h') we want to use and make sure that we don't switch off the interactivity (false). For more*parameters of the <a href="http://msdn2.microsoft.com/en-us/library/bb412546.aspx">LoadMap</a>-method have a look at the SDK. Afterwards we execute the function Resize().<pre><span style="color:rgb(0,0,255)">function</span> GetMap()
{
map = <span style="color:rgb(0,0,255)">new</span> VEMap(<span style="color:rgb(163,21,21)">'divMap'</span>);
map.LoadMap(<span style="color:rgb(0,0,255)">new</span> VELatLong(51.461962075378054, -0.9260702133178665), 18, <span style="color:rgb(163,21,21)">'h'</span>, <span style="color:rgb(0,0,255)">false</span>);
Resize();
}</pre><a href="http://11011.net/software/vspaste"></a>
<table cellspacing=0 cellpadding=2 width=783 border=1>
<tbody>
<tr>
<td valign=top width=781><em><u>Tip:</u> There are many ways to determine the latitude and longitude of a location. Usually you would use a geocoder for this but for a single pair of latitude and longitude coordinates you can also use <a href="http://maps.live.com/?mkt=en-us">Live Search Maps</a>.</em> <em>Center the map on*your location and then select 'Share => Permalink' from the menu. The URL you see contains the latitude and longitude of the center-point (cp) as well as the zoom-level (lvl):<br></em><a title="http://maps.live.com/default.aspx?v=2&cp=51.461213~-0.926116&style=h&lvl=18&tilt=-90&dir=0&alt=-1000&encType=1" href="http://maps.live.com/default.aspx?v=2&cp=51.461213~-0.926116&style=h&lvl=18&tilt=-90&dir=0&alt=-1000&encType=1"><em>http://maps.live.com/default.aspx?v=2&cp=51.461213~-0.926116&style=h&lvl=18&tilt=-90&dir=0&alt=-1000&encType=1</em></a><br><br><em>If you have up to 200 points you can add them to a collection in Live Search Maps and share the collection. The URL just contains a Collection-ID which is apparently not helpful but if you open the URL you see that you can subscribe to a RSS-feed:<br></em><a href="http://blufiles.storage.msn.com/y1pLfDzppuxasigQqmM3Ms7xLundLWQjuD0_UjzZ57QCF5y8Ne MIny-j6ZSa-CS1Cw3_31f4vpQhrY"><em><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=image src="http://blufiles.storage.msn.com/y1pLfDzppuxasikiWqnqjzBmOh7QEBXzTuF4AYitL9JDwTdn6n _DLXoqjuImXzSogp9tyEdOYoHLGQ" border=0></em></a><em> <br>In fact the RSS-feed is a GeoRSS-feed and if you look at it a bit closer you get all the latitudes and longitudes:<br></em><a href="http://blufiles.storage.msn.com/y1pLfDzppuxasiCeXzj1rUxHYP-lfztRLCZxg3_r3ZFLM69h7gbRBWGV5zuIwm-L7iPCsj1aPPhwHs"><em><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=05-small src="http://blufiles.storage.msn.com/y1pLfDzppuxasitaTOjcMbie_EdVPsBDd1i-9FH8II6DSDGcrOVRKGsF26whDso5WUZDdhscchZKHk" border=0></em></a> </tbody></table>
<p>After this short excursion let's go back to our script. I mentioned that the GetMap() function calls the Resize()-function and here it is:<pre><span style="color:rgb(0,0,255)">function</span> Resize()
{
<span style="color:rgb(0,0,255)">var</span> mapDiv = document.getElementById(<span style="color:rgb(163,21,21)">"divMap"</span>);
<span style="color:rgb(0,0,255)">var</span> accordion = document.getElementById(<span style="color:rgb(163,21,21)">"Accordion1"</span>);
<span style="color:rgb(0,0,255)">var</span> windowWidth = document.body.clientWidth;
<span style="color:rgb(0,0,255)">var</span> windowHeight = document.body.clientHeight;
<span style="color:rgb(0,0,255)">var</span> mapWidth = windowWidth - 255;
<span style="color:rgb(0,0,255)">var</span> mapHeight = windowHeight - 70;
mapDiv.style.width = mapWidth + <span style="color:rgb(163,21,21)">"px"</span>;
mapDiv.style.height = mapHeight + <span style="color:rgb(163,21,21)">"px"</span>;
accordion.style.height = (windowHeight - 65) + <span style="color:rgb(163,21,21)">"px"</span>;
map.Resize(mapWidth, mapHeight);
map.ShowMiniMap(mapWidth-205, 13, VEMiniMapSize.Large);
}
</pre><a href="http://11011.net/software/vspaste"></a>
<p>We retrieve the size of the browser client window and adjust the height of the Accordion as well as the height and width of the map. Afterwards we call the <a href="http://msdn2.microsoft.com/en-us/library/bb429585.aspx">Resize</a>-method from the VE MapControl and the we display a <a href="http://msdn2.microsoft.com/en-us/library/bb412549.aspx">minimap</a>. By default the minimap is attached to the Virtual Earth dashboard but I prefer to have it at the right hand side.
<p>At this point you are not quite ready to display a VEShape but you can already admire your first*results:
<p><a href="http://blufiles.storage.msn.com/y1pLfDzppuxasiwd8p-CxORCiz_ygHI3rWTOU5G6bNVUi2hN_Eq_UXM4O0Z6eNQu4Mrgw 6ogK-BVxQ"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=03-small src="http://blufiles.storage.msn.com/y1pLfDzppuxasiqtDHzAnZJ209iXQGGC1OkfZOzpDaQigrK4YP fRFf9WVhsrbgIhm20mu334C2teIU" border=0></a>
<p>Now let's*go for our shape. Since version 5 Virtual Earth supports the concepts of layers. You can still add shapes to the base layer of the map as you did in version 4 but the layer-concept is much more flexible and allows you to*organize different types of content*in different layers.:
<p><a href="http://blufiles.storage.msn.com/y1pLfDzppuxashzzHa4r8kum5o9OYC3DA06Nxmwq_czmOUaU-9MFs8sc8maN20B0RkA7RvPaKLYZK8"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=285 alt=image src="http://blufiles.storage.msn.com/y1pLfDzppuxashVX13XByKTDRGUZ2-vNcJ6NvS3FJGzBPUdpjkTksFNvAC3drGAf7iFqzTODM2TkUQ" width=400 border=0></a>
<p>We will define a global variable for our layer:<pre><span style="color:rgb(0,0,255)">var</span> pplTrafficCam = <span style="color:rgb(0,0,255)">new</span> VEShapeLayer();</pre>
<p><a href="http://11011.net/software/vspaste"></a>In the GetMap-function we set the name for this layer<pre>pplTrafficCam.SetTitle(<span style="color:rgb(163,21,21)">'pplTrafficCam'</span>);</pre><a href="http://11011.net/software/vspaste"></a>
<p>And then we have the function which is being*executed when the onclick-event of the checkbox in our web site is being clicked. As you can see further down*this is a very generic script*which takes all the necessary information as input-parameters of the function:
<ul>
<li>the name of the control so that we can check if it has been activated or deactivated
<li>the name of the layer we want to add the shape to
<li>the <a href="http://msdn2.microsoft.com/en-us/library/bb412419.aspx">type of the VEShape and its location</a>
<li>the title of its infobox and its details as well as
<li>the icon we want to use to mark the position of our VEShape</ul>
<p>If you have a look at the parameters we use when we call the JavaScript from you see that the details for the infobox are referencing an image '<img src=\'http://www.tfl.gov.uk/tfl/livetravelnews/trafficcams/cctv/546501.jpg\'/>'. This image is being created by traffic cams and made available on the web site '<a href="http://www.tfl.gov.uk/tfl/livetravelnews/realtime/road/default.asp">Transport for London</a>'.
<p>If the checkbox has been deactivated we will <a href="http://msdn2.microsoft.com/en-us/library/bb429616.aspx">delete all points</a>. Otherwise we will <a href="http://msdn2.microsoft.com/en-us/library/bb412479.aspx">add the layer to the map</a>, define the <a href="http://msdn2.microsoft.com/en-us/library/bb412535.aspx">VEShape-object</a> and <a href="http://msdn2.microsoft.com/en-us/library/bb412436.aspx">add it to the layer</a>.<pre><span style="color:rgb(0,0,255)">function</span> AddShapes(control,layer,type,lat,lon,title,desc,ic on)
{
<span style="color:rgb(0,0,255)">if</span> (document.getElementById(control).checked == <span style="color:rgb(0,0,255)">false</span>) {
layer.DeleteAllShapes();
}
<span style="color:rgb(0,0,255)">else</span> {
<span style="color:rgb(0,128,0)">//Add the Shape-Layer
</span> <span style="color:rgb(0,0,255)">try
</span> {
map.AddShapeLayer(layer);
}
<span style="color:rgb(0,0,255)">catch</span>(e)
{
}
<span style="color:rgb(0,128,0)">//Add the Shape
</span> <span style="color:rgb(0,0,255)">var</span> shape = <span style="color:rgb(0,0,255)">new</span> VEShape(type, <span style="color:rgb(0,0,255)">new</span> VELatLong(lat,lon));
shape.SetTitle(title);
shape.SetDescription(desc);
shape.SetCustomIcon(icon);
layer.AddShape(shape);
}
}</pre><a href="http://11011.net/software/vspaste"></a>
<p>This is already it. Just for better usability we have added a hyperlink on the web site which <a href="http://msdn2.microsoft.com/en-us/library/bb412439.aspx">centers the map</a> on the location where we just added the pin. This hyperlink will execute the following JavaScript.<pre><span style="color:rgb(0,0,255)">function</span> ShowLocation(lat, lon, lvl)
{
<span style="color:rgb(0,0,255)">var</span> cp = <span style="color:rgb(0,0,255)">new</span> VELatLong(lat, lon);
map.SetCenterAndZoom(cp, lvl);
}
</pre><a href="http://11011.net/software/vspaste"></a>
<p>Now we're really done. We have our framework for the further samples and a first one which shows us the images from the*traffic cam*at 'Parliament Square' in London:
<p><a href="http://blufiles.storage.msn.com/y1pLfDzppuxasjQ9EPdHyj3QP83hXvEijC2MyRq9xN0_GOUelY JMA-wuT6jGTMFIxhN8QAZa3ajdOw"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=06-small src="http://blufiles.storage.msn.com/y1pLfDzppuxashIyp4RajvezxjVA3SpVoiMaEazuBAVJzZ2Zfw EylBIVpgjLyzKJs3eUTOffBQ0Q4s" border=0></a>
<p>The <a href="http://mappointemea.members.winisp.net/IndividualShapes01/IndividualShapes01.aspx">sample application is also available here</a> and contains as always a download-link for the complete source-code.<img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4819404664324524694&page=RSS%3a+How+to+bring+your+own+content+to+Virtu al+Earth+(Part+2)&referrer=" width="1px" height="1px" border="0" alt=""><img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&NA=1149&PI=88469&RF=&DI=3919&PS=85545&TP=johanneskebeck.spaces.live.com>1=JohannesKebeck">
Click here to view the article. (http://JohannesKebeck.spaces.live.com/Blog/cns!42E1F70205EC8A96!1792.entry)
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">table</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="width:100%"</span> <span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">tr</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="vertical-align:top">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">td</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="width:140px; min-width:140px"><</span><span style="color:rgb(163,21,21)">img</span> <span style="color:rgb(255,0,0)">src</span><span style="color:rgb(0,0,255)">="IMG/VirtualEarth.gif"</span> <span style="color:rgb(255,0,0)">alt</span><span style="color:rgb(0,0,255)">="Virtual Earth Logo"</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="margin-left:5px;"</span> <span style="color:rgb(0,0,255)">/></</span><span style="color:rgb(163,21,21)">td</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">td</span><span style="color:rgb(0,0,255)">><</span><span style="color:rgb(163,21,21)">h1</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="min-width:400px"></span>Virtual Earth Demos<span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">h1</span><span style="color:rgb(0,0,255)">></</span><span style="color:rgb(163,21,21)">td</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">td</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="width:140px; min-width:140px; text-align:right"><</span><span style="color:rgb(163,21,21)">a</span><span style="color:rgb(0,0,255)">></span>Version 5<span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">br</span> <span style="color:rgb(0,0,255)">/></</span><span style="color:rgb(163,21,21)">a</span><span style="color:rgb(0,0,255)">></</span><span style="color:rgb(163,21,21)">td</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">tr</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">table</span><span style="color:rgb(0,0,255)">>
</</span><span style="color:rgb(163,21,21)">div</span><span style="color:rgb(0,0,255)">>
<</span><span style="color:rgb(163,21,21)">div</span> <span style="color:rgb(255,0,0)">id</span><span style="color:rgb(0,0,255)">="divAccordion"</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="position:absolute; top:60px; left:0px; width:240px; margin-left:5px;">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">ajaxToolkit</span><span style="color:rgb(0,0,255)">:</span><span style="color:rgb(163,21,21)">Accordion</span> <span style="color:rgb(255,0,0)">ID</span><span style="color:rgb(0,0,255)">="Accordion1"</span> <span style="color:rgb(255,0,0)">runat</span><span style="color:rgb(0,0,255)">="server"</span> <span style="color:rgb(255,0,0)">HeaderCssClass</span><span style="color:rgb(0,0,255)">="accordionHeader"</span> <span style="color:rgb(255,0,0)">ContentCssClass</span><span style="color:rgb(0,0,255)">="accordionContent"</span> <span style="color:rgb(255,0,0)">AutoSize</span><span style="color:rgb(0,0,255)">="Fill">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">Panes</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">ajaxToolkit</span><span style="color:rgb(0,0,255)">:</span><span style="color:rgb(163,21,21)">AccordionPane</span> <span style="color:rgb(255,0,0)">ID</span><span style="color:rgb(0,0,255)">="paneIndividualShapes"</span> <span style="color:rgb(255,0,0)">runat</span><span style="color:rgb(0,0,255)">="server">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">Header</span><span style="color:rgb(0,0,255)">></span>Individual Shapes<span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">Header</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">Content</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">input</span> <span style="color:rgb(255,0,0)">id</span><span style="color:rgb(0,0,255)">="cbTrafficCams"</span> <span style="color:rgb(255,0,0)">type</span><span style="color:rgb(0,0,255)">="checkbox"</span> <span style="color:rgb(255,0,0)">onclick</span><span style="color:rgb(0,0,255)">="AddShapes('cbTrafficCams',pplTrafficCam,VEShapeTyp e.Pushpin,51.501002490610155,-0.1260852813720587,'Parliament Square','<img src=\'http://www.tfl.gov.uk/tfl/livetravelnews/trafficcams/cctv/546501.jpg\'/>','<img src=\'Camera.png\'/>' )"</span> <span style="color:rgb(0,0,255)">/><</span><span style="color:rgb(163,21,21)">a</span> <span style="color:rgb(255,0,0)">href</span><span style="color:rgb(0,0,255)">='javascript:ShowLocation(51.50192414334902, -0.13169646263123205, 17);'></span>Traffic Cams<span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">a</span><span style="color:rgb(0,0,255)">><</span><span style="color:rgb(163,21,21)">br</span> <span style="color:rgb(0,0,255)">/>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">Content</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">ajaxToolkit</span><span style="color:rgb(0,0,255)">:</span><span style="color:rgb(163,21,21)">AccordionPane</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">Panes</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">ajaxToolkit</span><span style="color:rgb(0,0,255)">:</span><span style="color:rgb(163,21,21)">Accordion</span><span style="color:rgb(0,0,255)">>
</</span><span style="color:rgb(163,21,21)">div</span><span style="color:rgb(0,0,255)">>
<</span><span style="color:rgb(163,21,21)">div</span> <span style="color:rgb(255,0,0)">id</span><span style="color:rgb(0,0,255)">="divMap"</span> <span style="color:rgb(255,0,0)">style</span><span style="color:rgb(0,0,255)">="position:absolute; top:65px; left:250px; width:400px; height:400px;"></</span><span style="color:rgb(163,21,21)">div</span><span style="color:rgb(0,0,255)">>
</span></pre><a href="http://11011.net/software/vspaste"></a>
<p>In the <head> of our site we include the JavaScript which implements the Virtual Earth MapControl and also a second one - MyScript.js - which will contain our own code. Well, and of course we also have to include the CSS.<pre><span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">head</span> <span style="color:rgb(255,0,0)">runat</span><span style="color:rgb(0,0,255)">="server">
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">title</span><span style="color:rgb(0,0,255)">></span>Virtual Earth Demos<span style="color:rgb(0,0,255)"></</span><span style="color:rgb(163,21,21)">title</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">meta</span> <span style="color:rgb(255,0,0)">http-equiv</span><span style="color:rgb(0,0,255)">="Content-Type"</span> <span style="color:rgb(255,0,0)">content</span><span style="color:rgb(0,0,255)">="text/html; charset=utf-8"</span> <span style="color:rgb(0,0,255)">/>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">link</span> <span style="color:rgb(255,0,0)">rel</span><span style="color:rgb(0,0,255)">="shortcut icon"</span> <span style="color:rgb(255,0,0)">href</span><span style="color:rgb(0,0,255)">="IMG/favicon.ico"</span> <span style="color:rgb(0,0,255)">/>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">script</span> <span style="color:rgb(255,0,0)">src</span><span style="color:rgb(0,0,255)">="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"</span> <span style="color:rgb(255,0,0)">type</span><span style="color:rgb(0,0,255)">="text/javascript"></</span><span style="color:rgb(163,21,21)">script</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">script</span> <span style="color:rgb(255,0,0)">src</span><span style="color:rgb(0,0,255)">="JS/MyScript.js"</span> <span style="color:rgb(255,0,0)">type</span><span style="color:rgb(0,0,255)">="text/javascript"></</span><span style="color:rgb(163,21,21)">script</span><span style="color:rgb(0,0,255)">>
</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">link</span> <span style="color:rgb(255,0,0)">href</span><span style="color:rgb(0,0,255)">="CSS/StyleSheet.css"</span> <span style="color:rgb(255,0,0)">rel</span><span style="color:rgb(0,0,255)">="stylesheet"</span> <span style="color:rgb(255,0,0)">type</span><span style="color:rgb(0,0,255)">="text/css"</span> <span style="color:rgb(0,0,255)">/>
</</span><span style="color:rgb(163,21,21)">head</span><span style="color:rgb(0,0,255)">></span></pre><a href="http://11011.net/software/vspaste"></a>
<p>Now we*attach our first 2 JavaScript-functions to the body of our web site. One which is being executed when we load the page and another one which is always executed when we resize the browser window. We will use the former to load the Virtual Earth map and the latter to resize our controls in order to use all available screen estate.<pre><span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">body</span> <span style="color:rgb(255,0,0)">onload</span><span style="color:rgb(0,0,255)">="GetMap();"</span> <span style="color:rgb(255,0,0)">onresize</span><span style="color:rgb(0,0,255)">="Resize();"></span></pre><a href="http://11011.net/software/vspaste"></a>
<p>Now let's have a look at our JavaScript - MyScript.js. We define the map as a global variable so that we can access this object from different functions:<pre><span style="color:rgb(0,0,255)">var</span> map = <span style="color:rgb(0,0,255)">null</span>;</pre><a href="http://11011.net/software/vspaste"></a>
<p>The function that will be executed when we load the page is the function GetMap(). It*instantiates the Virtual Earth MapControl in our <div>-element with the ID 'divMap' and then loads the map centered on the latitude and longitude as shown below. We also determine the zoom-level (18) and the style ('h') we want to use and make sure that we don't switch off the interactivity (false). For more*parameters of the <a href="http://msdn2.microsoft.com/en-us/library/bb412546.aspx">LoadMap</a>-method have a look at the SDK. Afterwards we execute the function Resize().<pre><span style="color:rgb(0,0,255)">function</span> GetMap()
{
map = <span style="color:rgb(0,0,255)">new</span> VEMap(<span style="color:rgb(163,21,21)">'divMap'</span>);
map.LoadMap(<span style="color:rgb(0,0,255)">new</span> VELatLong(51.461962075378054, -0.9260702133178665), 18, <span style="color:rgb(163,21,21)">'h'</span>, <span style="color:rgb(0,0,255)">false</span>);
Resize();
}</pre><a href="http://11011.net/software/vspaste"></a>
<table cellspacing=0 cellpadding=2 width=783 border=1>
<tbody>
<tr>
<td valign=top width=781><em><u>Tip:</u> There are many ways to determine the latitude and longitude of a location. Usually you would use a geocoder for this but for a single pair of latitude and longitude coordinates you can also use <a href="http://maps.live.com/?mkt=en-us">Live Search Maps</a>.</em> <em>Center the map on*your location and then select 'Share => Permalink' from the menu. The URL you see contains the latitude and longitude of the center-point (cp) as well as the zoom-level (lvl):<br></em><a title="http://maps.live.com/default.aspx?v=2&cp=51.461213~-0.926116&style=h&lvl=18&tilt=-90&dir=0&alt=-1000&encType=1" href="http://maps.live.com/default.aspx?v=2&cp=51.461213~-0.926116&style=h&lvl=18&tilt=-90&dir=0&alt=-1000&encType=1"><em>http://maps.live.com/default.aspx?v=2&cp=51.461213~-0.926116&style=h&lvl=18&tilt=-90&dir=0&alt=-1000&encType=1</em></a><br><br><em>If you have up to 200 points you can add them to a collection in Live Search Maps and share the collection. The URL just contains a Collection-ID which is apparently not helpful but if you open the URL you see that you can subscribe to a RSS-feed:<br></em><a href="http://blufiles.storage.msn.com/y1pLfDzppuxasigQqmM3Ms7xLundLWQjuD0_UjzZ57QCF5y8Ne MIny-j6ZSa-CS1Cw3_31f4vpQhrY"><em><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=image src="http://blufiles.storage.msn.com/y1pLfDzppuxasikiWqnqjzBmOh7QEBXzTuF4AYitL9JDwTdn6n _DLXoqjuImXzSogp9tyEdOYoHLGQ" border=0></em></a><em> <br>In fact the RSS-feed is a GeoRSS-feed and if you look at it a bit closer you get all the latitudes and longitudes:<br></em><a href="http://blufiles.storage.msn.com/y1pLfDzppuxasiCeXzj1rUxHYP-lfztRLCZxg3_r3ZFLM69h7gbRBWGV5zuIwm-L7iPCsj1aPPhwHs"><em><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=05-small src="http://blufiles.storage.msn.com/y1pLfDzppuxasitaTOjcMbie_EdVPsBDd1i-9FH8II6DSDGcrOVRKGsF26whDso5WUZDdhscchZKHk" border=0></em></a> </tbody></table>
<p>After this short excursion let's go back to our script. I mentioned that the GetMap() function calls the Resize()-function and here it is:<pre><span style="color:rgb(0,0,255)">function</span> Resize()
{
<span style="color:rgb(0,0,255)">var</span> mapDiv = document.getElementById(<span style="color:rgb(163,21,21)">"divMap"</span>);
<span style="color:rgb(0,0,255)">var</span> accordion = document.getElementById(<span style="color:rgb(163,21,21)">"Accordion1"</span>);
<span style="color:rgb(0,0,255)">var</span> windowWidth = document.body.clientWidth;
<span style="color:rgb(0,0,255)">var</span> windowHeight = document.body.clientHeight;
<span style="color:rgb(0,0,255)">var</span> mapWidth = windowWidth - 255;
<span style="color:rgb(0,0,255)">var</span> mapHeight = windowHeight - 70;
mapDiv.style.width = mapWidth + <span style="color:rgb(163,21,21)">"px"</span>;
mapDiv.style.height = mapHeight + <span style="color:rgb(163,21,21)">"px"</span>;
accordion.style.height = (windowHeight - 65) + <span style="color:rgb(163,21,21)">"px"</span>;
map.Resize(mapWidth, mapHeight);
map.ShowMiniMap(mapWidth-205, 13, VEMiniMapSize.Large);
}
</pre><a href="http://11011.net/software/vspaste"></a>
<p>We retrieve the size of the browser client window and adjust the height of the Accordion as well as the height and width of the map. Afterwards we call the <a href="http://msdn2.microsoft.com/en-us/library/bb429585.aspx">Resize</a>-method from the VE MapControl and the we display a <a href="http://msdn2.microsoft.com/en-us/library/bb412549.aspx">minimap</a>. By default the minimap is attached to the Virtual Earth dashboard but I prefer to have it at the right hand side.
<p>At this point you are not quite ready to display a VEShape but you can already admire your first*results:
<p><a href="http://blufiles.storage.msn.com/y1pLfDzppuxasiwd8p-CxORCiz_ygHI3rWTOU5G6bNVUi2hN_Eq_UXM4O0Z6eNQu4Mrgw 6ogK-BVxQ"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=03-small src="http://blufiles.storage.msn.com/y1pLfDzppuxasiqtDHzAnZJ209iXQGGC1OkfZOzpDaQigrK4YP fRFf9WVhsrbgIhm20mu334C2teIU" border=0></a>
<p>Now let's*go for our shape. Since version 5 Virtual Earth supports the concepts of layers. You can still add shapes to the base layer of the map as you did in version 4 but the layer-concept is much more flexible and allows you to*organize different types of content*in different layers.:
<p><a href="http://blufiles.storage.msn.com/y1pLfDzppuxashzzHa4r8kum5o9OYC3DA06Nxmwq_czmOUaU-9MFs8sc8maN20B0RkA7RvPaKLYZK8"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=285 alt=image src="http://blufiles.storage.msn.com/y1pLfDzppuxashVX13XByKTDRGUZ2-vNcJ6NvS3FJGzBPUdpjkTksFNvAC3drGAf7iFqzTODM2TkUQ" width=400 border=0></a>
<p>We will define a global variable for our layer:<pre><span style="color:rgb(0,0,255)">var</span> pplTrafficCam = <span style="color:rgb(0,0,255)">new</span> VEShapeLayer();</pre>
<p><a href="http://11011.net/software/vspaste"></a>In the GetMap-function we set the name for this layer<pre>pplTrafficCam.SetTitle(<span style="color:rgb(163,21,21)">'pplTrafficCam'</span>);</pre><a href="http://11011.net/software/vspaste"></a>
<p>And then we have the function which is being*executed when the onclick-event of the checkbox in our web site is being clicked. As you can see further down*this is a very generic script*which takes all the necessary information as input-parameters of the function:
<ul>
<li>the name of the control so that we can check if it has been activated or deactivated
<li>the name of the layer we want to add the shape to
<li>the <a href="http://msdn2.microsoft.com/en-us/library/bb412419.aspx">type of the VEShape and its location</a>
<li>the title of its infobox and its details as well as
<li>the icon we want to use to mark the position of our VEShape</ul>
<p>If you have a look at the parameters we use when we call the JavaScript from you see that the details for the infobox are referencing an image '<img src=\'http://www.tfl.gov.uk/tfl/livetravelnews/trafficcams/cctv/546501.jpg\'/>'. This image is being created by traffic cams and made available on the web site '<a href="http://www.tfl.gov.uk/tfl/livetravelnews/realtime/road/default.asp">Transport for London</a>'.
<p>If the checkbox has been deactivated we will <a href="http://msdn2.microsoft.com/en-us/library/bb429616.aspx">delete all points</a>. Otherwise we will <a href="http://msdn2.microsoft.com/en-us/library/bb412479.aspx">add the layer to the map</a>, define the <a href="http://msdn2.microsoft.com/en-us/library/bb412535.aspx">VEShape-object</a> and <a href="http://msdn2.microsoft.com/en-us/library/bb412436.aspx">add it to the layer</a>.<pre><span style="color:rgb(0,0,255)">function</span> AddShapes(control,layer,type,lat,lon,title,desc,ic on)
{
<span style="color:rgb(0,0,255)">if</span> (document.getElementById(control).checked == <span style="color:rgb(0,0,255)">false</span>) {
layer.DeleteAllShapes();
}
<span style="color:rgb(0,0,255)">else</span> {
<span style="color:rgb(0,128,0)">//Add the Shape-Layer
</span> <span style="color:rgb(0,0,255)">try
</span> {
map.AddShapeLayer(layer);
}
<span style="color:rgb(0,0,255)">catch</span>(e)
{
}
<span style="color:rgb(0,128,0)">//Add the Shape
</span> <span style="color:rgb(0,0,255)">var</span> shape = <span style="color:rgb(0,0,255)">new</span> VEShape(type, <span style="color:rgb(0,0,255)">new</span> VELatLong(lat,lon));
shape.SetTitle(title);
shape.SetDescription(desc);
shape.SetCustomIcon(icon);
layer.AddShape(shape);
}
}</pre><a href="http://11011.net/software/vspaste"></a>
<p>This is already it. Just for better usability we have added a hyperlink on the web site which <a href="http://msdn2.microsoft.com/en-us/library/bb412439.aspx">centers the map</a> on the location where we just added the pin. This hyperlink will execute the following JavaScript.<pre><span style="color:rgb(0,0,255)">function</span> ShowLocation(lat, lon, lvl)
{
<span style="color:rgb(0,0,255)">var</span> cp = <span style="color:rgb(0,0,255)">new</span> VELatLong(lat, lon);
map.SetCenterAndZoom(cp, lvl);
}
</pre><a href="http://11011.net/software/vspaste"></a>
<p>Now we're really done. We have our framework for the further samples and a first one which shows us the images from the*traffic cam*at 'Parliament Square' in London:
<p><a href="http://blufiles.storage.msn.com/y1pLfDzppuxasjQ9EPdHyj3QP83hXvEijC2MyRq9xN0_GOUelY JMA-wuT6jGTMFIxhN8QAZa3ajdOw"><img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" alt=06-small src="http://blufiles.storage.msn.com/y1pLfDzppuxashIyp4RajvezxjVA3SpVoiMaEazuBAVJzZ2Zfw EylBIVpgjLyzKJs3eUTOffBQ0Q4s" border=0></a>
<p>The <a href="http://mappointemea.members.winisp.net/IndividualShapes01/IndividualShapes01.aspx">sample application is also available here</a> and contains as always a download-link for the complete source-code.<img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4819404664324524694&page=RSS%3a+How+to+bring+your+own+content+to+Virtu al+Earth+(Part+2)&referrer=" width="1px" height="1px" border="0" alt=""><img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&NA=1149&PI=88469&RF=&DI=3919&PS=85545&TP=johanneskebeck.spaces.live.com>1=JohannesKebeck">
Click here to view the article. (http://JohannesKebeck.spaces.live.com/Blog/cns!42E1F70205EC8A96!1792.entry)