make_clusters( $page['items'], isset($_GET['lap']) ? $_GET['lap'] : 0.01, isset($_GET['lop']) ? $_GET['lop'] : 0.01, isset($_GET['n']) ? $_GET['n'] : rvm_get_config_var('nb_markers',40) ); $cluster_debug .= ' cluster: '. $cm->debug_str. ';'; } function jsgm_position( $position ) { return 'new google.maps.LatLng(' . $position['lat'] . ',' . $position['lon'] . ')'; } function jsgm_bounds( $bounds ) { return 'new google.maps.LatLngBounds(' . jsgm_position(bounds_sw($bounds)) . ',' . jsgm_position(bounds_ne($bounds)) . ')'; } function jsgm_str( $str ) { return '"'. str_replace(array("\\",'"',"\n","\r","\t"), array("\\\\",'\"',"\\n","\\r","\\t"), $str) .'"'; } $out=''; function rvo($s) { global $out; $out.=$s; } function rvf() { global $out; echo $out; $out=''; ob_flush(); } $start_output = get_moment(); rvo( '{' ); rvo( "\ntitle:".jsgm_str( strip_tags(trigger_event('render_element_description', $page['title']) ) ) ); rvo( ",\n" ); rvo( "page_url:".jsgm_str( duplicate_index_url( array('start'=>0) ) ) ); rvo( ",\n" ); rvo( "blowup_url:".jsgm_str( rvm_duplicate_blowup_url( array('start'=>0) ) ) ); rvo( ",\n" ); rvo( "kml_url:".jsgm_str( rvm_duplicate_kml_index_url( array('start'=>0, 'flat'=>1) ) ) ); rvo( ",\n" ); rvo( "nb_items:".count($page['items']) ); rvo( ",\n" ); rvo( "bounds:" ); if ( isset($cm) ) rvo( jsgm_bounds( $cm->bounds ) ); else rvo( "null" ); rvo( ",\n" ); rvo( "\nnb_clusters:".count($clusters) ); rvo( "," ); rvo( "\nimage_clusters:[\n" ); $i=0; foreach( $clusters as $c ) { if ($i) rvo( ",\n\n" ); rvo( "{" ); rvo( 'position:'. jsgm_position( bounds_center($c->bounds) ) ); rvo( ",\n" ); rvo( 'bounds:'. jsgm_bounds( $c->bounds ) ); rvo( ",\n" ); rvo( 'nb_items:'.count($c->items) ); rvo( ",\n" ); rvo( 'blowup_url:"'.rvm_duplicate_blowup_url(array('box'=>$c->bounds), array('start') ). '"' ); rvo( ",\n" ); $max_per_cluster = rvm_get_config_var('nb_images_per_marker',20); if ( count($c->items) > $max_per_cluster ) { $c->items = array_slice($c->items, 0, $max_per_cluster); } rvo( 'items:[' ); for ($j=0; $jitems); $j++) { $img = $page['items'] [ $c->items[$j] ]; $img['file'] = basename( $img['path'] ); if (!empty( $img['name'] ) ) $title = $img['name']; else $title = str_replace('_', ' ', get_filename_wo_extension($img['file'])); $params = array( 'image_id' => $img['id'], 'image_file' => $img['file'], 'flat' => 1, ); $page_url = duplicate_picture_url($params, array('start') ); if ($j) rvo( "," ); rvo( "{" ); rvo( "tn:".jsgm_str( get_thumbnail_url( $img ) ) ); rvo( ",name:".jsgm_str( trigger_event('render_element_description', $title) ) ); rvo( ",comment:".jsgm_str( trigger_event('render_element_description', $img['comment']) ) ); rvo( ",page_url:".jsgm_str( $page_url ) ); rvo( "}" ); } rvo( ']' ); rvo( "\n" ); rvo( "}" ); rvf(); $i++; } rvo( "] /*clusters*/\n" ); $time = get_elapsed_time($t2, get_moment()); $page['queries_time'] = number_format($page['queries_time'],3,'.',' '); rvo( "\n,debug:'$time; out:".get_elapsed_time($start_output,get_moment()).";$cluster_debug queries:".$page['count_queries']." in ".$page['queries_time']."s'\n" ); rvo( '}' ); rvf(); ?>