function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gtuerkgtuerk 

Flex 3 SWF with Google Maps API, authentication exception

I have a Flex 3 SWF that is a static resource I would like to use in one of my VF pages.  I registered for an API key for the following URL:

 

https://na6.salesforce.com/

 I've seen other posts with similar errors.  The error I get when I view the SWF from its location in Static Resources is different from the one I get as trapped by Visualforce

 

This is the Static Resource error on clicking 'view':

 

SecurityError: Error #2047: Security sandbox violation: parent: http://maps.googleapis.com/mapsapi/publicapi?file=flashapi&url=https%3A%2F%2Fna6.salesforce.com%2Fresource%2F1240709021000%2FGoogleMap&key=ABQIAAAAA7aFgeQgFpt9KTUNsnsLOxQwNgRt8BDbI5KFRawO0dUAA_H1zxQUyv2-vlR7Qh3Fo2Zda7t4mYGuww&v=1.9&flc=x cannot access https://na6.salesforce.com/resource/1240709021000/GoogleMap.
    at flash.display::DisplayObject/get parent()
    at com.google.maps.templates::BootstrapSwf/onAdded()

 

And the error from Visualforce:

 

Initialization failed: please check the API key,
swf location, version and network availability.

 

Any ideas what's going on with this?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
gtuerkgtuerk
I scraped the 'c.na6' url from the view page source and was able to create a key for that domain.  this worked for embedding the map

All Answers

Ron HessRon Hess

Adobe SWF sandbox is a complex topic, this error is not coming from Force.com.

 

There are several articles on adobe security on the Adobe site, read about sandbox security in detail.

 

your SWF is served from here :  https://na6.salesforce.com/

 

and you are trying to open a resource here :  http://maps.googleapis.com/mapsapi/publicapi

 

So, by Adobe's security policy, the site maps.googleapis.com must have a properly configured crossdomain.xml file that permits this.

 

 

You may have more luck looking at the Google Flash API, which is designed for Flash clients to talk to the maps API.

 

Then when that is working, you should be able to run out of a static resource on Force.com with no problem.

 

 

gtuerkgtuerk
Hey Ron.  Thanks for getting back to me.  I am using the Google Maps API for Flash (specifically, the SWC for Flex, v 1.9).  I have a post in to the Google Group that support the API.  I'm a bit worried that this is a problem b/c of the https:// url as literature seems to indicate this is a problem for the Google Maps API for Flash.  Hopefully they have some workaround/assistance for me and then I'll post it here.  I know others will benefit from the info
gtuerkgtuerk

So I'm a little further along, thanks to help from the Google Maps API discussion forums.  Seems you must add a line to a start-up method in order to allow the Map server to talk to the SWF that holds the map.  Like so:

 

public function init():void{
            Security.allowInsecureDomain("maps.googleapis.com");            
        }

 

this gets called after creationComplete.

 

After adding this line, I can see the map in the uploaded Static Resource by clicking 'view' from the Static Resource.  When the resource is embedded in a VF page, I still get a security error.  Here's my VF page code.  Is there something missing in that page?  Why can I see this on the static resource page but not on the VF page?

 

<apex:page standardController="Location__c">
  <apex:form >
      <apex:pageBlock title="Flex implementation">
          <apex:flash id="flexSOs" src="{!$Resource.GoogleMap}" height="100%" width="100%"
          flashvars="session_id={!$Api.Session_ID}&server_url={!$Api.Partner_Server_URL_90}"/>
     </apex:pageBlock>
  </apex:form>
</apex:page>

 

Thanks

g

gtuerkgtuerk
I scraped the 'c.na6' url from the view page source and was able to create a key for that domain.  this worked for embedding the map
This was selected as the best answer
bbradybbrady

After following your guidance above, I created a key for the following URL:

 

https://c.na6.visual.force.com

 

When I typed the following in the browser (firefox) address line:

 

https://c.na6.visual.force.com/apex/GMapPage

 

 

I still experienced the problem you describe above.

 

 

I then deleted the "s" from "https" and was prompted to login once agin. I did so and voila, problem solved!

The map displayed.

 

