topical media & game development
actionscript-map-create.mx
actionscript-map-create.mx
[swf]
flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="onCreationComplete(event)" width="100%">
<mx:Script>
<![CDATA[
// from http://www.umapper.com/maps/edit/id/12356/
// final: http://www.umapper.com/maps/view/id/12356
import com.afcomponents.umap.core.UMap;
import com.afcomponents.umap.interfaces.IOverlay;
import com.afcomponents.umap.overlays.Layer;
import com.afcomponents.umap.overlays.Marker;
import com.afcomponents.umap.styles.DropShadowStyle;
import com.afcomponents.umap.styles.GeometryStyle;
import com.afcomponents.umap.styles.GradientStyle;
import com.afcomponents.umap.styles.IconStyle;
import com.afcomponents.umap.styles.MarkerStyle;
import com.afcomponents.umap.styles.StrokeStyle;
import com.afcomponents.umap.styles.TextStyle;
import com.afcomponents.umap.types.Align;
import com.afcomponents.umap.types.LatLng;
import com.afcomponents.umap.types.Offset;
import flash.display.CapsStyle;
import flash.display.GradientType;
import flash.display.InterpolationMethod;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import flash.display.SpreadMethod;
import flash.geom.Matrix;
import flash.text.AntiAliasType;
import flash.text.GridFitType;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
function addOverlaysToUmap(map:UMap, ...args:Array):void{
var len:int = args.length;
for(var i:int=0; i<len; i++){
if(args[i] is IOverlay) map.addOverlay(args[i]);
}
}
function addOverlaysToLayers(layer:Layer, ...args:Array):void{
var len:int = args.length;
for(var i:int=0; i<len; i++){
if(args[i] is IOverlay) layer.addOverlay(args[i]);
}
}
// end
import com.afcomponents.umap.gui.*;
import com.afcomponents.umap.core.UMap;
import com.afcomponents.umap.types.LatLng;
import com.afcomponents.umap.providers.google.GoogleProvider; // not documented yet!
import mx.core.UIComponent;
private var map:UMap;
public function onCreationComplete(event:Event) : void
{
var ref:UIComponent = new UIComponent();
// from http://www.umapper.com/maps/edit/id/12356/
var _style1:IconStyle = new IconStyle({align:new Align(Align.CENTER, Align.BOTTOM), offset:new Offset(0, 0), scale:1, rotation:null, colorTransform:null});
var _style2:TextStyle = new TextStyle({antiAliasType:AntiAliasType.ADVANCED, autoSize:TextFieldAutoSize.LEFT, condenseWhite:true, embedFonts:null, gridFitType:GridFitType.PIXEL, sharpness:null, thickness:null, textFormat:new TextFormat("_sans", 12, 0x000000, null, null, null, "", "", TextFormatAlign.LEFT, null, null, null, null), wordWrap:null, multiline:null, selectable:null, html:null, styleSheet:null});
var _style3:DropShadowStyle = new DropShadowStyle({angle:15, distance:0.5, color:0x000000, alpha:0.6, blurX:3, blurY:3, strength:1, quality:1});
var _style4:GradientStyle = new GradientStyle({type:GradientType.LINEAR, colors:[0xDDDDDD,0xFFFFFF], alphas:[70,100], ratios:[200,255], matrix:new Matrix(-1.1211606022543737e-17, -0.06103515625, 0.06103515625, -1.1211606022543737e-17, 50, 50), spreadMethod:SpreadMethod.PAD, interpolationMethod:InterpolationMethod.RGB, focalPointRatio:null});
var _style5:StrokeStyle = new StrokeStyle({pixelHinting:true, noScale:LineScaleMode.NORMAL, capsStyle:CapsStyle.ROUND, jointStyle:JointStyle.ROUND, miterLimit:3});
var _style6:MarkerStyle = new MarkerStyle({radius:10, icon:null, iconStyle:_style1, label:true, shadow:true, labelStyle:_style2, shadowStyle:_style3, fill:GeometryStyle.RGB, fillRGB:0xCC0000, fillAlpha:1, fillGradient:_style4, fillBitmap:null, stroke:GeometryStyle.RGB, strokeRGB:0x000000, strokeAlpha:1, strokeThickness:1, strokeGradient:null, strokeStyle:_style5});
var _marker1:Marker = new Marker({id:23, name:"Creative Technology @ UTwente", description:"<TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Verdana\" SIZE=\"10\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">52.242700 / 6.853300</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Verdana\" SIZE=\"10\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">N 52° 14' 34'' E 6° 51' 12''</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Verdana\" SIZE=\"10\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">The Twente University is located in Enschede, Netherlands. It was founded in 1961, and is unique in that it is the only campus type university in the country. The emphasis is mainly on technical subjects combined with sociocultural aspects. The name refers to the Twente region situated in the eastern part of the Netherlands (<A HREF=\"http://en.wikipedia.org/wiki/Universiteit_Twente\" TARGET=\"\">wiki</A>)</FONT></P></TEXTFORMAT>", position:new LatLng(52.2427, 6.8533), infoStyle:{autoSize:"auto", contentStyle:{wordWrap:true, multiline:true, autoSize:"left", condenseWhite:true, html:true}}}, _style6);
var _layer1:Layer = new Layer();
addOverlaysToLayers(_layer1, _marker1);
map = new UMap(); // com.afcomponents.umap.providers.*
addOverlaysToUmap(map, _layer1);
map.setCenter(new LatLng(52.214338608258196, 6.83349609375), 12);
map.setZoom(12); // explicit
map.setSize(this.width, this.height);
ref.addChild(map);
mapCanvas.addChild(ref);
// define GoogleProvider with custom paths
var settings:URLRequest = new URLRequest("http://umap.s3.amazonaws.com/assets/xml/GoogleSettings.xml?rand=" + Math.random());
var language:URLRequest = new URLRequest("http://maps.google.com/maps?file=api&v=2")
var copyright:URLRequest = new URLRequest("http://www.afcomponents.com/proxy/g_map_as3/copyright.php");
map.setProvider (new GoogleProvider(false, settings, language, copyright));
ref.focusManager.deactivate();
map.addControl(new MapTypeControl());
map.addControl(new ZoomControl());
map.addControl(new PositionControl());
}
]]>
</mx:Script>
<mx:VBox>
<mx:Canvas id="mapCanvas" width="100%" height="100%" backgroundColor="#352D69" x="6" y="10"/>
</mx:VBox>
</mx:Application>
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.