public function getArray() { $array = array("title" => $this->title, "description" => $this->description, "latitude" => $this->gpsPoint->getLatitude(), "longitude" => $this->gpsPoint->getLongitude()); if ($this->icon != null) { $array["icon"] = $this->icon; } return $array; }
public function render() { $template = $this->template; $mapParamsArray = $this->getMapParams(); $mapParamsArray["layer"] = array("layerUrlImage" => $this->layerUrlImage, "LeftDownCorner" => array("lat" => $this->layerLeftDownCorner->getLatitude(), "lng" => $this->layerLeftDownCorner->getLongitude()), "RightTopCorner" => array("lat" => $this->layerRightTopCorner->getLatitude(), "lng" => $this->layerRightTopCorner->getLongitude())); $template->json = json_encode($mapParamsArray); $template->setFile(__DIR__ . '/layer.latte'); $template->render(); }
public function getMapParams() { $array = array(); $array['map'] = array('size' => array('x' => $this->sizeX, 'y' => $this->sizeY), 'scrollwheel' => $this->scrollwheel); if ($this->centerMapGpsPoint != NULL) { $array['map']['center'] = array('lat' => $this->centerMapGpsPoint->getLongitude(), 'lng' => $this->centerMapGpsPoint->getLatitude()); } if ($this->zoom != NULL) { $array['map']['zoom'] = $this->zoom; } if (count($this->markers) > 0) { $array['markers'] = $this->markers; } if ($this->polyLine != NULL) { $array['polyline'] = $this->polyLine->getArray(); } return $array; }
function findNearestWaypoint($lat, $lon) { global $waypoints; $point = new GpsPoint(); $point->setLat($lat); $point->setLon($lon); if (count($waypoints) == 0) { $waypoints = getWaypoints(); } $nearestID = 0; $minDistance = 1000000; foreach ($waypoints as $waypoint) { $distance = $point->calcDistance($waypoint); if ($distance < $minDistance) { $minDistance = $distance; $nearestID = $waypoint->waypointID; } } return array($nearestID, $minDistance); }