Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Olicek committed Sep 13, 2014
1 parent 548ff59 commit 3e22feb
Showing 1 changed file with 51 additions and 51 deletions.
102 changes: 51 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,42 +67,42 @@ Simplest usage

To your presenter include (if you have PHP 5.4+)

``` php
class MapPresenter extends Nette\Application\UI\Presenter
{
use \Oli\GoogleAPI\TMap;

class MapPresenter extends Nette\Application\UI\Presenter
{
use \Oli\GoogleAPI\TMap;
// ...
}

// ...
}
```
and to template

{control map}


Define map in component
=======================
``` php
private $map;
private $markers;

public function __constructor(\Oli\GoogleAPI\IMapAPI $mapApi, \Oli\GoogleAPI\IMarkers $markers)
{
$this->map = $mapApi;
$this->markers = $markers;
}

private $map;
private $markers;
public function createComponentMap()
{
$map = $this->map->create();
$markers = $this->markers->create();

public function __constructor(\Oli\GoogleAPI\IMapAPI $mapApi, \Oli\GoogleAPI\IMarkers $markers)
{
$this->map = $mapApi;
$this->markers = $markers;
}
// ...

public function createComponentMap()
{
$map = $this->map->create();
$markers = $this->markers->create();
// ...
$map->addMarkers($markers);
return $map;
}

$map->addMarkers($markers);
return $map;
}
```
And in template

{* JS and HTML *}
Expand Down Expand Up @@ -171,34 +171,34 @@ config.neon
defaultIconPath: images/mapPoints

Presenter

protected function createComponentGoogleMap()
{
$map = $this->map->create();
$map->setCoordinates(array(50.250718,14.583435))
->setZoom(4)
->setType(MapAPI::TERRAIN);
$markers = $this->markers->create();
$markers->fitBounds();
if(count($markersFromDb) > 30)
{
$markers->isMarkerClusterer();
}
``` php
protected function createComponentGoogleMap()
{
$map = $this->map->create();

$map->setCoordinates(array(50.250718,14.583435))
->setZoom(4)
->setType(MapAPI::TERRAIN);

foreach ($markersFromDb as $marker)
{
$markers->addMarker(array($marker->lat, $marker->lng), Marker::DROP)
->setMessage(
'<h1>'.$marker->title.'</h1><br />'.$marker->description
)->setIcon($marker->icon);
}
$map->addMarkers($markers);
return $map;
$markers = $this->markers->create();
$markers->fitBounds();

if(count($markersFromDb) > 30)
{
$markers->isMarkerClusterer();
}


foreach ($markersFromDb as $marker)
{
$markers->addMarker(array($marker->lat, $marker->lng), Marker::DROP)
->setMessage(
'<h1>'.$marker->title.'</h1><br />'.$marker->description
)->setIcon($marker->icon);
}
$map->addMarkers($markers);
return $map;
}
```
Template

{block content}
Expand Down

0 comments on commit 3e22feb

Please sign in to comment.