Hi, I am working on a web-tool that allows users to add pre-loaded tiles of data as overlays to Google Maps. I then want users to be able to save their work. I'm approaching this as them saving a series of images that they can then import to work and add text etc to a layout they choose. If you want to see it in action, it's available here: http://195.62.199.219/pctsla/gis/supporttool/
My issue is saving the map image. I started by trying to use BitmapData.draw() and the JPGEncoder class in the as3corelib and this works for the 2 legend images. It also works for the map when testing on my PC (and changing the Global Security Settings). As soon as you put it on the server it hangs at the BitmapData.draw() line, and I've since found out that this isn't resolvable: http://code.google.com/apis/maps/faq.html#bitmapdata So... I went back to trying to use map.getPrintableBitmap (which I'd previously discarded due to poor resolution). I can still pass this through JPGEncoder and am now happy with the resolution of the result. However, the code only runs when no overlays have been added to the map. My "save code" goes as follows: import JPGEncoder; Security.loadPolicyFile("195.62.199.219/pctsla/gis/supporttool/ crossdomain.xml"); //see note below //Security.allowDomain("http://maps.googleapis.com"); //I've tested this option too! Security.allowInsecureDomain("maps.googleapis.com"); /* Saving FileReference.save requires the user to have clicked a button... so on clicking save a message box is displayed and a user has to click a button for each component they wish to save. */ butSave.addEventListener(MouseEvent.CLICK, SaveMessage); function SaveMessage(event:MouseEvent):void { saveMsgBox.visible = true; this.setChildIndex(saveMsgBox, numChildren - 1); } // close the message box when the user presses cancel saveMsgBox.butCancel.addEventListener(MouseEvent.CLICK, closeSaveMsg); function closeSaveMsg(event:MouseEvent):void { if (saveMsgBox.visible = true) { saveMsgBox.visible = false; } } // save the map saveMsgBox.butSaveMap.addEventListener(MouseEvent.CLICK,saveMap); function saveMap(event:MouseEvent):void { map.removeControl(myZoomControl); map.removeControl(myPosControl); map.addControl(myScaleControl); //runs as far as this when overlay added var mapImage:Bitmap= map.getPrintableBitmap(); var mapImageArray:BitmapData = mapImage.bitmapData; var encoder:JPGEncoder = new JPGEncoder(); var rawBytes:ByteArray = encoder.encode(mapImageArray); var saveFileRef:FileReference = new FileReference(); saveFileRef.save(rawBytes,"my map.jpg"); map.removeControl(myScaleControl); map.addControl(myZoomControl); map.addControl(myPosControl); } I know a crossdomain.xml is required, but even with putting * in everywhere it didn't save the map once an overlay was added. My beta-test was supposed to go out to users about 2 weeks ago and time is now getting extremely tight (I really need it out in the next couple of days)! If anyone has any suggestions they would be very much appreciated. Note: PHP cannot be installed on the server I am working with for various reasons so I need to pursue other routes. Thank you, Hannah -- 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.
