Build AJAX-Based Web Maps Using ka-Map
by Tyler Mitchell
|
Pages: 1, 2, 3, 4, 5, 6
Customize Look and Feel
ka-Map doesn't automatically pick an appropriate scale for your web browser's
window size or screen resolution. It always uses the first one you have specified
in config.php. Therefore, it is difficult to know exactly what
your map will look like on another screen. This is more of a problem when the
geographic extents of your application cover all your data. When there is more
data outside your map area it helps fill the screen better.
Customising the index.html code allows you to change the way
the interface looks. For example, you can change the colours, add logos, etc.
Cleaning Up the Cache
Sometimes you really need to clean out the cached tile data and start over,
especially if you are modifying your map file or map scales. It would be good
to have a more automated way of clearing the cache, e.g. a button on the web
page. Until then, you need to delete all the files in your cache folder. For
example, clear out all files and folders from /opt/fgs/apps/kamap-0.1.1/htdocs/tmp/.
Note that if you turn on the debug option, you will need to clear the cache when you turn it back off.
Prebuilding Map Tiles
Version 0.1.1 comes with a script called precache.php. This is
a powerful tool that can really improve the initial performance of your application.
You need to edit several pieces of the script before you can use it. Supply
the map name (changing it from the default gmap) and set the scales
that your map will be using. There is also a setting that calls the tile.php script.
Make sure this points to tile.php on your server.
If you comfortable with PHP, you could modify the precache tool to pick up
the settings from config.php. Then it could process all your maps
for all the scales that your application is set up for.
Legend Handling
There have been some bugs in the way that legends are generated. If you do
not include a LEGEND object in the global.map file,
then the legend doesn't draw properly. Even if the LEGEND object
is empty, it will allow ka-Map to render it properly. Having such a simple LEGEND object
isn't a very good practice for normal MapServer applications, but works fine
with ka-Map. By setting the TRANSPARENT option, it makes the legend
look good on top of the web page background.
Advanced Functionality
More recent versions of ka-Map (i.e. CVS or version 0.2) have many more options and features. For example, an advanced, tree-like legend manager tool. This allows layers to be controlled as a group. This requires some more planning and appears to be somewhat unstable at present, but is certainly promising.
There are options for setting transparency for layers. You can then make one layer semitransparent and see it overlaid on top of another. Combine this with layer-visibility control and you can make some really interesting tools.
Some really powerful maps can be created using WMS data sources in your map file. This could, for instance, allow you to have one layer of changing data that is regularly updated, but never requires you to regenerate map tiles for all layers. This takes some thinking and caution, as you could easily flood a WMS provider, giving poor results, or mistreating a benevolent provider. Adding real-time WMS layers to your application is customisation that ka-Map does not come with out-of-the-box. If you want your WMS layers to be updated, then you will have to clear the cache and let it rebuild the cached tiles.
Conclusion
It took some time to get my first set up of ka-Map to work properly. I had switched between packaged source files and CVS, but found that the best way to get started was by using MS4W or FGS. The set up is relatively simple, but leaves little room for mistakes. Having an AJAX-based web-mapping platform is in high demand and ka-Map does a worthy job filling that need. Because it is an open source product, there is room for others to help develop it further. Whether you are a user or a developer, you can play a part in making the product better and more stable. I hope you enjoy using it as much as I have.
Links and Resources
In a previous article and some weblogs, I introduced some web-mapping tools. This is also the focus of my book, Web Mapping Illustrated. I have focused on the open source tools that are freely available, very powerful, in active use, and under continual development.
Here are links to some of the products and web sites mentioned in this article.
- MapTools - http://maptools.org/
- MapServer - http://ms.gis.umn.edu/
- ka-Map - http://ka-map.maptools.org/
- FreeGIS - http://www.freegis.org/
- FWTools - http://fwtools.maptools.org/
- Web Mapping Illustrated - http://oreilly.com/catalog/webmapping
- Mapping Hacks - http://oreilly.com/catalog/mappinghks
- My other articles and weblogs - http://www.oreillynet.com/pub/au/1898
In June 2005, O'Reilly Media, Inc., released Web Mapping Illustrated.
-
Chapter 3: Converting and Viewing Maps (PDF), is available free online.
-
You can also look at the Table of Contents, the Index, and the full description of the book.
-
For more information, or to order the book, click here.
Have you used ka-Map? If so, let us know how it worked for you.
(* You must be a member of XML.com to use this feature.)
Comment on this Article
| Titles Only | Titles Only | Newest First |
- Error when Ka-map is installed
2008-01-24 03:07:26 AyoM [Reply]
Hi,
I'm getting this same error and i've tried everything to make it work.
Warning: Invalid argument supplied for foreach() in C:\ms4w\apps\kamap-0.1.1\htdocs\init.php on line 75
Fatal error: [MapServer Error]: setExtent(): Given map extent is invalid. Check that it is in the form: minx, miny, maxx, maxy in C:\ms4w\apps\kamap-0.1.1\htdocs\init.php on line 93
When i tried installing version 1.0 i'm gettin a sample interface which looks nothing like the .0.1.1 version. Any help on this would be appreciated as i am doing my final year project using ka-map.
- Error when Ka-map is installed
2008-12-08 06:26:34 NickInZim [Reply]
Hi,
I also read and followed the article, and had this problem. I managed solved it after a few hours of effort. The problem is actually very easy to fix.
In your config.php file go to line 105 (that's what it is in mine) or the line that starts "$szMap" this should say something like:
$szMap = 'gmap';
Change this to:
$szMap = 'weather';
This tells the system the default MAP file to load, therefore if it points to a non-existent file, it gives an error. Other than this the instructions are correct. Maybe the Author can add this to his instructions?
- Error when sample application is deployed in ka map
2008-11-07 01:01:47 muzaffari [Reply]
hi
if i put in browser iam getting error like this.
Warning: Invalid argument supplied for foreach() in C:\ms4w\apps\ka-map-1.0\htdocs\init.php on line 123
/*init*/this.tileWidth=256;this.tileHeight=256;this.server = 'http://127.0.0.1/kamap/';this.tileURL = 'tile.php';this.selectMap('gmap');
pls help me out from this.wat could be the thing.
- Ka-map warning
2008-02-27 20:20:38 AyoM [Reply]
hi,
Whenever i run the init.php i get the error below
Warning: Invalid argument supplied for foreach() in C:\ms4w\apps\ka-map-1.0\htdocs\init.php on line 123
/*init*/this.tileWidth=256;this.tileHeight=256;this.server = 'http://localhost/kamap/';this.tileURL = 'tile.php';this.selectMap('weather');
all changes have been made correctlybut still no solution. there seem to be many people with the same problem but no solution seems to be available. Any help will be a Godsend
- Error when Ka-map is installed
- Error popup: Argument for foreach & given map extent are invalid
2006-01-18 09:50:57 H. [Reply]
Hi,
I have installed ka-map and Mapserver as the above manual and ran tests as recommended:
MapServer test:OK
shp2img test: OK
Testing Map in Web context: OK
However, when I try http://localhost/ka-map/init.php I got the following error:
-----------
Warning: Invalid argument supplied for foreach() in C:\ms4w\Apache\kamap-0.1.1\htdocs\init.php on line 75
Fatal error: [MapServer Error]: setExtent(): Given map extent is invalid. in C:\ms4w\Apache\kamap-0.1.1\htdocs\init.php on line 93
-----------
These guys have the same problem: http://lists.maptools.org/pipermail/ka-map-users/2006-January/000829.html
I really appreciate for any suggestions!
Regards,
H.
- Error popup: Argument for foreach & given map extent are invalid
2006-03-08 14:53:51 mmelendez [Reply]
I had the same mistake, but I downloaded ka-map v0.2 and it worked.
The only diference is that 'config.php' is in the "apps\ka-map-0.2\include" directory.
Good luck.
- Error popup: Argument for foreach & given map extent are invalid
2007-09-21 11:47:08 abdhiee [Reply]
i have some problems like him too
i cant' find ka map v2....? where should i donwload?
thx for your atention pls...
HELP!
- Error popup: Argument for foreach & given map extent are invalid
- Error popup: Argument for foreach & given map extent are invalid
