/** * Returns the latitude value. * * @return double */ public function getLatitude() { if (null === $this->address) { return null; } return $this->address->getLatitude(); }
/** * @param Address $address * * @return string */ public function dump(Address $address) { $gpx = sprintf(<<<GPX <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <gpx version="1.0" creator="Geocoder" version="%s" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> GPX , Geocoder::VERSION); if ($address->getBounds()->isDefined()) { $bounds = $address->getBounds(); $gpx .= sprintf(<<<GPX <bounds minlat="%f" minlon="%f" maxlat="%f" maxlon="%f"/> GPX , $bounds->getWest(), $bounds->getSouth(), $bounds->getEast(), $bounds->getNorth()); } $gpx .= sprintf(<<<GPX <wpt lat="%.7f" lon="%.7f"> <name><![CDATA[%s]]></name> <type><![CDATA[Address]]></type> </wpt> GPX , $address->getLatitude(), $address->getLongitude(), $this->formatName($address)); $gpx .= <<<GPX </gpx> GPX; return $gpx; }
public static function mapRenderer(Address $address) { static::setContentType('text/html'); $formatter = new \Geocoder\Formatter\StringFormatter(); $latitude = $address->getLatitude(); $longitude = $address->getLongitude(); $title = $formatter->format($address, "%L, %S, %n"); $body = "\n\t\t\t<iframe \n\t\t\t\tframeborder='0'\n\t\t\t\tscrolling='no' \n\t\t\t\tmarginheight='0'\n\t\t\t\tmarginwidth='0'\n\t\t\t\twidth='300' \n\t\t\t\theight='300' \n\t\t\t\tsrc='https://maps.google.com/maps?hl=en&q={$latitude}, {$longitude}&ie=UTF8&t=m&z=19&iwloc=B&output=embed'>\n\t\t\t</iframe>\t\n\t\t"; return static::htmlSerializer($body, static::$htmlMetadata, $title, null, self::GoogleAnalyticsSnippet(), true); }
/** * Set the latitude and the longitude of the coordinates into an selected ellipsoid. * * @param Address|array|string $coordinates The coordinates. * @param Ellipsoid $ellipsoid The selected ellipsoid (WGS84 by default). * * @throws InvalidArgumentException */ public function __construct($coordinates, Ellipsoid $ellipsoid = null) { if ($coordinates instanceof Address) { $this->setLatitude($coordinates->getLatitude()); $this->setLongitude($coordinates->getLongitude()); } elseif (is_array($coordinates) && 2 === count($coordinates)) { $this->setLatitude($coordinates[0]); $this->setLongitude($coordinates[1]); } elseif (is_string($coordinates)) { $this->setFromString($coordinates); } else { throw new InvalidArgumentException('It should be a string, an array or a class which implements Geocoder\\Model\\Address !'); } $this->ellipsoid = $ellipsoid ?: Ellipsoid::createFromName(Ellipsoid::WGS84); }
/** * {@inheritDoc} */ public function dump(Address $address) { $properties = array_filter($address->toArray(), function ($value) { return !empty($value); }); unset($properties['latitude'], $properties['longitude'], $properties['bounds']); if (0 === count($properties)) { $properties = null; } $json = ['type' => 'Feature', 'geometry' => ['type' => 'Point', 'coordinates' => [$address->getLongitude(), $address->getLatitude()]], 'properties' => $properties]; if (null !== ($bounds = $address->getBounds())) { if ($bounds->isDefined()) { $json['bounds'] = $bounds->toArray(); } } return json_encode($json); }
public function insertUserInformation($ipAddress, $userAgentString, $sapiName, GeocoderResult $geocoderResult = null) { $userAgent = new UserAgent(); $userAgent->setUserAgent($userAgentString); $browser = $userAgent->browser(); $platform = $userAgent->platform(); $data = ['ip_address' => $ipAddress, 'sapi_name' => substr($sapiName, 0, 32), 'user_agent' => substr($userAgentString, 0, 255), 'user_agent_browser' => substr($browser, 0, 32), 'user_agent_device' => substr($userAgent->device(), 0, 32), 'user_agent_browser_version' => substr($userAgent->version($browser), 0, 32), 'user_agent_platform_version' => substr($userAgent->version($platform), 0, 32), 'user_agent_platform' => substr($platform, 0, 32), 'user_agent_robot' => substr($userAgent->robot(), 0, 32)]; if ($geocoderResult) { $region = $geocoderResult->getAdminLevels()->first(); $data['geo_city'] = substr($geocoderResult->getLocality(), 0, 32); $data['geo_region'] = $region ? substr($region->getCode(), 0, 32) : null; $data['geo_country'] = substr($geocoderResult->getCountry(), 0, 32); $data['geo_country_code'] = substr($geocoderResult->getCountryCode(), 0, 6); $data['geo_latitude'] = substr($geocoderResult->getLatitude(), 0, 32); $data['geo_longitude'] = substr($geocoderResult->getLongitude(), 0, 32); } $this->getAdapter()->insert('dewdrop_activity_log_user_information', $data); return $this->getAdapter()->lastInsertId(); }
/** * {@inheritDoc} */ public function dump(Address $address) { return pack('cLdd', 1, 1, $address->getLongitude(), $address->getLatitude()); }
/** * {@inheritDoc} */ public function dump(Address $address) { return sprintf('POINT(%F %F)', $address->getLongitude(), $address->getLatitude()); }
/** * Set coordinates * * @param \Geocoder\Model\Address $coordinates * @return Geo */ private function setCoordinates(\Geocoder\Model\Address $coordinates) { $this->coordinates = ['latitude' => $coordinates->getLatitude(), 'longtitude' => $coordinates->getLongitude()]; return $this; }