[ka-Map-users] RE: Multiple URLs - one ka-map install - variablepassing question?

David William Bitner bitner at gyttja.org
Wed Jul 12 18:48:58 EDT 2006


Steve --

You really should take a look at mod_rewrite, I think that it would really
be quite easy to do what you are trying to accomplish.

The basic idea is that you would setup a rule in apache that would take any
url of the form http://www.usmapserver.com/california and you would
internally (the end user will never see what you are doing) change that url
to http://www.usmapserver.com/index.html?state=california.  Then you would
just need to have a lookup in index.html that would find the bbox for ca and
would zoom in there.

It's actually pretty darn slick when you get it running.

David

On 7/12/06, Steve Walker <walker at mfgis.com> wrote:
>
>
> I have partially solved my own question posted below.
>
> I have discovered the following:
>
> To view multiple pages such as
> http://www.blahblah.com/location1 and
> http://www.blahblah.com/location2
>
> from the same ka-map back-end, do the following:
>
> Modify the init.php, changing file 'includes' as necessary to point to the
> correct locations on the file system (ie tile.php, config.php) as you will
> copy the init.php file to multiple locations on the file system and the
> relative pointers to these files may/will break.
>
> Also in init.php, insert the line
> include_once('./variables.php');
> before the include_once( 'config.php) entry.  This pulls in the variables
> (extent, map name, title) as noted in my original posting.
>
> modify the *.js files again to replace path names as necessary, for the
> same reason as above (ie from 'images/blahblah.jpg' to
> '/ka-map/images/blahblah.jpg'
>
> copy both the init.php files to the corresponding location(s) on the file
> system.
>
> re-write the index.html files (using scripts & templates) to reflect the
> page-specific values from variables.php such as name, title, etc.
>
> /var/www/htdocs/location1/init.php
> /var/www/htdocs/location1/index.html
> /var/www/htdocs/location1/variables.php
>
> /var/www/htdocs/location2/init.php
> /var/www/htdocs/location2/index.html
> /var/www/htdocs/location2/variables.php
>
> This solution works as you can see for example from
>
> www.usmapserver.com/Washington
> www.usmapserver.com/California
> www.usmapserver.com/California/Los_Angeles
>
> However, drawbacks include:
>
> 1.  need to make a copy of init.php for each desired web page rather than
> pointing to a single master.
> 2.  need to (progromatically) re-write each index.html (ie to generate
> title, name, links) from scratch rather than including these values at
> run-time.
>
> I am still scratching at the surface of understanding and will report
> anything else I learn.
>
> -steve walker
>
> > Hello,
> >
> > I am hoping to be able to achieve the following:
> >
> > Have
> > http://www.usmapserver.com/location1
> > http://www.usmapserver.com/location2
> > (and n  additional URLS)
> >
> > each launch the same ka-map application (same map, data, etc)
> > but so that each grabs its extent and title (among other things) from
> > the URL's  index.php file as here:
> >
> > /var/www/htdocs/location1/index.php:
> >     $title = 'Map of Green City';
> >     $extent = '-120,40,-115,45';
> >     $include ("/var/www/htdocs/kamap_index.html");
> >
> > /var/www/htdocs/location2/index.php:
> >     $title =  'Map of Red Town';
> >     $extent = '-90,30,-70,40';
> >     $include ("/var/www/htdocs/kamap_index.html");
> >
> > where of course location1/index.php corresponds with
> > http:/www.usmapserver.com/location1   etc.
> > and where kamap_index.html is essentially the ka-map distribution html.
> >
> > My idea is to replace (in init.php) the extents read from the map file
> > $szExtents = $oMap->extent->minx.",".$oMap->extent->miny.",".
> >     $oMap->extent->maxx.",".$oMap->extent->maxy;
> >
> > with
> >
> > $szExtents = $extent;
> >
> > where $extent is the $extent variable in index.php
> >
> > (CF The analogous setup using the chameleon environment at
> usmaperver.com
> > - a web page for each state, county, and city in the nation.)
> >
> >
> > The problem, as I understand it, is that these variables don't get
> passed
> > through.  And here is where my skills break down - specifically on the
> the
> > javascript side.
> >
> > I can *fake it* but only for one page:  In init.php, near the line
> > include_once( '/var/www/htdocs/include/config.php' );
> >
> > I can add
> > include_once( '/var/www/htdocs/location1/variables.php' );
> >
> > But this will only work if hard-wired to the 'location1/variables.php'
> > and since I don't know how to move these variables through, I can't
> write
> >
> > $variable_path = '/var/www/htdocs/' . $url_base . '/variables.php';
> > include_once( $variable_path );
> >
> > where $url_base would be one of location1,location2,...,locationN
> >
> >
> > Does this make sense?  Clearly I wouldn't even need to bother with this
> > kluggy 'include_once' in init.php if those variables originally defined
> in
> > index.php were passed through.
> >
> > I think I am missing something simple (php globals?  javascript
> anything?)
> >
> >
> > Thanks for any insights.
> >
> >
> >
> >
> > --
> > Steve Walker
> > Middle Fork Geographic Information Services
> > walker at mfgis.com
> > 360-671-2505
> >
> > _______________________________________________
> > ka-Map-users mailing list
> > ka-Map-users at lists.maptools.org
> > http://lists.maptools.org/mailman/listinfo/ka-map-users
> >
>
>
> --
> Steve Walker
> Middle Fork Geographic Information Services
> walker at mfgis.com
> 360-671-2505
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
>



-- 
************************************
David William Bitner
bitner at gyttja.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/ka-map-users/attachments/20060712/705d510f/attachment.html


More information about the ka-Map-users mailing list