Tour de Mobile ESRI Flex
Back at devsummit this year, I chanced upon a fantastic presentation by @mraad which demonstrated
embryonic Flex 4.5 Mobile capabilities and the ESRI Map control running within it. He published the project
as a simple map-and-query effort. I have cannibalized and extended the project with some integrated
device functionality, in an effort towards making a lightweight Tour De Mobile Flex for ESRI.
Here’s the functionality I wanted to show:-
- Show Address on map (Reverse Geocode)
- Measure Distance (Geoprocessing)
- Create Points in FeatureClass (editing)
- Locate Me on the map (use GPS)
- Take photo and upload as attachment to amazon ec2 hosted geodatabase (use Camera)
- Store / Retrieve layer URL in local database for dynamic layer configuration. Necessitated by ec2
instance changing IPs every time I rebooted it.(use device database)
Let’s see you do any of the last 3 in Javascript…
Demo
Code
Here’s the code. It’s fugly, and barely at prototype quality, no patterns, consistency etc. Just pasted from various samples, basically, to show proof of concept.
If you’re going to run the code be sure to change / modify the featurelayer by clicking the “Set AGS Layer” button from the tools dialog; or in code.
Deja Vu (Write once, run anywhere)
Remember the 90s? A new technology offered developers to write one language which could be run on any
operating system — Java. In terms of developing apps, the mobile platform market is roughly at 1990 -
there is total fragmentation between OS vendors. .NET, Java and Objective-C are respectively tethered to Windows/Android/Apple.
So it seems that the time is right (as if it ever weren’t) for someone to develop a platform
for giving developers a single language to push out an app.
I have no idea if Flex is going to be the solution, but it’s not exactly going to be Objective C, is it (please)? The hello-world tutorial for Objective-C is about 50 steps. Ouch. Do I really want to learn a platform-specific language of
1980s complexity/toolsupport, or do I want a nice-and-easy-lemon-squeezey developer experience? Flex
is so easy it’s laughable. You want full-on GIS editing capability — just paste & tweak from the samples and you’re there in minutes. OK, enough religion.
Woah!
OK, so we’re not in the promised land just yet. I’m sure running Flex Mobile with ESRI on an iPad2 is fine;
but for the iPhone4 it was painful bordering on unusable at startup time. The application will
timeout before initialization is complete unless you touch the screen. Not exactly production ready but once it’s up & running performance is OK. Some more specifics:
- Pinch Zooming. At first it looks to work as you’d expect, but on closer inspection pinching the
screen causes it to shimmy around - Because the Mobile framework is spark-based, not mx-based, there are certain things that just
don’t work when you deploy to iOS. Flashing graphics, for example. - InfoWindow doesn’t work so I had to throw something together for that.
- Double-tapping doesn’t work (had to create a “Done” button for DrawTool stuff).
Relating to iOS:
- No debugging on iOS by USB yet (exists for Android), so testing anything that required device integration was painful
- Compiling takes several minutes & deploying is a pain (iTunes…and handing over $99 to Apple. Ugh).
Relating to Flex Mobile:
- Flex Mobile API is designed from a screen-input perspective, with a hierarchy of screens. It’s a little
inflexible when it comes to deviating from that pattern. With regards to a GIS environment, it’s not possible to
swap out action buttons within the same view without reverting to skinning, which was too black-belt for me
Conclusion
Hopefully ESRI will provide a spark-based touch-sensitvie map control in future because cross-platform
development in an established language is amazingly productive. I’m equally sure that by the time phones are all dual-core
the performance problems will be a thing of the past. Using Flex gives you lots of bang for your buck in terms of rapid development, but the real gain is the fact that you can write once and deploy to Blackberry/Android/iOS. This paradigm has to be the future.
Phil Penn (@ppenn)