new GeoPoint()
The GeoPoint object represents a physical location.
For example:
```js
var loopback = require(‘loopback’);
var here = new loopback.GeoPoint({lat: 10.32424, lng: 5.84978});
```
Embed a latitude / longitude point in a model.
```js
var CoffeeShop = loopback.createModel('coffee-shop', {
location: 'GeoPoint'
});
```
You can query LoopBack models with a GeoPoint property and an attached data source using geo-spatial filters and
sorting. For example, the following code finds the three nearest coffee shops.
```js
CoffeeShop.attachTo(oracle);
var here = new GeoPoint({lat: 10.32424, lng: 5.84978});
CoffeeShop.find( {where: {location: {near: here}}, limit:3}, function(err, nearbyShops) {
console.info(nearbyShops); // [CoffeeShop, ...]
});
```
Properties:
Name |
Type |
Description |
lat |
Number
|
The latitude in degrees. |
lng |
Number
|
The longitude in degrees. |
lat |
Number
|
The latitude point in degrees. Range: -90 to 90. |
lng |
Number
|
The longitude point in degrees. Range: -180 to 180. |
lat |
Number
|
The latitude point in degrees. Range: -90 to 90. |
lng |
Number
|
The longitude point in degrees. Range: -180 to 180. |
- Source:
Methods
distanceTo(point)
Determine the spherical distance to the given point.
Example:
```js
var loopback = require(‘loopback’);
var here = new loopback.GeoPoint({lat: 10, lng: 10});
var there = new loopback.GeoPoint({lat: 5, lng: 5});
loopback.GeoPoint.distanceBetween(here, there, {type: 'miles'}) // 438
```
Parameters:
Name |
Type |
Description |
point |
Object
|
GeoPoint object to which to measure distance. |
Properties:
Name |
Type |
Description |
type |
String
|
Unit of measurement, one of:
- `miles` (default)
- `radians`
- `kilometers`
- `meters`
- `miles`
- `feet`
- `degrees` |
- Source:
toString()
Simple serialization.
- Source:
(static) distanceBetween(pointA, pointB)
Determine the spherical distance between two GeoPoints.
Parameters:
Properties:
Name |
Type |
Description |
type |
String
|
Unit of measurement, one of:
- `miles` (default)
- `radians`
- `kilometers`
- `meters`
- `miles`
- `feet`
- `degrees` |
- Source: