[google_maps]'; $title = 'La Malu II, Reis naar de antipodes'; $text = parse_google_maps($text); function array_to_json( $array ){ if( !is_array( $array ) ){ return false; } $associative = count( array_diff( array_keys($array), array_keys( array_keys( $array )) )); if( $associative ){ $construct = array(); foreach( $array as $key => $value ){ // We first copy each key/value pair into a staging array, // formatting each key and value properly as we go. // Format the key: if( is_numeric($key) ){ $key = "key_$key"; } $key = "'".addslashes($key)."'"; // Format the value: if( is_array( $value )){ $value = array_to_json( $value ); } else if( !is_numeric( $value ) || is_string( $value ) ) { $value = "'".addslashes($value)."'"; } // Add to staging array: $construct[] = "$key: $value"; } // Then we collapse the staging array into the JSON form: $result = "{ " . implode( ", ", $construct ) . " }"; } else { // If the array is a vector (not associative): $construct = array(); foreach( $array as $value ){ // Format the value: if( is_array( $value )){ $value = array_to_json( $value ); } else if( !is_numeric( $value ) || is_string( $value ) ){ $value = "'".addslashes($value)."'"; } // Add to staging array: $construct[] = $value; } // Then we collapse the staging array into the JSON form: $result = "[ " . implode( ", ", $construct ) . " ]"; } return $result; } function prepare_chars($value) { $value = str_replace("'", htmlentities("'"), $value); $value = str_replace('"', htmlentities('"'), $value); $value = nl2br($value); return $value; } function parse_google_maps($text) { global $taal ; $sql ="SELECT id, lat, lng, zoom, nl, fr, en, created, modified FROM google_maps_markers ORDER BY datum DESC, created DESC "; $res = safe_query($sql); $markers = array(); $markerSelected = -1; $markerString = ""; $polylineString = ''; $i=0; while($row = mysql_fetch_array($res)) { // $row['nl'] = htmlentities($row['nl']); // $row['fr'] = htmlentities($row['fr']); // $row['en'] = htmlentities($row['en']); $markers[$i] = array('id'=>$row['id'], 'lat'=>$row['lat'], 'lng'=>$row['lng'], 'zoom'=>$row['zoom'], 'nl'=>'nl', 'fr'=>'fr', 'en'=>'en', 'created'=>$row['created'], 'modified'=>$row['modified']); $polylineString .= ($i>0?',':'') . PHP_EOL . ' new GLatLng('. $row['lat'] .', '. $row['lng'] .')'; if ($row['id'] == $id) $markerSelected = $i; $markerString .= '
'. $row[$taal] .' ('. $row['lat'] .', '. $row['lng'] .')
'.PHP_EOL; $i++; } // extra javascript $js =" var global_taal = '". $taal ."'; var m_google_maps = new google_maps('map'); var markersinDb = ''; function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, false); return true; } else if (obj.attachEvent){ var r = obj.attachEvent('on'+evType, fn); return r; } else { return false; } } function load() { markersinDb = eval(\"". array_to_json($markers) ."\"); m_google_maps.init(true); } addEvent(window, 'load', load); addEvent(window, 'unload', GUnload); "; $module = '
'; return str_replace('[google_maps]', $module, $text) ; } ?>

Download Google Earth addon