[OpenLayers-Users] Failing with Ka-Map...
Christopher Schmidt
crschmidt at crschmidt.net
Thu Aug 10 12:24:55 CDT 2006
On Thu, Aug 10, 2006 at 10:47:07AM -0500, Jeff Dege wrote:
> I have, after some playing around, an installation of ka-map v0.2
> working against the gmap demo map data. I'm now trying to get the map
> to display using OpenLayers' kamap layer type.
>
>
> The only change I've made to the gmap configuration is to add a "GROUP
> 'all'" entry to each layer:
>
> # FILE: gmap75.map
> #
> # Start of GMAP map file
> #
> #
> NAME GMAP_DEMO
> STATUS ON
> SIZE 400 300
> SYMBOLSET ../etc/symbols.sym
> EXTENT -2200000 -712631 3072800 3840000
> UNITS METERS
> SHAPEPATH "../data"
> IMAGECOLOR 255 255 255
> FONTSET ../etc/fonts.txt
>
> [...]
>
> LAYER
> NAME bathymetry
> GROUP 'all'
> METADATA
> "DESCRIPTION" "Elevation/Bathymetry"
> END
> TYPE RASTER
> STATUS ON
> DATA bath_mapserver.tif
> END
>
> LAYER
> NAME land_fn
> GROUP 'all'
>
> [...]
>
> The gmap installation works, when accessed directly:
>
> http://www.visi.com/~jdege/gmap-test.gif
>
>
> With ka-map, I've edited include/config.php, to us the correct dlls, and
> to point to the gmap installation:
>
> <?php
>
> /**********************************************************************
> *
> * $Id: config.dist.php,v 1.4 2006/02/07 03:20:18 pspencer Exp $
>
> [...]
>
> $szPHPMapScriptModule = 'php_mapscript_48.'.PHP_SHLIB_SUFFIX;
> $szPHPGDModule = 'php_gd2.'.PHP_SHLIB_SUFFIX;
>
> [...]
>
> $aszMapFiles = array(
> "gmap" => array( "GMap", "/ms4w/apps/gmap/htdocs/gmap75.map",
> array(30000000, 10000000, 3000000, 1000000),
> "PNG")
>
> /* Add more elements to this array to offer multiple mapfiles */
>
> );
>
> [...]
>
> $szMap = 'gmap';
>
> [...]
>
> And it works fine:
>
> http://www.visi.com/~jdege/kamap-test.gif
>
> But when I try to access the layer through OpenLayers, I get some
> serious tiling artifacts.
>
> This is what I'm doing:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
>
> <head>
> <title>OpenLayers/Ka-Map Test</title>
> <script type="text/javascript"
> src="./release-1.0/lib/OpenLayers.js"></script>
> </head>
>
> <body>
>
> <h3>OpenLayers/Ka-Map Test</h3>
>
> <div style="width:100%;height:800px" id="mapDiv" />
>
> <form id="form1" runat="server">
> </form>
>
>
> <script type="text/javascript" defer="defer">
>
> var map = new OpenLayers.Map('mapDiv',
> {
> controls:[]
> }
> );
>
> var baseLayer = new OpenLayers.Layer.KaMap("Cities",
> "http://localhost:8080/kamap/tile.php?",
> { map: 'gmap', g: 'all' },
> 'meters',
> 72 );
>
> map.addLayer(baseLayer);
>
> map.addControl(new OpenLayers.Control.PanZoomBar());
> map.addControl(new OpenLayers.Control.LayerSwitcher());
> map.addControl(new OpenLayers.Control.MouseToolbar());
>
> map.zoomToFullExtent();
>
> </script>
>
> </body>
> </html>
>
> And this is what I get:
>
> http://www.visi.com/~jdege/openlayers-test.gif
>
> What am I missing?
Currently, your ka-Map is being displayed in meters, but OpenLayers is
working in degrees. It seems likely that this is cuasing the effect
you're seeing.
In order to work in a different unit in OpenLayers, you will need to set
two things: One, a different maxExtent, and two, a different
maxResolution.
It looks like you need, as an option (alongside controls: []):
maxExtent: new OpenLayers.Bounds(-2200000,-712631,3072800,3840000),
maxResolution: 'auto'
This will set the extent to match the gmap75 demo (I believe -- I pulled
this from googling) and it will set the maxResolution such that the
entire map is displayed within the div you're setting up.
If this doesn't work, let me know where I can find the gmap75 demo, and
I'll get to work on trying to figure out how to solve the problem.
--
Christopher Schmidt
Web Developer
More information about the Users
mailing list