Select to view content in your preferred language

Google Maps in Viewer for Flex && Multiple WMS layers

369
0
10-01-2012 02:50 AM
MarcinDruzgala
Occasional Contributor
Hi so i got two questions.

1. The first one is i want to add Google Maps to my basemaps list - i know google is no longer supporting Flash API but i wrote a simple application with JavaScript function which launchs google maps in my Flex app.(I've copied the "callWrapper" function from web).
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="application1_creationCompleteHandler(event)">
 
 <mx:Script>
  <![CDATA[
   import mx.events.FlexEvent;
   import flash.external.*;
   
   protected function application1_creationCompleteHandler(event:FlexEvent):void
   {
   }
   public function callWrapper():void {
    var s:String;
    if (ExternalInterface.available) {
     var wrapperFunction:String = "initialize";
     s = ExternalInterface.call(wrapperFunction);
    } else {
     s = "Wrapper not available";
    }
    trace(s); 
   }
  ]]>
 </mx:Script>
</mx:Application>

In index.template.html i added a few lines:
<script type="text/javascript"
      src="http://maps.googleapis.com/maps/api/js?key=[MYKEY]&sensor=false">
    </script>
    <script type="text/javascript">
      function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(-34.397, 150.644),
          zoom: 8,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),
            mapOptions);
      }
    </script>

My question is: Is it possible to add google maps to flex application throught javascript function? If 'yes', can you show me how to add these layers to basemaps?

2.Second question: Let's say I have few WMS layers(building, rivers, terrain, roads etc) how can add them to basemaps list under ONE icon or to LayerList widget as one element of this list? I want to show them in specified order so the building are not overlayed by terrain layer.
Tags (2)
0 Kudos
0 Replies