changed Cache behaviour
Only the map is cached not the markers.
This commit is contained in:
parent
601f3f684a
commit
94784b3870
@ -215,6 +215,8 @@ Class staticMapLite
|
|||||||
imagecopy($this->image, $tileImage, $destX, $destY, 0, 0, $this->tileSize, $this->tileSize);
|
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()
|
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()
|
public function mapCacheIDToFilename()
|
||||||
@ -367,7 +369,15 @@ Class staticMapLite
|
|||||||
public function makeMap()
|
public function makeMap()
|
||||||
{
|
{
|
||||||
$this->initCoords();
|
$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 (count($this->markers)) $this->placeMarkers();
|
||||||
if ($this->osmLogo) $this->copyrightNotice();
|
if ($this->osmLogo) $this->copyrightNotice();
|
||||||
}
|
}
|
||||||
@ -375,32 +385,9 @@ Class staticMapLite
|
|||||||
public function showMap()
|
public function showMap()
|
||||||
{
|
{
|
||||||
$this->parseParams();
|
$this->parseParams();
|
||||||
if ($this->useMapCache) {
|
$this->makeMap();
|
||||||
// use map cache, so check cache for map
|
$this->sendHeader();
|
||||||
if (!$this->checkMapCache()) {
|
return imagepng($this->image);
|
||||||
// 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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user