1. Go to this page and download the library: Download venca-x/nettegmap 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/ */
venca-x / nettegmap example snippets
Nette\Forms\NetteGMapPicker::register();//
protected function createComponentNetteGMapSimpleViewer() {
$markers = array();
$markers[] = new \Marker("home", "description", "49.1695254488", "14.2521617334");
//$netteGMapViewer->setCenterMap(new \GpsPoint(49.1695254488,14.2521617334));
//$netteGMapViewer->setScrollWheel(true);
//$netteGMapViewer->setZoom(12);
$netteGMapViewer = new \NetteGMapViewer($markers);
return $netteGMapViewer;
}
protected function createComponentNetteGMapViewerPolyline() {
$markers = array();
$markers[] = new \Marker("home", "description", "49.1695254488", "14.2521617334");
//$netteGMapViewer->setCenterMap(new \GpsPoint(49.1695254488,14.2521617334));
//$netteGMapViewer->setScrollwheel(TRUE);
//$netteGMapViewer->setZoom(12);
$netteGMapViewer = new \NetteGMapViewer($markers);
//add polyline to map
$coordinates = array(
new \GpsPoint(49.169669, 14.252152),
new \GpsPoint(49.169399, 14.252175),
new \GpsPoint(49.169532, 14.251842),
new \GpsPoint(49.169669, 14.252152)
);
$polyLine = new \PolyLine($coordinates);
$netteGMapViewer->setPolyLine($polyLine);
return $netteGMapViewer;
}
protected function createComponentGMapForm() {
$form = new Nette\Application\UI\Form;
$form->addGMap('position', 'Position:')
->setWidth("500")
->setHeight("500");
//->showMyActualPositionButton();
//->setScrollwheel(TRUE);
$form->addSubmit('send', 'Save');
$form->onSuccess[] = [$this, 'gMapFormSucceeded'];
return $form;
}
public function gMapFormSucceeded($form) {
$values = $form->getValues();
dump($values);
exit();
}