<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Everything Silverlight &#187; map</title>
	<atom:link href="http://www.michaelsnow.com/tag/map/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelsnow.com</link>
	<description></description>
	<lastBuildDate>Thu, 28 Apr 2011 21:43:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Silverlight Tip of the Day #36 &#8211; Creating Smooth Tile Transitions using Opacity Masks</title>
		<link>http://www.michaelsnow.com/2010/10/22/silverlight-tip-of-the-day-36-creating-smooth-tile-transitions-using-opacity-masks/</link>
		<comments>http://www.michaelsnow.com/2010/10/22/silverlight-tip-of-the-day-36-creating-smooth-tile-transitions-using-opacity-masks/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 23:08:59 +0000</pubDate>
		<dc:creator>Snowman</dc:creator>
				<category><![CDATA[game programming]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[map]]></category>

		<guid isPermaLink="false">http://www.michaelsnow.com/2010/10/22/silverlight-tip-of-the-day-36-creating-smooth-tile-transitions-using-opacity-masks/</guid>
		<description><![CDATA[This tutorial will look into using the Opacity property on the tiles to create smooth, natural looking transitions between tiles. For example, blending a dirt tile into a grass tile, a grass tile into a rock tile, etc. Below, on the left, is a screen shot of a grass and dirt tile without the use [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will look into using the Opacity property on the tiles to create smooth, natural looking transitions between tiles. For example, blending a dirt tile into a grass tile, a grass tile into a rock tile, etc. </p>
<p>Below, on the left, is a screen shot of a grass and dirt tile <em>without</em> the use of an opacity mask. As you can see, the straight line does not make for a very real looking transition! On the right is the result with an opacity mask applied, making for a much more realistic transition.</p>
<table border="0" cellspacing="0" cellpadding="2" width="544">
<tbody>
<tr>
<td valign="top" width="275"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_4.png" /></td>
<td valign="top" width="2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </td>
<td valign="top" width="265"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_6.png" /></td>
</tr>
</tbody>
</table>
<p>So how does this work? What we do is we put down a grass layer followed by a layer of dirt on the same tile location. We then apply an Opacity mask to the dirt image which tells Silverlight what level of rendering to do on each pixel within the dirt image.</p>
<p>Example:</p>
<p>&#160;</p>
<table border="0" cellspacing="0" cellpadding="2" width="429">
<tbody>
<tr>
<td valign="top" width="130">
<p align="center">Layer 1</p>
</td>
<td valign="top" width="13">+</td>
<td valign="top" width="128">
<p align="center">Layer 2</p>
</td>
<td valign="top" width="12">+</td>
<td valign="top" width="130">
<p align="center">Opacity Mask</p>
</td>
<td valign="top" width="12">=</td>
<td valign="top" width="2">
<p align="center">Final Result</p>
</td>
</tr>
<tr>
<td valign="top" width="130"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_8.png" width="128" height="128" /></td>
<td valign="top" width="13">&#160;</td>
<td valign="top" width="128"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_22.png" width="128" height="128" /></td>
<td valign="top" width="12">&#160;</td>
<td valign="top" width="130"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_12.png" width="128" height="128" /></td>
<td valign="top" width="12">&#160;</td>
<td valign="top" width="2"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_16.png" width="128" height="128" /></td>
</tr>
</tbody>
</table>
</p>
<p>The checker boxes in the opacity image (image #3) above represent the areas that are transparent in the PNG opacity mask. In this area, the image will not be drawn allowing any image below it show through.</p>
<p>Here’s how it looks in our XAML code:</p>
<div class="csharpcode">
<pre class="alt">&lt;Image Source=<span class="str">&quot;grass.png&quot;</span>&gt;&lt;/Image&gt;</pre>
<pre>&lt;Image Source=<span class="str">&quot;dirt.png&quot;</span> &gt;</pre>
<pre class="alt">    &lt;Image.OpacityMask &gt;</pre>
<pre>        &lt;ImageBrush ImageSource=<span class="str">&quot;opacityMask.png&quot;</span>&gt;&lt;/ImageBrush&gt;</pre>
<pre class="alt">    &lt;/Image.OpacityMask&gt;</pre>
<pre>&lt;/Image&gt;</pre>
</div>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>Using a PNG image file, transparency is represented by the alpha value only. All the other colors in this image have no impact. Each color is represented by “#AARRGGBB” where AA=alpha hex value, RR=red hex value, GG=green hex value and BB= blue hex value.&#160; Transparency in a pixel increases starting at #00000000 (completely non-transparent) to #FF000000 (completely transparent.</p>
<p>If you do not want to use an image for your opacity mask, you can also use a Brush. For example, this tile shows a transition using a LinearImageBrush:</p>
<table border="0" cellspacing="0" cellpadding="2" width="429">
<tbody>
<tr>
<td valign="top" width="130">
<p align="center">Layer 1</p>
</td>
<td valign="top" width="13">+</td>
<td valign="top" width="128">
<p align="center">Layer 2</p>
</td>
<td valign="top" width="12">+</td>
<td valign="top" width="130">
<p align="center">Opacity Mask</p>
</td>
<td valign="top" width="12">=</td>
<td valign="top" width="2">
<p align="center">Final Result</p>
</td>
</tr>
<tr>
<td valign="top" width="130"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_22.png" width="128" height="128" /></td>
<td valign="top" width="13">&#160;</td>
<td valign="top" width="128"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_20.png" width="128" height="128" /></td>
<td valign="top" width="12">&#160;</td>
<td valign="top" width="130"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_18.png" width="128" height="128" /></td>
<td valign="top" width="12">&#160;</td>
<td valign="top" width="2"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_16.png" /></td>
</tr>
</tbody>
</table>
<p>&#160;</p>
</p>
</p>
<p>Here is the XAML code:</p>
<div class="csharpcode">
<pre class="alt">&lt;Image Source=<span class="str">&quot;grass.png&quot;</span>&gt;&lt;/Image&gt;</pre>
<pre>&lt;Image Source=<span class="str">&quot;dirt.png&quot;</span>&gt;</pre>
<pre class="alt">    &lt;Image.OpacityMask &gt;</pre>
<pre>        &lt;LinearGradientBrush StartPoint=<span class="str">&quot;0,0.5&quot;</span> EndPoint=<span class="str">&quot;1,0.5&quot;</span>&gt;</pre>
<pre class="alt">            &lt;GradientStop Color=<span class="str">&quot;#FF000000&quot;</span> Offset=<span class="str">&quot;0.0&quot;</span> /&gt;</pre>
<pre>            &lt;GradientStop Color=<span class="str">&quot;#00000000&quot;</span> Offset=<span class="str">&quot;1.0&quot;</span> /&gt;</pre>
<pre class="alt">        &lt;/LinearGradientBrush&gt;</pre>
<pre>    &lt;/Image.OpacityMask&gt;</pre>
<pre class="alt">&lt;/Image&gt;</pre>
</div>
<p>&#160;</p>
<p>Using other brush types, such as the RadialGradientBrush, you can do a lot of other cool effects.</p>
<p>Example:</p>
<p>&#160;</p>
<table border="0" cellspacing="0" cellpadding="2" width="429">
<tbody>
<tr>
<td valign="top" width="130">
<p align="center">Layer 1</p>
</td>
<td valign="top" width="13">+</td>
<td valign="top" width="128">
<p align="center">Layer 2</p>
</td>
<td valign="top" width="12">+</td>
<td valign="top" width="130">
<p align="center">Opacity Mask</p>
</td>
<td valign="top" width="12">=</td>
<td valign="top" width="2">
<p align="center">Final Result</p>
</td>
</tr>
<tr>
<td valign="top" width="130"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_20.png" width="127" height="128" /></td>
<td valign="top" width="13">&#160;</td>
<td valign="top" width="128"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_22.png" width="128" height="128" /></td>
<td valign="top" width="12">&#160;</td>
<td valign="top" width="130"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_26.png" width="128" height="128" /></td>
<td valign="top" width="12">&#160;</td>
<td valign="top" width="2"><img src="http://silverlight.net/blogs/msnow/WindowsLiveWriter/TerrainTutorialPart3CreatingSmoothTileTr_E831/image_24.png" width="128" height="128" /></td>
</tr>
</tbody>
</table>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</p>
</p>
<p>XAML Code:</p>
<div class="csharpcode">
<pre class="alt">&lt;Image Source=<span class="str">&quot;grass.png&quot;</span>&gt;&lt;/Image&gt;</pre>
<pre>&lt;Image Source=<span class="str">&quot;dirt.png&quot;</span>&gt;</pre>
<pre class="alt">    &lt;Image.OpacityMask &gt;</pre>
<pre>        &lt;RadialGradientBrush GradientOrigin=<span class="str">&quot;1,0&quot;</span>&gt;</pre>
<pre class="alt">            &lt;GradientStop Color=<span class="str">&quot;#FF000000&quot;</span> Offset=<span class="str">&quot;0.0&quot;</span> /&gt;</pre>
<pre>            &lt;GradientStop Color=<span class="str">&quot;#FF000000&quot;</span> Offset=<span class="str">&quot;0.25&quot;</span> /&gt;</pre>
<pre class="alt">            &lt;GradientStop Color=<span class="str">&quot;#AE000000&quot;</span> Offset=<span class="str">&quot;0.75&quot;</span> /&gt;</pre>
<pre>            &lt;GradientStop Color=<span class="str">&quot;#00000000&quot;</span> Offset=<span class="str">&quot;1.0&quot;</span> /&gt;</pre>
<pre class="alt">        &lt;/RadialGradientBrush&gt;</pre>
<pre>    &lt;/Image.OpacityMask&gt;</pre>
<pre class="alt">&lt;/Image&gt;</pre>
</div>
<p>&#160;</p>
<p>Thank you,<br />
  <br />&#8211;Mike Snow </p>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelsnow.com/2010/10/22/silverlight-tip-of-the-day-36-creating-smooth-tile-transitions-using-opacity-masks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Silverlight Tip of the Day #19 &#8211; Using Bing Maps in Silverlight</title>
		<link>http://www.michaelsnow.com/2010/05/12/silverlight-tip-of-the-day-19-using-bing-maps-in-silverlight/</link>
		<comments>http://www.michaelsnow.com/2010/05/12/silverlight-tip-of-the-day-19-using-bing-maps-in-silverlight/#comments</comments>
		<pubDate>Wed, 12 May 2010 16:18:09 +0000</pubDate>
		<dc:creator>Snowman</dc:creator>
				<category><![CDATA[big maps]]></category>
		<category><![CDATA[mike.snow]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[map]]></category>

		<guid isPermaLink="false">http://www.silverlightdev.net/2010/05/12/silverlight-tip-of-the-day-19-using-bing-maps-in-silverlight/</guid>
		<description><![CDATA[Creating a Silverlight application with a Bing Map control is surprising easy. To do this, start by downloading the Bing Maps Silverlight Control SDK which can be found by clicking here. Once installed, follow these steps to get Bing Maps loaded in your Silverlight application: Open your Silverlight application. In the Solution Explorer, right click [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a Silverlight application with a Bing Map control is surprising easy. To do this, start by downloading the <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=beb29d27-6f0c-494f-b028-1e0e3187e830">Bing Maps Silverlight Control SDK</a> which can be found by clicking <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=beb29d27-6f0c-494f-b028-1e0e3187e830">here</a>.</p>
<p>Once installed, follow these steps to get Bing Maps loaded in your Silverlight application:</p>
<ol>
<li>Open your Silverlight application. </li>
<li>In the Solution Explorer, right click on Reference for your Silverlight app and add a reference to: Microsoft.Maps.MapControl.dll as well as Microsoft.Maps.MapControl.Common.dll. Both of these DLL’s where in my C:\Program Files (x86)\Bing Maps Silverlight Control\V1\Libraries folder. </li>
<li>Open MainPage.xaml. Add a reference to these assemblies in your UserControl: </li>
<li></li>
</ol>
<pre class="csharpcode">xmlns:m=<span class="str">&quot;clr-namespace:Microsoft.Maps.MapControl; assembly=Microsoft.Maps.MapControl&quot;</span> </pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Next, declare the Map control like this:</p>
<div class="csharpcode">
<pre class="alt">&lt;Grid x:Name=<span class="str">&quot;LayoutRoot&quot;</span> Background=<span class="str">&quot;White&quot;</span>&gt;     </pre>
<pre>   &lt;m:Map CredentialsProvider=<span class="str">&quot;&quot;</span> Name=<span class="str">&quot;myMap&quot;</span> /&gt; </pre>
<pre class="alt">&lt;/Grid&gt; </pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><span style="color: blue"><br />
    <br /></span></p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>At this point you will see the Map rendering in the designer as seen in the screenshot below:</p>
<p><a href="http://www.michaelsnow.com/wp-content/uploads/2010/06/image2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.michaelsnow.com/wp-content/uploads/2010/06/image_thumb1.png" width="435" height="322" /></a></p>
<p>CrendentialsProvider is the API key you get when you register with the Bing Maps Account center. This is a easy, straight forward process that can be done here: <a title="https://www.bingmapsportal.com/" href="https://www.bingmapsportal.com/">https://www.bingmapsportal.com/</a>. Once on the site click on the Create a Bing Maps account in the left hand side of the page. Once you create the account the key will be automatically provided for you.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:2d2c321f-e81d-41af-ba39-28cce7f8a6ee" class="wlWriterEditableSmartContent">
<p>Source: <a href="http://www.michaelsnow.com/wp-content/uploads/2010/06/Tip19_BingMaps1.zip" target="_blank">Tip19_BingMaps.zip</a></p>
</div>
<p>Demo:</p>
<p>[silverlight: Tip19_BingMaps.xap]</p>
<p>Thank you,<br />
  <br />&#8211;Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelsnow.com/2010/05/12/silverlight-tip-of-the-day-19-using-bing-maps-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

