mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-20 00:37:26 +00:00
19 lines
610 B
CoffeeScript
19 lines
610 B
CoffeeScript
# Usage:
|
|
# Geo.geocode address, (results, status) ->
|
|
# if status == Geo.OK
|
|
# console.log results[0].geometry.location
|
|
# else
|
|
# console.log "Error: #{status}"
|
|
|
|
Darkswarm.service "Geo", ->
|
|
new class Geo
|
|
OK: google.maps.GeocoderStatus.OK
|
|
|
|
geocode: (address, callback) ->
|
|
geocoder = new google.maps.Geocoder()
|
|
geocoder.geocode {'address': address}, callback
|
|
|
|
distanceBetween: (locatable, location) ->
|
|
latLng = new google.maps.LatLng locatable.latitude, locatable.longitude
|
|
google.maps.geometry.spherical.computeDistanceBetween latLng, results[0].geometry.location
|