Маркер на карте, при выборе места в результатах поиска

This commit is contained in:
Krivchikov Dmitry 2015-12-06 23:33:32 +03:00
parent 8314d78f1b
commit a609173669
3 changed files with 11 additions and 4 deletions

View File

@ -57,8 +57,8 @@ class IndexController extends Controller
App::setConfig('title', App::$defaultTitle); App::setConfig('title', App::$defaultTitle);
self::addVar('isAdmin', (int) (App::$user && App::$user->isAdmin == 1)); self::addVar('isAdmin', (int) (App::$user && App::$user->isAdmin == 1));
self::addVar('pointLat', 0); self::addVar('pointLat', (isset($_GET['lat'])?floatval($_GET['lat']):0));
self::addVar('pointLng', 0); self::addVar('pointLng', (isset($_GET['lng'])?floatval($_GET['lng']):0));
$categoryArray = array(); $categoryArray = array();
foreach ($category as $cat) { foreach ($category as $cat) {

View File

@ -491,7 +491,7 @@ class JsonController extends Controller
$lat = $coords[1]; $lat = $coords[1];
$lng = $coords[0]; $lng = $coords[0];
$name = "Координаты N°" . $lat . ' E°' . $lng; $name = "Координаты N°" . $lat . ' E°' . $lng;
$results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13"); $results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13&marker=true");
} }
} }
} }
@ -517,7 +517,7 @@ class JsonController extends Controller
$name = (string) $obj->results[$index]->formatted_address; $name = (string) $obj->results[$index]->formatted_address;
$lat = (string) $obj->results[$index]->geometry->location->lat; $lat = (string) $obj->results[$index]->geometry->location->lat;
$lng = (string) $obj->results[$index]->geometry->location->lng; $lng = (string) $obj->results[$index]->geometry->location->lng;
$results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13"); $results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13&marker=true");
} }
} }
} }

View File

@ -218,6 +218,13 @@ function initPoints(useBounds)
} else if ((getURLParameter('lat') != 'null') && (getURLParameter('lng') != 'null') && (getURLParameter('zoom') != 'null')) } else if ((getURLParameter('lat') != 'null') && (getURLParameter('lng') != 'null') && (getURLParameter('zoom') != 'null'))
{ {
myMap.setView([getURLParameter('lat'), getURLParameter('lng')], getURLParameter('zoom')); myMap.setView([getURLParameter('lat'), getURLParameter('lng')], getURLParameter('zoom'));
if (getURLParameter('marker') == 'true') {
L.popup()
.setLatLng([getURLParameter('lat'), getURLParameter('lng')])
.setContent('Координаты: N°' + getURLParameter('lat').substring(0,8) + ' E°' + getURLParameter('lng').substring(0,8))
.openOn(myMap);
}
} }
} }
}); });