1. Go to this page and download the library: Download occ2/nette-mapy-cz library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
occ2 / nette-mapy-cz example snippets
use MapyCZ\Controls\MapControl\Factories\IMapControlFactory;
use MapyCZ\Controls\MapControl;
use Nette\Application\UI\Form;
/**
* @var IMapControlFactory
* @inject
*/
public $mapControlFactory;
...
/**
* @return MapControl
* @param string $name
*/
protected function createComponentMap(string $name): MapControl
{
$map = $this->mapControlFactory->create();
$map->settings = [
"mapId" => "map", // HTML id of map element
"width" => 400, // map width in pixels
"height" => 300, // map height in pixels
"units" => "px", // units of map dimensiosns
"mapType" => 1, // default map
"center" => [ // default center of map
"latitude" => 50,
"longitude" => 15,
],
"defaultZoom" => 13, // default zoom
"controls" => true, // show controls
];
$this->addComponent($map, $name);
return $map;
}
...
/**
* @return Form
* @param string $name
*/
protected function createComponentForm(string $name): Form
{
$form = new Form();
...
$form->addGpsPicker('gps', 'Vyberte polohu')
->setSettings([
"mapId" => "map",
"width" => 400,
"height" => 300,
"mapType" => 1,
"units" => "px",
"center" => [
"latitude" => 50,
"longitude" => 15,
],
"defaultZoom" => 12,
"controls" => true,
]);
..
$this-addComponent($form, $name);
return $form;
}