Flex: UMap WMS Custom Provider Demo
The first thing to note is that this is not using Google or Microsoft to provide the map tiles. I have implemented a custom tile provider class ‘WMSTileProvider’ which talks to a mapping server using the WMS protocol.
The map is supplied from here.
This tiles are from here and have been generated by scanning out-of-copyright Ordnance Survey maps and stitching them together. Very clever.
The forum posts are more of a signpost as to how you could go about plugging in a Custom provider for the map. There was no downloadable code, until now.
I have spent a fair bit of time trying to get this working and I have adopted one technique. There may be others. The main trick is to override all the overridable methods in your ‘Provider’ subclass.
public class WMSTileProvider extends Provider
public function WMSTileProvider(defaultData:Boolean = false,
settings:URLRequest = null,
language:URLRequest = null,
copyright:URLRequest = null)
super(defaultData, settings, language, copyright);
override public function getDefaultLanguage():String
override public function getDefaultCopyright():String
return “(c) – OS NPE (1940s) – Public Domain”;
override protected function parseSettings(data:String):Boolean
override protected function parseLanguage(data:String):Boolean
override protected function parseCopyright(data:String):void
The next trick is to supply dummy requests for the language and copyright strings. Normally these would be php requests but I just changed them into xml files. As long as you override all the methods in the Provider subclass you won’t get any annoying exceptions.
var settings:URLRequest = new URLRequest("settings.xml?rand=" + Math.random());
var language:URLRequest = new URLRequest("language.xml?rand=" + Math.random())
var copyright:URLRequest = new URLRequest("copyright.xml?rand=" + Math.random());
_map.control.provider = new WMSTileProvider(false, settings, language, copyright);
You have to put something into language.xml and copyright.xml they can’t be empty.
The settings.xml file only need contain the minumum definition:
Not so complicated when you know how but not easy to work out from the UMap forum posts.
Truly a pure geeky rush when I saw the map tiles burst into life. It was worth all the hassle. Right-click to view the source.
There is a pretty long list of other WMS data providers here if you want to try creating a different WMS tile layer. If you do it would be good form to post it up onto the UMap forum.
– Resizing the map window sometimes makes the tile disappear. No idea as of now what’s going on but I think it’s linked to the resize.
About the dataset
This is the original drawing William Stukeley made of the Avebury complex.
His drawing shows the main complex and the two avenues to the left and right before time and other thieves destroyed most of it. You can see most of the same features on the map view.
For some more information head here.
- Clicking on a marker now highlights the appropriate item in the data grid. Note that it scrolls to the target item.
- Tidied up the xml text names and descriptions.
- Updated demo to use new version of the UMap component (02/08/08 v1.1). See here.