KML (semi-)support for version 1.0.5

Phoca Maps - displaying maps in Joomla! CMS
joortje
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 12 Dec 2008, 13:25
Location: Holland

KML (semi-)support for version 1.0.5

Post 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).
Last edited by joortje on 30 Mar 2010, 08:21, edited 1 time in total.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: KML (semi-)support

Post 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
If you find Phoca extensions useful, please support the project
joortje
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 12 Dec 2008, 13:25
Location: Holland

Re: KML (semi-)support

Post 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.
Last edited by joortje on 30 Mar 2010, 07:52, edited 1 time in total.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: KML (semi-)support

Post by Jan »

Hi, thank you for this improvement
If you find Phoca extensions useful, please support the project
CZBios
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 21 May 2010, 14:25

Re: KML (semi-)support for version 1.0.5

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: KML (semi-)support for version 1.0.5

Post by Jan »

If you find Phoca extensions useful, please support the project
Post Reply