Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add some caching to demos in case they become too popular.

  • Loading branch information...
commit ef3f09d34aa8a864ef1aac5a7335990e427f386e 1 parent 1e69b90
@tuupola authored
Showing with 40 additions and 13 deletions.
  1. +15 −2 cluster.html
  2. +25 −11 kml.html
View
17 cluster.html
@@ -1,7 +1,17 @@
<?php
+require_once 'Cache/Lite.php';
require_once 'Benchmark/Timer.php';
+$cache = new Cache_Lite();
+
+if ($data = $cache->get($_SERVER['REQUEST_URI'])) {
+ print $data;
+ die();
+}
+
+ob_start();
+
$timer = new Benchmark_Timer(true);
$timer->start();
@@ -50,11 +60,10 @@
$timer->setMarker('Clustered');
$timer->stop();
-$timer->display();
+//$timer->display();
//print $map->toUrl();
-print strlen($map->toUrl());
//die();
?>
@@ -194,4 +203,8 @@
</body>
</html>
+<?php
+$data = ob_get_contents();
+$cache->save($data);
+?>
View
36 kml.html
@@ -1,5 +1,16 @@
<?php
+require_once 'Cache/Lite.php';
+
+$cache = new Cache_Lite();
+
+if ($data = $cache->get($_SERVER['REQUEST_URI'])) {
+ print $data;
+ die();
+}
+
+ob_start();
+
require_once 'Google/Maps.php';
$map = Google_Maps::create('static');
@@ -11,6 +22,9 @@
$pan = Google_Maps_Control::create('pan');
$map->addControl($pan);
+$clusterer = Google_Maps_Clusterer::create('distance');
+$map->setClusterer($clusterer);
+
$xml = simplexml_load_file('http://kaskoabi.ergoaitab.ee/ergo2.kml', null, LIBXML_NOCDATA);
foreach ($xml->Document->Placemark as $placemark) {
@@ -29,15 +43,6 @@
$map->setProperties($_GET);
-$clusterer = Google_Maps_Clusterer::create('distance');
-$map->setClusterer($clusterer);
-
-//print_r($map->getClusteredMarkers('array', $map->getBounds()));
-
-/*
-print strlen($map->toUrl());
-print $map->toUrl();
-*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -89,7 +94,8 @@
<br /><br />
<p>
Markers and infowindow data comes from <a href="http://kaskoabi.ergoaitab.ee/ergo2.kml">KML</a>.
- Zooming and panning works. There is noJavaScript (except Google Analytics) used in this page.
+ Zooming and panning works. There is noJavaScript (except Google Analytics) used in this page.
+ Markers are clustered using distance based clustering.
Map is created using following code:
</p>
<p>
@@ -105,6 +111,9 @@
$pan = Google_Maps_Control::create('pan');
$map->addControl($pan);
+$clusterer = Google_Maps_Clusterer::create('distance');
+$map->setClusterer($clusterer);
+
$xml = simplexml_load_file('http://kaskoabi.ergoaitab.ee/ergo2.kml',
null, LIBXML_NOCDATA);
@@ -113,6 +122,8 @@
explode(',', $placemark->Point->coordinates, 3);
$coordinate = new Google_Maps_Coordinate($latitude, $longitude);
$marker = new Google_Maps_Marker($coordinate);
+ $marker->setSize('small');
+ $marker->setColor('blue');
$bubble = new Google_Maps_Infowindow($placemark->description);
$bubble->setMarker($marker);
$map->addMarker($marker);
@@ -173,4 +184,7 @@
</body>
</html>
-
+<?php
+$data = ob_get_contents();
+$cache->save($data);
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.