changed Cache behaviour

Only the map is cached not the markers.
This commit is contained in:
Dennis Glittenberg 2016-05-22 15:04:43 +02:00
parent 601f3f684a
commit 94784b3870
1 changed files with 15 additions and 28 deletions

View File

@ -215,6 +215,8 @@ Class staticMapLite
imagecopy($this->image, $tileImage, $destX, $destY, 0, 0, $this->tileSize, $this->tileSize);
}
}
$this->mkdir_recursive(dirname($this->mapCacheIDToFilename()), 0777);
imagepng($this->image, $this->mapCacheIDToFilename(), 9);
}
@ -307,7 +309,7 @@ Class staticMapLite
public function serializeParams()
{
return join("&", array($this->zoom, $this->lat, $this->lon, $this->width, $this->height, serialize($this->markers), $this->maptype));
return join("&", array($this->zoom, $this->lat, $this->lon, $this->width, $this->height, $this->maptype));
}
public function mapCacheIDToFilename()
@ -367,7 +369,15 @@ Class staticMapLite
public function makeMap()
{
$this->initCoords();
$this->createBaseMap();
if ($this->useMapCache){
if($this->checkMapCache()){
$this->image = imagecreatefrompng($this->mapCacheIDToFilename());
} else{
$this->createBaseMap();
}
} else{
$this->createBaseMap();
}
if (count($this->markers)) $this->placeMarkers();
if ($this->osmLogo) $this->copyrightNotice();
}
@ -375,32 +385,9 @@ Class staticMapLite
public function showMap()
{
$this->parseParams();
if ($this->useMapCache) {
// use map cache, so check cache for map
if (!$this->checkMapCache()) {
// map is not in cache, needs to be build
$this->makeMap();
$this->mkdir_recursive(dirname($this->mapCacheIDToFilename()), 0777);
imagepng($this->image, $this->mapCacheIDToFilename(), 9);
$this->sendHeader();
if (file_exists($this->mapCacheIDToFilename())) {
return file_get_contents($this->mapCacheIDToFilename());
} else {
return imagepng($this->image);
}
} else {
// map is in cache
$this->sendHeader();
return file_get_contents($this->mapCacheIDToFilename());
}
} else {
// no cache, make map, send headers and deliver png
$this->makeMap();
$this->sendHeader();
return imagepng($this->image);
}
$this->makeMap();
$this->sendHeader();
return imagepng($this->image);
}
}