Page 1 of 1

KML (semi-)support for version 1.0.5

Posted: 29 Jan 2010, 12:01
by joortje
Hi all,

A month ago I send an e-mail to Jan with the question if I can add an overlay (KML file). The answer was that this will be in v-next. So i decided to load 2 maps, 1 with pointers and 1 with overlay (showing my trip). :x What a nasty solution.

So today I decided to solve this. But as I have limited time, I will solve this in increments.

step 1) Load a predefined kml file into the map
- I created a kml-file, howto:: http://code.google.com/apis/kml/documen ... l_tut.html
- I edited components/com_phocamaps/views/map/tmpl/default.php
- After line 274 I added

Code: Select all

// added to support kml file
  echo 'geoXml = new GGeoXml("[WRITE THE URL OF YOUR KML FILE HERE]");' ."\n";
  echo 'mapPhocaMap.addOverlay(geoXml);' ."\n"; 
- save and done!

step 2) Load the kml file from the list of markers
- When time is on my side I will add the code to generate the KML file
- Of course I will post the solution here! It will probably look like http://code.google.com/apis/kml/article ... qlkml.html

step 3) Don't know yet, but open for suggestions.

See the result :: http://www.henkjanopreis.nl/index.php?o ... &Itemid=15 (sorry, loading time is crap and most of the site is in Dutch).

Re: KML (semi-)support

Posted: 29 Jan 2010, 13:37
by Jan
Hi, thank you for this guide, I will take a look at it and will try to add it to next release.

Thank you, Jan

Re: KML (semi-)support

Posted: 10 Mar 2010, 11:26
by joortje
** edited to clarify the dir and url **

As the kml stays in the cache for to long, I made a little improvement.
Using this code you can just upload a new kml-file to the kml-folder.

Code: Select all

// added to support kml file
// find kml files in dir
$dir = "[[dir to kml files]]"; // dir meaning the dir on the server
$files = glob($dir."*.kml"); 
// sort newest first
array_multisort(array_map('filemtime', $files), SORT_DESC, $files);
$kml = basename($files[0]);

// display newest
echo 'geoXml = new GGeoXml("[[full url to kml files dir ending with a slash]]' .$kml. '");' ."\n";
echo 'mapPhocaMap.addOverlay(geoXml);' ."\n";


You need to change [[dir to kml files]] and ("[[full url to kml files ending with a slash]] to make it work.

@aljvilla, send me an e-mail at joris dot arts att gmail dot com.

Re: KML (semi-)support

Posted: 11 Mar 2010, 14:25
by Jan
Hi, thank you for this improvement

Re: KML (semi-)support for version 1.0.5

Posted: 30 Jul 2010, 16:31
by CZBios
thanks fot a tip, but thats a static solution, isnt it? I mean, that i can have just one KML file avaible for use, right?

Also, where i am must upload the kml file and where i find it after upload? Thanks.

Re: KML (semi-)support for version 1.0.5

Posted: 26 Jul 2011, 23:17
by Jan