4 Replies Latest reply on Aug 25, 2009 8:57 AM by Sar975

    Yahoo Maps API


      I took the sample yahoo maps api applications on the yahoo developer network but when you run them in flex builder with your local server running as localhost you get a security sandbox error.  Has anyone been able to render one of these maps from localhost through flex builder?  I'm currently using flex builder 3.  I tried registering localhost with the yahoo api key generator since it looks like you need to to get through the crossdomain policy for yahoo services but it didnt work.  Let me know if this is possible if anyone has successfully done this.  Thanks.

        • 1. Re: Yahoo Maps API

          check the below code with the you key


          for more documentation visit the site  http://developer.yahoo.com/flash/maps/



          if this post answers your question. Please mark it as such


          <?xml version="1.0" encoding="utf-8"?> 


              Copyright (c) 2008 Yahoo! Inc.  All rights reserved. 

              The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license








              <mx:Panel title="Yahoo! Maps - Simple Flex Example" top="5" left="5" bottom="5" right="5">

                  <!-- This is the map container, the YahooMap component extends Sprite, so you must add it to a UIComponent. -->

                  <mx:UIComponent id="mapContainer" width="100%" height="100%"/>





                      import mx.events.ResizeEvent;


                      // import maps classes.

                      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 handleCreationComplete():void 


                          // this examples uses an application id passed into the app via FlashVars.

                          // Get your own from the Yahoo! Developer Network @ http://developer.yahoo.com/wsregapp/

                          var appid:String = Application.application.parameters.appid;


                          // create a new YahooMap object.

                          _yahooMap = new YahooMap();


                          // list for the MAP_INITIALIZE event from YahooMap

                          _yahooMap.addEventListener(YahooMapEvent.MAP_INITIALIZE, handleMapInitialize);


                          // initialize the map, passing the app-id, width and height.




                          mapContainer.addEventListener(ResizeEvent.RESIZE, handleContainerResize);







                      private function handleMapInitialize(event:YahooMapEvent):void 


                          // creating a new address object, passing our address string as the single parameter.

                          _address = new Address("141 pike st. seattle,wa");


                          // listen for the GEOCODER_SUCCESS event dispatched when the data comes back from the webservice.

                          _address.addEventListener(GeocoderEvent.GEOCODER_SUCCESS, handleGeocodeSuccess);


                          // send the geocode request.




                      private function handleGeocodeSuccess(event:GeocoderEvent):void 


                          // retrieve the first result returned by the geocoder.

                          var result:GeocoderResult = _address.geocoderResultSet.firstResult;


                          // then we'll get the zoom level and center latlon to position the map on.

                          _yahooMap.zoomLevel = result.zoomLevel;

                          _yahooMap.centerLatLon = result.latlon;




                      private function handleContainerResize(event:ResizeEvent):void {

                          // set the size of the map based on its containers size.






          • 2. Re: Yahoo Maps API
            Sar975 Level 1

            I have the sample code already that's not the problem.  The issue is that if I register the key to http://localhost:8080/  when i launch and deploy I get the sandbox security error.

            • 3. Re: Yahoo Maps API
              babo_ya Level 3

              Not sure about Yahoo Map.


              I know for Google map you have to enter both URL & the key. Maybe you need a new key created using the localhost url?



              • 4. Re: Yahoo Maps API
                Sar975 Level 1

                I tried registering localhost already maybe it does not work well with anything besides port 80 in the url http://localhost/ as opposed to http://localhost:8080 for example.  I may just try the google maps too and see if that works any differently.