Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heatmap layer support #24

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
43 changes: 43 additions & 0 deletions Layer/HeatmapLayer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace PHPGoogleMaps\Layer;

use PHPGoogleMaps\Core\LatLng;
use PHPGoogleMaps\Core\MapObject;

/**
* Heatmap Layer
*
* @link https://developers.google.com/maps/documentation/javascript/heatmaplayer
*/
class HeatmapLayer extends MapObject
{

/**
* Constructor
*
* @param array $options Array of options
*/
public function __construct(array $options = null)
{
if ($options) {
unset($options['map']);
$this->options = $options;
}
}

/**
* Add a Coordinate
*
* @param LatLng $latLng
* @return void
*/
public function addLatLng(LatLng $latLng)
{
if (!isset($this->options['data'])) {
$this->options['data'] = array();
}
$this->options['data'][] = $latLng;
}

}
48 changes: 48 additions & 0 deletions Layer/HeatmapLayerDecorator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace PHPGoogleMaps\Layer;

/**
* Panoramio layer decorator
*
* Decorate a panoramio layer after it has been added to a map
*/


class HeatmapLayerDecorator extends \PHPGoogleMaps\Core\MapObjectDecorator {

/**
* Id of the HeatmapLayer layer in the map
*
* @var integer
*/
protected $_id;

/**
* Map id the HeatmapLayer is attached to
*
* @var string
*/
protected $_map;

/**
* Constructor
*
* @param HeatmapLayer $heatmapLayer
* @param int $id ID of the HeatmapLayer layer in the map
* @param string $map Map Id of the map the HeatmapLayer is attached to
*/
public function __construct( HeatmapLayer $heatmapLayer, $id, $map ) {
parent::__construct( $heatmapLayer, array( '_id' => $id, '_map' => $map ) );
}

/**
* Returns the javascript variable of the Heatmap layer
*
* @return string
*/
public function getJsVar() {
return sprintf( '%s.heatmap_layers[%s]', $this->_map, $this->_id );
}

}
Loading