<?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>Flex Examples &#187; Mapping</title>
	<atom:link href="http://blog.flexexamples.com/category/mapping/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Google Maps in a Flex project</title>
		<link>http://blog.flexexamples.com/2008/08/03/using-google-maps-in-a-flex-project/</link>
		<comments>http://blog.flexexamples.com/2008/08/03/using-google-maps-in-a-flex-project/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 06:23:26 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Mapping]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/03/using-google-maps-in-a-flex-project/</guid>
		<description><![CDATA[<p>The following example shows how you can embed a Google map into a Flex/ActionScript 3.0 project.</p> <p>Full code after the jump.</p> <p></p> <p>Before getting started, you need to first get an API key from Google and then download the mapping component and put it in your /libs/ folder in your Flex Builder 3 project:</p> <a [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can embed a Google map into a Flex/ActionScript 3.0 project.</p>
<p>Full code after the jump.</p>
<p><span id="more-729"></span></p>
<p>Before getting started, you need to first get an API key from Google and then download the mapping component and put it in your /libs/ folder in your Flex Builder 3 project:</p>
<ul>
<li><a href="http://code.google.com/apis/maps/signup.html">Click here to get Google Maps API key</a>.</li>
<li><a href="http://maps.googleapis.com/maps/flash/release/sdk.zip">Click here to download the Google Maps ActionScript 3.0 component</a>.</li>
<li>Copy the map_flex_1_5.swc file from the .ZIP file&#8217;s /lib/ directory and copy it into your Flex Project&#8217;s /libs/ directory.</li>
</ul>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/GoogleMap_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/03/using-google-maps-in-a-flex-project/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import com.google.maps.LatLng;
            import com.google.maps.Map;
            import com.google.maps.MapEvent;
            import com.google.maps.controls.MapTypeControl;
            import com.google.maps.controls.PositionControl;
            import com.google.maps.controls.ZoomControl;
            import com.google.maps.services.ClientGeocoder;
            import com.google.maps.services.GeocodingEvent;
            import com.google.maps.services.GeocodingResponse;
            import com.google.maps.services.Placemark;
            import mx.controls.Alert;
            import mx.events.ResizeEvent;

            private var googleMap:Map;
            private var geocoder:ClientGeocoder;

            private function init():void {
                googleMap = new Map();
                googleMap.key = APP_ID;
                googleMap.addEventListener(MapEvent.MAP_READY, googleMap_mapReady);
                googleMap.setSize(new Point(mapContainer.width, mapContainer.height));
                googleMap.addControl(new ZoomControl());
                googleMap.addControl(new MapTypeControl());

                mapContainer.addChild(googleMap);
            }

            private function geocoder_geocodingSuccess(evt:GeocodingEvent):void {
                var result:Placemark = GeocodingResponse(evt.response).placemarks[0];
                googleMap.setCenter(result.point, 13);
            }

            private function geocoder_geocodingFailure(evt:GeocodingEvent):void {
                Alert.show("Unable to geocode address: " + evt.name);
            }

            private function googleMap_mapReady(evt:MapEvent):void {
                geocoder = new ClientGeocoder();
                geocoder.addEventListener(GeocodingEvent.GEOCODING_SUCCESS, geocoder_geocodingSuccess);
                geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE, geocoder_geocodingFailure);
                geocoder.geocode(textInput.text);
            }

            private function button_click(evt:MouseEvent):void {
                geocoder.geocode(textInput.text);
            }

            private function mapContainer_resize(evt:ResizeEvent):void {
                if (googleMap) {
                    googleMap.setSize(new Point(mapContainer.width, mapContainer.height));
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:String id="APP_ID" source="appid.txt" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="Address:"
                    direction="horizontal"&gt;
                &lt;mx:TextInput id="textInput"
                        text="601 Townsend St, San Francisco, CA 94103" /&gt;
                &lt;mx:Button id="button"
                        label="Submit"
                        click="button_click(event);" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:UIComponent id="mapContainer"
            width="100%"
            height="100%"
            resize="mapContainer_resize(event);" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/GoogleMap_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/GoogleMap_test/bin/main.html" width="100%" height="500"></iframe></p>
<p>For more information and examples, see the <a href="http://code.google.com/apis/maps/documentation/flash/">&#8220;Google Maps API for Flash homepage&#8221;</a>.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using Google Maps in a Flex project on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/03/using-google-maps-in-a-flex-project/',contentID: 'post-729',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: '',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/08/03/using-google-maps-in-a-flex-project/feed/</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>Using Yahoo! Maps in a Flex project</title>
		<link>http://blog.flexexamples.com/2008/08/03/using-yahoo-maps-in-a-flex-project/</link>
		<comments>http://blog.flexexamples.com/2008/08/03/using-yahoo-maps-in-a-flex-project/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 00:16:04 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Yahoo!]]></category>
		<category><![CDATA[Yahoo! Maps]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/03/using-yahoo-maps-in-a-flex-project/</guid>
		<description><![CDATA[<p>The following example shows how you can embed a Yahoo! map into a Flex/ActionScript 3.0 project.</p> <p>Full code after the jump.</p> <p></p> <p>Before getting started, you need to first get an API key from Yahoo! and then download the mapping component and put it in your /libs/ folder in your Flex Builder 3 project:</p> <a [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can embed a Yahoo! map into a Flex/ActionScript 3.0 project.</p>
<p>Full code after the jump.</p>
<p><span id="more-728"></span></p>
<p>Before getting started, you need to first get an API key from Yahoo! and then download the mapping component and put it in your /libs/ folder in your Flex Builder 3 project:</p>
<ul>
<li><a href="http://developer.yahoo.com/wsregapp/">Click here to get Yahoo! Maps API key</a>.</li>
<li><a href="http://developer.yahoo.com/flash/maps/getLatest.php">Click here to download the Yahoo! Maps ActionScript 3.0 component</a>.</li>
<li>Copy the YahooMap.swc file from the .ZIP file&#8217;s /YahooMap/Build/Flex/ directory and copy it into your Flex Project&#8217;s /libs/ directory.</li>
</ul>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/YahooMap_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/03/using-yahoo-maps-in-a-flex-project/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ResizeEvent;
            import mx.controls.Alert;

            import com.yahoo.maps.api.YahooMap;
            import com.yahoo.maps.api.YahooMapEvent;
            import com.yahoo.maps.api.core.location.Address;
            import com.yahoo.maps.webservices.geocoder.GeocoderResult;
            import com.yahoo.maps.webservices.geocoder.events.GeocoderEvent;

            private var yahooMap:YahooMap;
            private var address:Address;

            private function init():void {
                yahooMap = new YahooMap();
                yahooMap.init(APP_ID, mapContainer.width, mapContainer.height);
                yahooMap.addPanControl();
                yahooMap.addZoomWidget();
                yahooMap.addTypeWidget();
                mapContainer.addChild(yahooMap);

                geocodeAddress(textInput.text);
            }

            private function geocodeAddress(value:String):void {
                address = new Address(value);
                address.addEventListener(GeocoderEvent.GEOCODER_SUCCESS, address_geocoderSuccess);
                address.addEventListener(GeocoderEvent.GEOCODER_FAILURE, address_geocoderFailure);
                address.geocode();
            }

            private function address_geocoderSuccess(evt:GeocoderEvent):void {
                var result:GeocoderResult = Address(evt.target).geocoderResultSet.firstResult;
                yahooMap.centerLatLon = result.latlon;
                yahooMap.zoomLevel = result.zoomLevel;
            }

            private function address_geocoderFailure(evt:GeocoderEvent):void {
                Alert.show("Unable to geocode address: " + address.address);
            }

            private function mapContainer_resize(evt:ResizeEvent):void {
                if (yahooMap) {
                    yahooMap.setSize(mapContainer.width, mapContainer.height);
                }
            }

            private function button_click(evt:MouseEvent):void {
                geocodeAddress(textInput.text);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:String id="APP_ID" source="appid.txt" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="Address:"
                    direction="horizontal"&gt;
                &lt;mx:TextInput id="textInput"
                        text="601 Townsend St, San Francisco, CA 94103" /&gt;
                &lt;mx:Button id="button"
                        label="Submit"
                        click="button_click(event);" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:UIComponent id="mapContainer"
            width="100%"
            height="100%"
            resize="mapContainer_resize(event);"/&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/YahooMap_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/YahooMap_test/bin/main.html" width="100%" height="400"></iframe></p>
<p>For more information and examples, see the <a href="http://developer.yahoo.com/flash/maps/">&#8220;Yahoo! Maps ActionScript 3.0 Component homepage&#8221;</a>.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using Yahoo! Maps in a Flex project on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/03/using-yahoo-maps-in-a-flex-project/',contentID: 'post-728',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: '',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/08/03/using-yahoo-maps-in-a-flex-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

