Ok. Let me try this again with some code (hopefully that gets me a
huckleberry). I'm trying to access a kml file that is hosted on
dropbox, trying to prove that I can embed 'dynamic' kml output in a
SWF that is hosted on a secure domain. I would think it would be
simple but I'm getting Security Sandbox Violation errors that I cannot
resolve (although I have tried adding an allowInsecureDomain Security
call)
Please help.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:maps="com.google.maps.*"
xmlns:salesforce="http://www.salesforce.com/"
layout="absolute"
creationComplete="init(event);"
width="100%" height="100%"
viewSourceURL="srcview/index.html">
<salesforce:Connection id="connection"/>
<mx:Script>
<![CDATA[
import com.google.maps.services.ClientGeocoder;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import com.google.maps.*;
import com.google.maps.overlays.*;
import com.google.maps.controls.*;
import com.google.maps.services.*;
import com.google.maps.extras.xmlparsers.kml.*;
import com.salesforce.AsyncResponder;
import com.salesforce.objects.SObject;
import com.salesforce.objects.LoginRequest;
import com.salesforce.results.QueryResult;
private var alat:Number;
private var alon:Number;
private var zlat:Number;
private var zlon:Number;
public function init(event:Event):void{
/*var lr:LoginRequest = new LoginRequest();
lr.server_url = parameters.server_url;
lr.session_id = parameters.session_id;
lr.callback = new AsyncResponder(getLatLongs);
connection.login(lr);*/
Security.allowInsecureDomain("maps.googleapis.com");
Security.allowInsecureDomain("dl.getdropbox.com");
}
public function getLatLongs(o:Object):void{
connection.query("Select Id, Latitude__c, Longitude__c from
Building__c where Id IN ('" + parameters.aLocID + "','" +
parameters.zLocID + "')"
,new AsyncResponder(
function(qr:QueryResult):void{
alat = qr.records[0].Latitude__c;
alon = qr.records[0].Longitude__c;
zlat = qr.records[1].Latitude__c;
zlon = qr.records[1].Longitude__c;
prepareMap();
}));
}
private function prepareMap():void{
var aLat:Number = parseFloat(parameters.aLat);
var aLon:Number = parseFloat(parameters.aLon);
var aLatLng:LatLng = new LatLng(aLat, aLon);
var aOptions:MarkerOptions = new MarkerOptions({
strokeStyle: {color: 0x00FF00},
fillStyle: {color: 0x00FF00,alpha: 0.8},
label: "A",
labelFormat: {bold: false},
tooltip: "A Location",
radius: 12,
hasShadow: true,
clickable: false,
draggable: false,
gravity: 0.5,
distanceScaling: false
});
var aMarker:Marker = new Marker(aLatLng, aOptions);
map.addOverlay(aMarker);
map.setCenter(aLatLng, 15, MapType.NORMAL_MAP_TYPE);
//These are the controls that must be added for standard
behavior
map.addControl(new ScaleControl());
var myZoomControl:ZoomControl = new ZoomControl();
var position:ControlPosition = new ControlPosition
(ControlPosition.ANCHOR_TOP_LEFT, 10, 5);
myZoomControl.setControlPosition(position);
map.addControl(myZoomControl);
var myMapTypeControl:MapTypeControl = new MapTypeControl();
myMapTypeControl.setControlPosition(new ControlPosition
(ControlPosition.ANCHOR_TOP_RIGHT, 10, 5));
map.addControl(myMapTypeControl);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadKML);
loader.load(new URLRequest("http://dl.getdropbox.com/u/
470962/_mytrip.kml"));
}
private function loadKML(event:Event):void{
var kml:Kml22 = new Kml22(event.target.data);
var rootFeature:Feature = kml.feature;
trace(rootFeature.toString());
/* kmlObj:Object = new Object();
if(kml.feature == null)
{
trace("KML == NULL");
}
kmlObj.name = rootFeature.name;
*/
}
]]>
</mx:Script>
<mx:Panel height="100%" width="100%">
<maps:Map id="map" mapevent_mapready="prepareMap()"
key="{parameters.apiKey}"
height="100%" width="100%"/>
</mx:Panel>
</mx:Application>
On May 14, 2:24 pm, gtuerk <[email protected]> wrote:
> I've spent a few hours this morning sifting through various literature
> with an express goal of plotting somewhat dynamic data on Google Maps
> that are embedded in Flex. The kicker is that the SWF is hosted on a
> secure domain (on Salesforce.com) and I'm seeing Sandbox Security
> Violation errors that indicate to me I may be barking up the wrong
> tree.
>
> The business problem is that we store our KML files in a KMZ archive
> on a private LAN. For obvious reasons, I can't/don't want to allow
> the SWF to dip into this location. So I looked into sharing from
> Google Earth. I don't think that's the route I want to go. So then I
> wanted to see if I could get the kml file hosted on Google Docs (my
> organization is a Google Apps premier customer). The file type was
> prohibitive. Then I looked into Google Pages (a now defunct service,
> supplanted by Google Sites). It looks like Google Sites doesn't want
> to allow kml/kmz to be hosted. But Box.net and Dropbox do support
> direct downloads of hosted KML but I still run into the Sandbox
> security violation.
>
> I don't want to package the kml files with the compiled SWF because
> the KML files change very frequently (weekly or so) and I don't want
> to recompile to get those changes. Can anyone give me a good
> suggestion on this conundrum?
> thanks
> g
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API For Flash" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-maps-api-for-flash?hl=en
-~----------~----~----~----~------~----~------~--~---