Reference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class GeoPoint.
Represents a geographical point.
Unless specified otherwise, this must conform to the WGS84 standard. Values must be within normalized ranges.
Example:
use Google\Cloud\Core\GeoPoint;
$point = new GeoPoint(37.423147, -122.085015);
Namespace
Google \ Cloud \ CoreMethods
__construct
Create a GeoPoint.
Ints will be converted to floats. Values not passing the is_numeric()
check will result in an exception.
Parameters | |
---|---|
Name | Description |
latitude |
float|int|null
The GeoPoint Latitude. Note that
|
longitude |
float|int|null
The GeoPoint Longitude. Note that
|
allowNull |
bool
[optional] If true, null values will be allowed
in the constructor only. This switch exists to handle a rare case
wherein a geopoint may be empty and is not intended for use from
outside the client. Defaults to |
latitude
Get the latitude
Example:
$latitude = $point->latitude();
Returns | |
---|---|
Type | Description |
float|null |
setLatitude
Set the latitude
Non-numeric values will result in an exception
Example:
$point->setLatitude(42.279594);
Parameter | |
---|---|
Name | Description |
latitude |
int|float
The new latitude |
Returns | |
---|---|
Type | Description |
GeoPoint |
longitude
Get the longitude
Example:
$longitude = $point->longitude();
Returns | |
---|---|
Type | Description |
float|null |
setLongitude
Set the longitude
Non-numeric values will result in an exception.
Example:
$point->setLongitude(-83.732124);
Parameter | |
---|---|
Name | Description |
longitude |
float|int
The new longitude value |
Returns | |
---|---|
Type | Description |
GeoPoint |
point
Return a GeoPoint
Example:
$point = $point->point();
Returns | |
---|---|
Type | Description |
array |
[LatLng](https://cloud.google.com/datastore/reference/rest/Shared.Types/LatLng) |
jsonSerialize
Implement JsonSerializable by representing GeoPoint as a JSON-object:
{
latitude: 31.778333
longitude: 35.229722
}
Returns | |
---|---|
Type | Description |
object |