After a year or more of working with the open source Flex mapping API OpenScales, it struck me that a download-able template might help the user community. The OpenScales team provide some excellent code examples on their Web site. I wanted to pull this functionality, plus some custom additions, into one application. A few months ago I released a build, which was based on the 1.1.7 release of OpenScales. The application was built using a basic framework, which was configurable and contained loadable widgets. Also included was the base map solution a number of people had asked about, allowing the inclusion of satellite/road maps from Yahoo. Bing etc.
An upgrade to this template, has been in the back of my mind for a while. The goal being the following:
- Upgrade to the new Flex SDK and, in my case, use of Flash Builder 4
- Upgrade to the 1.2.2 build of OpenScales
- Simplify the MVC framework from the original
- Port the functionality from the 1.1.7 template
- Compare the Openscales 1.1.7 release to the current
New OpenScales GIS Template
So the newly upgraded template is ready to go. This will be updated over time. There are some omission and comments that need be made.
Figure 1 – Flex Openscales Map Demo 1.2.1
Let’s walk through what is there:
A very simple MVC is in place; the model contains all application data, the controller updates the model. Widgets are opened and closed via the headercanvas. They are all contained in the view/components folder. All widgets inherit from the ToolsBase class. My goal was to build a framework which was simple to understand ie. you dont need to learn the framework before you can dig in.
The application is configured using the files contained in assets/styles and assets/config. The former contains a stylesheet, so you can change the look and feel of components without the need for a recompile. The latter contains title and subtitle text, the base maps to load.
The header contains icons which open and close the various widgets or tools. The pop ups are built using best practice, at least from what I have seen over the years. So can be closed from the icon in the header or close button. All pop ups are move-able and can be minimised/maximised. The tools include are:
- Full extent
- Layers (TOC)
- Overview Map
These are not coupled to any other shared classes (a huge annoyance in the ESRI Flex template). Adding additional tools to the template, which inherit from the ToolsBase class, should be easy. So more to come.
Annoyances and Issues
I have hesitated to release this new template, since I am aware of some issues. Most relate to the new 1.2.1 base. They are worth discussion, since they relate directly to whether OpenScales is ready for production. I say yes, but only under the guiding hand of an experienced Flex developer. The list:
a) Base maps – I have commented where this relevant lines are for this implementation. At the moment this code is commented out. Why? The solution which worked in 1.1.7 does not work here. Let me qualify that; if we add a WMS layer things break. So in this release I have included WMS and commented out base maps. But the solution for the latter is included. I plan to spend more time looking for the solution, feel free to give me any of your feedback. Btw, thanks to Rashmi here for saving me a bunch of time by helping with the upgrade.
b) Draw tool – this has always been a problem in OpenScales. Try to put the tool in an opening/closing pop up and an array of side effects result. I have kept the tool available in the template so you can see the problems. Its a pain, since draw tools are usually made available as we have it here. Now I have a number of solutions to get past this (which I put in the 1.1.7 template), feel free to suggest any of your own. I wanted to highlight the issues here which is why i didn’t put in any of my own fixes.
Another issue. If we open the draw tool pop up, it adds a layer to the layer list pop up. Now close it and open again, another layer is listed. Again I have a solution, but this is less than optimum behaviour
Now I point out some of the remaining issues with OpenScales not as criticism, just as fyi’s. It would be nice, as things move forward, if some of these issues are resolved. For me they come ahead of panning smoothness etc, which i have seen discussed.
The new download is available here. Please note you will need to add the following compiler argument in Flash Builder 4:
My goal is to upgrade this template when I can; to fix issues and add widgets. I hope it proves useful to those working with OpenScales. Hopefully it will help you get your sites up and running quicker. Feel free to provide comments, feedback, maybe code. OpenScales is not perfect, it still has some teething problems. But its open source and built using Actionscript. I hope it is recognised as a useful addition to the open source stack; I’m trying my hardest to spread the word. Also that it is increasingly looked at as an alternative to the ESRI Flex API (which I like don’t get me wrong). I have not included WFS in this release. I have thoughts on best use, and will write a blog article on the subject in the near future.
The template can be downloaded here.
I had somebody call me from Colorado just recently very interested in using OpenScales, wondering whether it was production ready. My response; there are still some annoying, but minor issues which can be fixed. In the long term, these should go away. Open source is potentially cheaper and more flexible than proprietary solutions I explained. It is not free. Application development, using open source tools, is the expense. Not the software itself. The better the developer, the more you will pay, and the better your outcome. They didn’t call back. But that’s a different battle we need to fight ……