<?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>Blue Flex &#187; google maps</title>
	<atom:link href="http://kennethsutherland.com/category/google-maps/feed/" rel="self" type="application/rss+xml" />
	<link>http://kennethsutherland.com</link>
	<description>Flex with a hint of cool</description>
	<lastBuildDate>Wed, 18 Apr 2012 21:22:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Flex and Google Maps</title>
		<link>http://kennethsutherland.com/2009/05/08/flex-and-maps/</link>
		<comments>http://kennethsutherland.com/2009/05/08/flex-and-maps/#comments</comments>
		<pubDate>Fri, 08 May 2009 08:18:31 +0000</pubDate>
		<dc:creator>Kenneth</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[InfoWindowOptions]]></category>
		<category><![CDATA[panning]]></category>

		<guid isPermaLink="false">http://kennethsutherland.com/?p=249</guid>
		<description><![CDATA[I started to try out some flex with Google maps and it’s refreshingly straight forward. Virtually all of the information to do the below can be found here http://code.google.com/apis/maps/documentation/flash/reference.html   So I’m just going to highlight a couple of things I did that were not in the docs. Panning Panning, well there is an example [...]]]></description>
			<content:encoded><![CDATA[<p>I started to try out some flex with Google maps and it’s refreshingly straight forward.</p>
<p class="MsoNormal"><span>Virtually all of the information to do the below can be found here <a href="http://code.google.com/apis/maps/documentation/flash/reference.html">http://code.google.com/apis/maps/documentation/flash/reference.html</a></span></p>
<p class="MsoNormal"><span> <a title="Google Map" href="http://www.kennethsutherland.com/flex/maps/MapTest.html" target="_blank"><img class="aligncenter" title="click to see app" src="/flex/maps/maps (Small).jpg" alt="" width="640" height="332" /></a><br />
</span></p>
<p class="MsoNormal"><span>So I’m just going to highlight a couple of things I did that were not in the docs.</span></p>
<h4><span>Panning</span></h4>
<ul>
<li>
<p class="MsoListParagraph"><span>Panning, well there is an example on how to do panning in ‘tour de flex’ but it uses a very basic method to work out difference between 2 points, divide by 100 and just add difference to starting point using the timer function.</span></p>
</li>
</ul>
<p class="MsoListParagraph"><span>A much better way would be to use a Tween so that you can implement an easing function, but a tween will only do one value at a time and a point has two values.</span></p>
<p class="MsoListParagraph"><span>So I used the Move class. It moves an object from point A to point B which is exactly what I was after, but I just wanted the values as I’m not moving an object.</span></p>
<p class="MsoListParagraph"><span> Here is the actionscript code to implement it</span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//The move effect needs a target  otherwise it will NOT tween</span>
<span style="color: #009900; font-style: italic;">//so just create a temporary target</span>
<span style="color: #6699cc; font-weight: bold;">var</span> uiTemp <span style="color: #000066; font-weight: bold;">:</span> UIComponent = <span style="color: #0033ff; font-weight: bold;">new</span> UIComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
moveEffect = <span style="color: #0033ff; font-weight: bold;">new</span> Move<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//set up the move effect</span>
moveEffect<span style="color: #000066; font-weight: bold;">.</span>xFrom = currentLatLng<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span>
moveEffect<span style="color: #000066; font-weight: bold;">.</span>yFrom = currentLatLng<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span>
moveEffect<span style="color: #000066; font-weight: bold;">.</span>duration = <span style="color: #000000; font-weight:bold;">1500</span><span style="color: #000066; font-weight: bold;">;</span>
moveEffect<span style="color: #000066; font-weight: bold;">.</span>easingFunction = moveMap<span style="color: #000066; font-weight: bold;">;</span>
moveEffect<span style="color: #000066; font-weight: bold;">.</span>xTo = <span style="color: #004993;">Number</span><span style="color: #000000;">&#40;</span>mapDetails<span style="color: #000066; font-weight: bold;">.</span>lat<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
moveEffect<span style="color: #000066; font-weight: bold;">.</span>yTo = <span style="color: #004993;">Number</span><span style="color: #000000;">&#40;</span>mapDetails<span style="color: #000066; font-weight: bold;">.</span>long<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//on each update move the map</span>
<span style="color: #009900; font-style: italic;">//calls the map.setCenter method</span>
moveEffect<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>TweenEvent<span style="color: #000066; font-weight: bold;">.</span>TWEEN_UPDATE<span style="color: #000066; font-weight: bold;">,</span> updateMapPosition<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//at the end I open up the marker window</span>
moveEffect<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>TweenEvent<span style="color: #000066; font-weight: bold;">.</span>TWEEN_END<span style="color: #000066; font-weight: bold;">,</span> showMarker<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//Play effect, give it the target so that it actually plays</span>
moveEffect<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">play</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>uiTemp<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<h4>Marker Windows</h4>
<ul>
<li>
<p class="MsoListParagraph"><span>The information window that pops up beside the marker on the map needed to be an image with some text.<span>  </span>I never noticed any examples in the docs for this but I did see an example online so I thought I’d stick into this post as well to increase its coverage.</span></p>
<p class="MsoListParagraph"><span>Again very straight forward (Google really makes it easy for developers) check out the code below.</span></p>
</li>
</ul>
<p> </p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">//In order to open a window beside a marker you need a InfoWindowOptions</span>
<span style="color: #6699cc; font-weight: bold;">var</span> options<span style="color: #000066; font-weight: bold;">:</span>InfoWindowOptions = <span style="color: #0033ff; font-weight: bold;">new</span> InfoWindowOptions<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span>
    <span style="color: #009900; font-style: italic;">//This is the key line for making it into a custom window</span>
    <span style="color: #009900; font-style: italic;">//uiHolder is a Canvas (but it can be any UIComponent) and I'm sure you know what you can put into</span>
    <span style="color: #009900; font-style: italic;">//a UIComponent, anything you like :)</span>
    customContent<span style="color: #000066; font-weight: bold;">:</span> uiHolder<span style="color: #000066; font-weight: bold;">,</span>
&nbsp;
    padding <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000066; font-weight: bold;">,</span>
    <span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">262</span><span style="color: #000066; font-weight: bold;">,</span>
    <span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #000000; font-weight:bold;">262</span><span style="color: #000066; font-weight: bold;">,</span>
    drawDefaultFrame<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">true</span>
<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">//Take the marker that you wish the window to appear above and</span>
<span style="color: #009900; font-style: italic;">//call openInfoWindow and pass in the InfoWindowOptions you just created</span>
currentOpenMarker<span style="color: #000066; font-weight: bold;">.</span>openInfoWindow<span style="color: #000000;">&#40;</span>options<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p class="MsoNormal"><span> <a title="Google Map" href="http://kennethsutherland.com/flex/wendy/PaintingMaps.html" target="_blank">Click to open app in new window</a></span></p>
<p class="MsoNormal"><span><a title="Google Map" href="http://www.kennethsutherland.com/flex/maps/MapTest.html" target="_blank">Click to open app2 in new window</a><br />
</span></p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-7396620608505330";
google_ad_slot = "1277482570";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://kennethsutherland.com/2009/05/08/flex-and-maps/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

