|
Last change
on this file since 7767 was 7767, checked in by janveeden, 16 years ago |
|
|
-
Property svn:eol-style
set to
native
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | <?php
|
|---|
| 2 | require_once($config['root']."/inc/LogHandler.class.php");
|
|---|
| 3 |
|
|---|
| 4 | function getArrayFromKML()
|
|---|
| 5 | {
|
|---|
| 6 | global $config;
|
|---|
| 7 | $file = $config['kml_file'];
|
|---|
| 8 |
|
|---|
| 9 | //Check if the file exists, if it does we load it. If it doesn't we exit and return an error message
|
|---|
| 10 | if (file_exists($file))
|
|---|
| 11 | {
|
|---|
| 12 | $xml = simplexml_load_file($file);
|
|---|
| 13 | }
|
|---|
| 14 | else
|
|---|
| 15 | {
|
|---|
| 16 | trigger_log(SYSLOG_CRIT, "Failed to open KML file $file", __FILE__, __LINE__);
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | //Counter starts at 0. For every foreach done counter will go up by one. Thus resulting in total nodes added(counter starts at 0 so add 1 to the total )
|
|---|
| 20 | $counter = 0;
|
|---|
| 21 |
|
|---|
| 22 | //Now we go through the xml files, storing the data in an array called $markers. More data can be stored by adding more rows in the array
|
|---|
| 23 | foreach($xml->Document->Folder->Placemark as $placemark)
|
|---|
| 24 | {
|
|---|
| 25 |
|
|---|
| 26 | $markers[(string)$placemark->name] = array( "latitude"=>$placemark->LookAt->latitude,
|
|---|
| 27 | "longitude"=>$placemark->LookAt->longitude,
|
|---|
| 28 | "name"=>$placemark->name,
|
|---|
| 29 | "description"=>$placemark->description,
|
|---|
| 30 | "id"=>$counter);
|
|---|
| 31 | $counter++;
|
|---|
| 32 | }
|
|---|
| 33 | return $markers;
|
|---|
| 34 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.