Posts

Showing posts from 2007

Minn IT Symposium

Sorry for the delay folks. As promised, you can download the presentation and the samples . Thank you for all that attended, and hope to hear from you.

The Flex Show

Listen to me being interviewed on The Flex Show .  I'm talking (with my very heavy accent and my rolling r's :-) about AWX, Spring, the Minneapolis bridge application and lot's of other stuff.  Tell me what you think.  I had a great time doing it.

Java To AS3 on AIR

Image
Found this great project that enables me to convert Java code to ActionScript3 code, or at least get me close enough that I can do minor manual tweaks to get code to compile (granted that compiled code does not mean that it runs :-). However, in its current format, it was a laborious process as I can only process one file at the time, and had to copy and paste the generated code from the text area into a file. There must be a better way ! And yes there is a better way using Adobe AIR . AIR enables me to read from and write to the local file system. So, I took the core Converter class and wrapped it with the AIR File api. A user can now select the output folder and upon the selection of the input folder, all the java files will be read, converted and written to the output folder. In addition, you can drag and drop onto the output or input button the output or input folder. Download the AIR file from here . BTW - this is using the latest beta3 version :-)

Granite Data Services

I love Life Cycle Data Services . As a developer, IMHO, I think it is worth its weight in gold. However, I do get customers that want to do remoting with it :-( So...since HTTPService and WebService are first class citizens in Flex, I recommend that they SOAP enable their server side services, or come up with some kind of XML representation and XML over HTTP since XML is a native type in AS3. But the serialization/deserializtion is costly, and it would be great if we can use the flash native binary format (AMF) to transfer objects around. Thus enters Granite . Quoting from the introduction "Granite Data Services (GDS) is a free, open source (LGPL'd), alternative to Adobe® LiveCycle® (Flex™ 2) Data Services for J2EE application servers. It is not, however, a drop-in replacement: you won't be able to simply deploy a Flex 2 Data Services application into a Granite Data Services server without modifications. The main goal of this project is to provide a framework for Flex 2/EJ...

GeoRSS Support

AWX has GeoRSS support. So given for example the following feed (on my local machine I can access it as http://ccccmac/~mansour/geofeed.xml): <?xml version="1.0"?> <rss xmlns:georss="http://www.georss.org/georss" version="2.0">  <channel>   <title>GeoRSS-Simple Example</title>   <description>Example GeoRSS-Simple Feed</description>   <georss:box>38.373576,-122.854022,38.423121,-122.804327</georss:box>   <item>    <title>GeoRSS-Simple Polygon</title>    <description>A polygon describes an arbitrary geographic shape. The    format is a series of ordered latitude, longitude pairs. The last pair    must be the same as the first pair, closing t...

10000 Markers

Been wanting to blog about this for a while. Users been asking me "how to I plot thousands of markers without the overhead of a Marker (which is a subclass of UIComponent) but still get the benefits of Marker mostly for mouse over/out/click events ?". Back in the days when I was RAT (Rent-a-Tech), my friend Leo came up with a concept of TurboLayer for SDE, where you group in one feature all the geometries of a feature class. It was fast, but you could not get to an individual feature because it was all "blob'ed" together (SDE folks out there, you know what I mean :-) So I took the same concept and implemented it in AWX, but with an extra twist where you can get to an individual feature indirectly using an RTree class. An RTree enables you to efficiently index features spatially on the client side. cool, eh ? You can download this zip file that contains an application that loads 1000 random points and when you mouse over a point, a tooltip shows up with the id ...

DefaultProperty metadata

Looking back at the last post, yea... it is nice to MXML, but it is a bit ugly and verbose till I remembered the [DefaultProperty("xxxx")] metadata.   Adjusted my local copy and what you will get is this: <?xml version="1.0" encoding="utf-8"?> <mx:Application   xmlns:mx="http://www.adobe.com/2006/mxml"   xmlns:awx="http://www.arcwebservices.com/v2007/awx"   layout="absolute"   >   <awx:Framework/>   <awx:Map createDefaultLayers="false">     <awx:PolygonLayer>       <awx:Polygon>         <awx:PolygonShape>           <awx:GeoPoint x="45" y="45"/>           <awx:GeoPoint x="45" y="-45"/>           <awx:GeoPoint x="-45" y="0"/>          ...

Creating polygons in MXML

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:geom="com.esri.aws.awx.geom.*" xmlns:arcwebservices="http://www.arcwebservices.com/2007/awx" > <arcwebservices:Framework/> <arcwebservices:Map> <arcwebservices:basemaps> <arcwebservices:PolygonLayer> <arcwebservices:Polygon> <arcwebservices:shape> <geom:PolygonShape> <geom:geoPoints> <geom:GeoPoint x="45" y="45"/> <geom:GeoPoint x="45" y="-45"/> <geom:GeoPoint x="-45" y="45"/> </geom:geoPoints> </geom:PolygonShape> </arcwebservices:shape> </arcwebservices:Polygon> ...

AWX 4.0 Is Released !

Check out the latest version 4.0 - lots of bug fixes - great documentation.   And if you are wondering what happened to version 3.0, well...it was an internal release.   Have fun :-) Blogged with Flock

IntelliJ 7 Rocks

I've been using IDEA since I do not remember when.   Just got a license to the latest version .  It has great Spring support, and now you can see your web.xml files in this wizard cool panes.  In addition, there is support of AS3, I mean with auto-completion and refactoring. Too cool ! Blogged with Flock

Cairngorm and the Framework

People have been asking me to show them how to use Cairngorm with the AWX Framework that is loosely based on OSGi. The interaction will most likely come in an ICommand implementation or a Delegate.  Here is an example that shows how to use the Find Service. First, make sure that you have registered with the Framework the FindActivator. <Framework apiKey="[your-api-key]">   <FindActivator/> </Framework> Next, since a Command is always created and executed by the CairngormEventDispatcher,  you can always get a reference to the Framework through its static function getInstance() and then get a reference to systemBundleContext which is an IBundleContext implementation. package com.esri.awx {     import com.adobe.cairngorm.commands.ICommand;     import com.adobe.cairngorm.control.CairngormEvent;     import com.esri.aws.osgi.framework.Framework;     import com.esri.aws.osgi.framework.IBundleContext; ...

What beautifui HTML code looks like

Found this great link ! Updating my html samples :-) Blogged with Flock

How to find locations ?

So...if you want to find "380 new york st, redlands, ca" or "www.esri.com" or "909 793 285", you can use the IFind service. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:services="com.esri.aws.services.*" layout="absolute" > <mx:Script> <![CDATA[ import com.esri.aws.services.FindOptions; import com.esri.aws.services.FindResultSet; import com.esri.aws.services.GeocodeInfo; import mx.controls.Alert; import mx.collections.ItemResponder; import com.esri.aws.services.IFind; import flash.utils.getQualifiedClassName; import com.esri.aws.osgi.framework.IServiceReference; import com.esri.aws.osgi.framework.IBundleContext; private function doFind() : void { var context : IBundleContext = framewo...

Flickr Images as Markers

You can create BubbleMarkers that when expanded will display a Flickr image. In the below example, I'm creating a map, and when the user clicks on the search button, I'm searching any public image in the map extent. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:map="com.esri.aws.awx.map.*" layout="absolute" > <mx:Script> <![CDATA[ import mx.controls.Image; import com.esri.aws.awx.geom.PointShape; import com.esri.aws.awx.map.layers.overlays.BubbleMarker; import mx.controls.Alert; import com.esri.flickr.Photo; import mx.collections.ItemResponder; import mx.rpc.AsyncToken; import mx.rpc.http.HTTPService; import com.esri.aws.awx.geom.Extent; private function searchPhotos() : void { map.markerLayer.removeAllOverlays(); ...

Flex and OSGi

The AWX framework is based on a simplified OSGi implementation in AS3. The advent of flex modules made this implementation possible. The following is a simple walk-through that showcases how to use this solution. The idea is to define an interface whose implementation can be defined and discovered at runtime. Using FlexBuilder as a project manager makes things a bit easier. Create a flex library project named "FooAPI" to define the following interface. A SWC "FooAPI.swc" is generated upon the build in the "bin" directory. package com.esri.awx { public interface IFoo { function doFoo( text : String ) : String; } } Create a flex actionscript project named "FooBundle" - make sure to add the AWX swc as a project library and the "FooAPI" project. Modify the FooBundle.as class as follows: package { import com.esri.aws.osgi.framework.IBundleActivator; import com.esri.aws.osgi.framework.IBundleContext; import com.esri.awx.FooImpl; import ...

Hey ArcGIS users

You can create an ArcGIS Server based layer using the AWX Flex API. In the below sample, I'm loading a layer from a specified endpoint and then when I click click on the button, I'm turning off the "water" layer in the ArcGIS group layer. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:map="com.esri.aws.awx.map.*" xmlns:layers="com.esri.aws.awx.map.layers.*" layout="absolute" > <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.collections.ItemResponder; import com.esri.aws.awx.map.layers.LayerVisibility; private function turnWaterOff() : void { ags.getLayerVisibilities( new ItemResponder( function(data : Object, token : Object = null) : void { var arrCol : ArrayCollection = data as ArrayCollection; for each ( var layerVisib...

MinnDOT using Flex and AWX

Success story using Adobe Flex and ESRI AWX .

AWX2 Beta3 Released

Download it from here . One of the new items is great documentation of the API.

My MAX 2007 Presentation

Thanks all for attending, it was a packed room. You can download a zipped ppt version of my presentation from here .

Cool usage of AWX

Check out Andrew Trice's post on AWX usage. Pretty cool !

Trace AWX errors

We use Flex logging capabilities to report debug, info and error information: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" layout="absolute" > <mx:TraceTarget/> <framework:Framework username="foo" password="bar" authenticationError="trace(event.getError())"/> </mx:Application>

I get a blank map first time through...

Image
If you are using Flex Builder , make sure that you set the output folder of the project to a web application folder. Remember, your api key is tied to a URL. To get to this setting, use File -> Properties -> Flex Build Path.

WMS basemap layer

You can subclass BaseMapLayer to create a WMS basemap layer: package com.esri.aws.awx.map.layers { import com.esri.aws.awx.geom.Extent; import flash.geom.Point; import flash.utils.getTimer; public class WMSGroupLayer extends BaseMapLayer { public var service : String = "WMS"; public var version : String = "1.1.1"; public var request : String = "GetMap"; public var format : String = "image/png"; public var wmsLayers : String; public var serviceName : String; public var wmtVersion : String; public var styles : String; public var srs : String; public var dataSource:String; public var proxyURL : String; public function WMSGroupLayer() { super(); mapOversizeBuffer = 0; } override protected function getMap():void { m_lastMap = buildGeoLoader(); var scalarPt:Point = getScalar(); var width:Number = Math.floor(map.rotatedWidth * scalarPt.x); var height:Number = Math.floor(map.rotatedHeight * scalar...

Presenting at Adobe MAX 2007

Will be in Chicago at Adobe MAX 2007 , and presenting on: Monday, October 1 4:30 pm - 5:30 pm Tuesday, October 2 9:15 am - 10:15 am Hope to see you there.

Current US precipitation

You can take advantage of AWS data sources, in this case Precipitation.US , to view dynamic data. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:map="com.esri.aws.awx.map.*" xmlns:layers="com.esri.aws.awx.map.layers.*" xmlns:services="com.esri.aws.services.*" layout="absolute" > <framework:Framework apiKey="19640523"> <services:MapImageActivator/> </framework:Framework> <map:Map centerLat="35" centerLon="-93" scale="20000000"> <map:basemaps> <layers:MapImageGroupLayer dataSource="ArcWeb:MX.Precipitation.US"> <layers:layerVisibilities> <layers:LayerVisibility name="U.S. States" visible="false"/> </layers:layerVisibilities> </layers:MapImageGroupLayer>...

AWX2 beta users count keeps growing

As of today, the number of AWX2 beta users have reached a cool 883 !

AWX2 blog reference

Mapperz posted comments about AWX2 . Thanks.

Hey ArcIMS users....

You can use an ArcIMS datasource as a basemap, as follows: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:map="com.esri.aws.awx.map.*" xmlns:layers="com.esri.aws.awx.map.layers.*" layout="absolute" > <framework:Framework apiKey="19640523"/> <map:Map> <map:basemaps> <layers:ArcIMSGroupLayer id="world" serviceHost="http://www.geographynetwork.com" serviceName="ESRI_World" /> </map:basemaps> </map:Map> </mx:Application> Don't forget to place a crossdomain.xml file at the base of your ArcIMS host. Check out the Geography Network cross domain file as a sample.

How to create a dashed line ?

This code is based on the great work from Eli . You can download all the source code from here . So... in mxml it will look like this: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:map="com.esri.aws.awx.map.*" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:layers="com.esri.aws.awx.map.layers.*" xmlns:style="com.esri.aws.awx.map.layers.overlays.style.*" xmlns:overlays="com.esri.aws.awx.map.layers.overlays.*" xmlns:geom="flash.geom.*" > <framework:Framework/> <map:Map> <map:basemaps> <layers:PolylineLayer> <layers:style> <style:StrokeStyle> <style:stroke> <mx:Stroke color="0xFF0000" alpha="0.5" weight="5" caps="round"/> </style:stroke> <style:pattern...

Map distance measuring tool

Following the previous post, here is an example on how you will be able to use in the upcoming beta3 the polyline mouse handler to create a distance measuring tool. & lt ;? xml version="1.0" encoding=" utf -8"?> & lt ; mx :Application xmlns : mx ="http://www.adobe.com/2006/mxml" xmlns : utils ="com.esri.aws.awx.utils.*" xmlns :framework="com.esri.aws.osgi.framework.*" xmlns :map="com.esri.aws.awx.map.*" layout="absolute" > & lt ; mx :Script> & lt ;![ CDATA [ import com.esri.aws.awx.utils.Utils; import com.esri.aws.awx.map.layers.overlays.Polyline; import com.esri.aws.awx.events.OverlayEvent; import com.esri.aws.awx.map.handlers.PolylineMouseHandler; import com.esri.aws.awx.map.handlers.IMouseHandler; private var m_ mouseHandler : IMouseHandler ; private function doMeasure () : void { m_ mouseHandler = map. mouseHandler ; var mouseHandler : Polyl...

Distance between two Latitude/Longitude points

So when I asked my friend Kerry (who BTW is the king when it comes to map projections) how to calculate the distance between two lat/ lon points ? he pointed me to this link . He followed by saying "This is a good start, but what I have implemented in Java, takes care of all the 'weird' conditions!". This is why he is the king :-). So you can find the AS3 implementation here . And here is a simple MXML calculator. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import com.esri.aws.awx.utils.Utils; private function onClick() : void { var lat1n : Number = Utils.parseDeg(lat1.text); var lon1n : Number = Utils.parseDeg(lon1.text); var lat2n : Number = Utils.parseDeg(lat2.text); var lon2n : Number = Utils.parseDeg(lon2.text); var dist : Number = Util...

LiveHTTPHeaders

Following the last post, AWX can connect directly to a resource such as ArcIMS or even ArcGIS to get maps. The best way that I found out to see what crossdomain.xml the player is requesting, is to run the application in Firefox and watch the HTTP traffic using LiveHTTPHeaders.

I do not get a map...

Make sure that you have a crossdomain.xml file at the base of you web server that is hosting ArcIMS, ArcGIS or any host that you are trying to access data from that is not the host from which the swf was downloaded from. In such a way, that if you type http://your-host-name-info/crossdomain.xml in a web browser, you should get: <?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <allow-access-from domain="*" secure="false"/> </cross-domain-policy> If you cannot create that file on that host, then use/create a proxy with a crossdomain file.

How to turn off layer visibility ?

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:map="com.esri.aws.awx.map.*" xmlns:layers="com.esri.aws.awx.map.layers.*" layout="absolute" > <mx:Script> <![CDATA[ import com.esri.aws.awx.map.layers.LayerVisibility; private function onClick() : void { world.layerVisibilities = [ new LayerVisibility("Major Rivers", false) ]; } ]]> </mx:Script> <framework:Framework apiKey="19640523"/> <mx:Panel width="100%" height="100%"> <map:Map> <map:basemaps> <layers:ArcIMSGroupLayer id="world" serviceHost="http://www.geographynetwork.com" serviceName="ESRI_World" autoLoadLay...

How to add a polygon to the map ?

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:map="com.esri.aws.awx.map.*" creationComplete="onCreationComplete()" layout="absolute" > <mx:Script> <![CDATA[ import flash.geom.Point; import com.esri.aws.awx.map.layers.overlays.Polygon; import com.esri.aws.awx.geom.PolygonShape; private function onCreationComplete() : void { var coords : Array = [ new Point( 0, 0), new Point( -97.06138,32.837), new Point( 0, 32.832), new Point( 0, 0) ]; var polygonShape : PolygonShape = new PolygonShape( coords); var polygon : Polygon = new Polygon( polygonShape); map.polygonLayer.addOverlay( polygon); } ]]> </mx:Script> <framework:Framework/> <ma...

How to create geographic circles ?

In the current beta-2 version of AWX, you can create geographical circles using the Circle and CircleShape classes. In the beta-3 version, you will be able to do: <map:Map> <map:basemaps> <layers:PolygonLayer> <overlays:Circle centerLat="0" centerLon="0" radius="500000" units="meters"/> <overlays:Circle centerLat="45" centerLon="-80" radius="500" units="kilometers"/> <overlays:Circle centerLat="60" centerLon="80" radius="500" units="miles"/> </layers:PolygonLayer> </map:basemaps> </map:Map>

Framework start event

Wait for the framework start event to lookup services registered by the activator. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:services="com.esri.aws.services.*" layout="absolute" > <mx:Script> <![CDATA[ import mx.controls.Alert; import com.esri.aws.services.IRouteFinder; import flash.utils.getQualifiedClassName; import com.esri.aws.osgi.framework.IServiceReference; import com.esri.aws.osgi.framework.Framework; import com.esri.aws.osgi.framework.IBundleContext; private function frameworkStartHandler() : void { var context : IBundleContext = Framework.getInstance().systemContext; var ref : IServiceReference = context.getServiceReference( getQualifiedClassName(IRouteFinder)); if( ref != null) { ...

How to reverse geocode a location ?

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:map="com.esri.aws.awx.map.*" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:services="com.esri.aws.services.*" xmlns:awx="com.esri.aws.awx.*" implements="mx.rpc.IResponder" initialize="initializeHandler()" layout="absolute"> <mx:Script><![CDATA[ import mx.logging.targets.TraceTarget; import mx.logging.Log; import com.esri.aws.services.GeocodeCandidate; import com.esri.aws.awx.map.handlers.ReverseGeocodeMouseHandler; import com.esri.aws.services.FindActivator; import com.esri.aws.services.GeocodeInfo; import com.esri.awx.RevGeoMouseHandler; private function initializeHandler() : void { map.mouseHandler = new ReverseGeocodeMouseHandler(this); } public function res...

How to get a layer visibility info ?

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:awx="com.esri.aws.awx.*" xmlns:map="com.esri.aws.awx.map.*" xmlns:layers="com.esri.aws.awx.map.layers.*" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:services="com.esri.aws.services.*" layout="absolute" > <mx:Script> <![CDATA[ import com.esri.aws.awx.map.layers.LayerVisibility; import mx.collections.ItemResponder; private function onFrameworkStart() : void { parcels.getLayerVisibilities( new ItemResponder( function(data:Object, token:Object = null):void { for each ( var layerVisibility : LayerVisibility in data ) { trace( layerVisibility.name + " " + layerVisibility.visible); } }, function(info:Object, to...

How to get parcel information ?

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:framework="com.esri.aws.osgi.framework.*" xmlns:services="com.esri.aws.services.*" xmlns:map="com.esri.aws.awx.map.*" xmlns:layers="com.esri.aws.awx.map.layers.*" layout="absolute" > <mx:Script> <![CDATA[ import com.esri.aws.services.SpatialQueryOptions; import com.esri.aws.services.ISpatialQuery; import com.esri.aws.services.PlaceFinderOptions; import mx.collections.ItemResponder; import com.esri.aws.services.IPlaceFinder; import flash.utils.getQualifiedClassName; import com.esri.aws.osgi.framework.IServiceReference; private function doSpatialQuery() : void { var ref : IServiceReference = framework.systemContext.getServiceReference(getQualifiedClassName(ISpatialQuery)); var spatialQuery : ISpati...