Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
A little while back, I posted a few mapping extensions that read in various kinds of data to allow mapping of regions and data on Google Maps. One major problem with those is that Google is now charging money for useof their mapping product, so in order to use this extension on any grand scale,they'd need to purchase licensing.
So, in response to this, I've built an extension which uses all open source (free) products to provide some similar mapping capabilities(and then some). The tool which provides the scrolling and "slippy" map features is called OpenLayers which reads in map imagery from OpenStreetMap. What I've done this time, however, is built the extension to read in KML files for the regions. KML is a format that is very common in the industry (Google Earth uses and creates the files) ,and there are many tools out there to convert other formats (like shape files) into the KML format.
So, for example, I went and found a KML file for the US 50 states and put it into this new extension, and was able to create a map similar to my other US Map extension:
New Features
Above and beyond the normal features of the extensions I created for Google, this extension provides a few new features:
I've attached the extension as well as a QVW and quick guide. In the extension is a sample KML file called us_states.kml that can be used with the example QVW.
Please let me know if you have any questions. Hopefully this is useful to people.
Due to some issues with versions of Internet Explorer prior to 9 and how it handles different data formats, it is now necessary to change the KML file into an XML file prior to loading it into the extension. So, for example, if you have a KML named "counties.kml" you need to change the file extension so it becomes "counties.xml". Hopefully I'll eventually get time so this last step can be avoided, but for now it's necessary in order for the extension to work in IE8.
I've updated the attatchments on this post to use an XML file, so the examples should now work.
Hi Brian,
I got around my problem with the KML file, actually I mistyped some $(data) lines and I couldn't read the data at all.
Is there a way to use the OpenLayers.Layer.Google as a choice instead of the OSM layer?
I tried to include the standard "http://maps.google.com/maps?file=api&v=2&key=abcdefg1234" with my Google Maps API Key but it seems like a different key is needed. Have you given it a try?
Thanks
Francesco
hogen,
What does the ARGB value look like?
Francesco,
I haven't tried this extension with google yet. I think the issue might be that you're using v2 of the API. If you call out to the google API the v3 way (which I THINK no longer requires a key), that might work? Just a guess...
Eliano,
The quick guide should explain how to do this, but the extension has a percentage expression and a color expression. The percentage expression is there if you want to have the color on the regions fade or darken based on a value for that region. If that's not applicable, you can just set this to a hardcoded value like 80.
The color expression is there in case you want to have the regions act almost like a gauge. So in the example I posted here, I have the colors change to red green or yellow depending on a value using the following expression:
=If(Num > 66, '#439400', If(Num > 33, '#F2EF1B', If(Num <= 33, '#EB1A1A')))
If you were using a percentage expression and simply wanted a single color to fade or darken, you could also just hardcode a color here in hex or RGB format.
The argb value looks like "ARGB(255,253,2,0)"
Does anyone have any idea where to find a KML file containing US Counties? I found this: http://www.gfairchild.com/public/populationCounty.kmz but it's not in polygon format.
Marcus,
I actually grabbed that KML file you mentioned and wrapped some of the <LinearRing> tags in opening and closing <Polygon> tags and it was able to load those into the extension. You could probably do that fairly easily with a find and replace.
Hi Brian,
This is exaclty what I was looking for. Thank you so much and congratulations for the great job!
Regards,
Cesar
Brian
Really nice extension, jsut need to find some time to have a proper look at it
Lewis
Hi, I generated a KML using Google Earth and I sucessfully loaded it to the extension. However I noticed that the KML contains a tag "description" with custom HTML tags (Regional attributes). Is there a way to load this as separated fields to the application?