# CarLocation

# CarLocation

Artifact:[androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app)  
[View Source](https://cs.android.com/search?q=file:androidx/car/app/model/CarLocation.java+class:androidx.car.app.model.CarLocation)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/car/app/model/CarLocation "View this page in Java")

<br />

```
@CarProtocol
class CarLocation
```

<br />

*** ** * ** ***

Represents a geographical location with a latitude and a longitude.

## Summary

|                                              ### Public functions                                              |
|----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[CarLocation](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation) | [create](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation#create(android.location.Location))`(location: `[Location](https://developer.android.com/reference/android/location/Location.html)`)` Returns a new instance of a[CarLocation](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation)with the same latitude and longitude contained in the given[Location](https://developer.android.com/reference/android/location/Location.html). |
| `java-static `[CarLocation](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation) | [create](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation#create(double,double))`(latitude: `[Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)`, longitude: `[Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)`)` Returns a new instance of a[CarLocation](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation).                                                           |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                            | [equals](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation#equals(java.lang.Object))`(other: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)`                                                                                                                                                                                                                                                                                             |
| [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)                              | [getLatitude](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation#getLatitude())`()` Returns the latitude of the location, in degrees.                                                                                                                                                                                                                                                                                                                                      |
| [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)                              | [getLongitude](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation#getLongitude())`()` Returns the longitude of the location, in degrees.                                                                                                                                                                                                                                                                                                                                   |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                    | [hashCode](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation#hashCode())`()`                                                                                                                                                                                                                                                                                                                                                                                              |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!`                           | [toString](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation#toString())`()`                                                                                                                                                                                                                                                                                                                                                                                              |

## Public functions

### create

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
java-static fun create(location: Location): CarLocation
```

Returns a new instance of a[CarLocation](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation)with the same latitude and longitude contained in the given[Location](https://developer.android.com/reference/android/location/Location.html).  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|----------------------|
| [java.lang.NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException.html) | if`location`is`null` |

### create

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
java-static fun create(latitude: Double, longitude: Double): CarLocation
```

Returns a new instance of a[CarLocation](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation).  

### equals

```
fun equals(other: Any?): Boolean
```  

### getLatitude

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
fun getLatitude(): Double
```

Returns the latitude of the location, in degrees.  

### getLongitude

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)  

```
fun getLongitude(): Double
```

Returns the longitude of the location, in degrees.  

### hashCode

```
fun hashCode(): Int
```  

### toString

```
fun toString(): String!
```