Its worth noting (but not a surprise, given Ron's comments) that the key I generated enabled the map to display on VF page (in a DE org) but not when I clicked "Click here to view this file" in the static resources window of the Force.com UI. (BTW, I haven't yet experimented with this key in a sandbox or production org)

 

In any case, thanks much to you both for help to end the frustration!

 

bb

 

bbradybbrady

Here's the MXML and the Apex code that worked for me:

 

 

<?xml version="1.0" encoding="utf-8"?> <mx:Application creationComplete="init()" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:map="com.google.maps.*" layout="vertical" width="100%" height="100%" viewSourceURL="srcview/index.html"> <mx:HBox height="100%" width="100%"> <mx:DataGrid dataProvider="{this.acMarkers}" itemClick="showInfo(event)" height="100%" > <mx:columns> <mx:DataGridColumn headerText="Label" dataField="label"/> <mx:DataGridColumn headerText="Name" width="200"> <mx:itemRenderer> <mx:Component> <mx:Label text="{data.personInfo.name}"/> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> <mx:Panel title="Update DataGrid from a Map's InfoWindow" width="100%" height="100%"> <map:Map id="map" key="ABQIAAAARNirr2sT9pUTJa_GSfEM6xT-zg9ZsPJ7SHSAsA1SgzAAGPL_qBSj3iOCRMSF5Ygb6xTgFVGm6RErBQ" mapevent_mapready="onMapReady(event)" width="100%" height="100%"/> </mx:Panel> </mx:HBox> <mx:Script> <![CDATA[ import com.google.maps.controls.PositionControl; import com.google.maps.controls.ZoomControl; import com.google.maps.controls.MapTypeControl; import vo.PersonVO; import com.google.maps.InfoWindowOptions; import mx.events.ListEvent; import mx.collections.ArrayCollection; import com.google.maps.overlays.Marker; import com.google.maps.MapMouseEvent; import com.google.maps.MapEvent; import com.google.maps.LatLng; import com.google.maps.Map; import com.google.maps.MapType; public function init():void{ Security.allowInsecureDomain("maps.googleapis.com"); } private var apiKey:String = "ABQIAAAARNirr2sT9pUTJa_GSfEM6xT-zg9ZsPJ7SHSAsA1SgzAAGPL_qBSj3iOCRMSF5Ygb6xTgFVGm6RErBQ"; [Bindable] private var acMarkers:ArrayCollection = new ArrayCollection(); private function onMapReady(event:Event):void { map.setCenter(new LatLng(37.873684, -122.467680),17,MapType.NORMAL_MAP_TYPE); map.addControl(new ZoomControl); map.addControl(new PositionControl); map.addControl(new MapTypeControl); map.enableScrollWheelZoom(); map.enableContinuousZoom(); map.addEventListener(MapMouseEvent.CLICK, addMarker); map.openInfoWindow(map.getCenter(), new InfoWindowOptions({content: "Click to add markers!"})); } private function addMarker(e:MapMouseEvent):void { map.closeInfoWindow(); var marker:Marker = new Marker(e.latLng); var label:String = 'Person ' + acMarkers.length; var personInfo:PersonVO = new PersonVO(); var nameInput:NameInput = new NameInput(); nameInput.setPersonInfo(personInfo); nameInput.setMarker(marker); acMarkers.addItem({label: label, marker: marker, personInfo:personInfo}); marker.addEventListener(MapMouseEvent.CLICK, function(e:Event):void { marker.openInfoWindow(new InfoWindowOptions({customContent:nameInput, width:300, drawDefaultFrame:true})); }); map.addOverlay(marker); marker.dispatchEvent(new MapMouseEvent(MapMouseEvent.CLICK, marker, marker.getLatLng(), true, false)); } private function showInfo(event:ListEvent):void { var marker:Marker = event.itemRenderer.data.marker as Marker; marker.dispatchEvent(new MapMouseEvent(MapMouseEvent.CLICK, marker, marker.getLatLng(), true, false)); } ]]> </mx:Script> </mx:Application>

 

 

<apex:page sidebar="false"> <apex:flash src="{!$Resource.GMap}" flashvars="session_id={!$Api.Session_ID}&server_url={!$Api.Partner_Server_URL_90}" height="600" width="100%" /> </apex:page>