# Google Cloud PHP shared dependency, providing functionality useful to all components. Client - Class GeoPoint (1.72.2)

1.72.2 (latest) 1.72.1 1.71.2 1.70.0 1.69.0 1.68.2 1.67.0 1.66.0 1.65.0 1.64.3 1.63.0 1.62.3 1.61.0 1.60.1 1.59.1 1.58.2 1.53.0 1.52.11 1.51.2 1.50.0 1.49.3 1.48.1 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](http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf) standard.
Values must be within normalized ranges.

Example:

    use Google\Cloud\Core\GeoPoint;

    $point = new GeoPoint(37.423147, -122.085015);

## Namespace

Google \\ Cloud \\ Core

## Methods

### __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 `null` is not a generally valid value, and will throw an `InvalidArgumentException` unless `$allowNull` is set to `true`. |
| `longitude` | `float|int|null` The GeoPoint Longitude. **Note** that `null` is not a generally valid value, and will throw an `InvalidArgumentException` unless `$allowNull` is set to `true`. |
| `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** `false`. |

### 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** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-core/latest/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** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-core/latest/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` |   |