Better "near me" feature
This commit is contained in:
parent
803b4858be
commit
49d9f83c2b
@ -1,16 +1,17 @@
|
|||||||
$(document).on 'turbolinks:load', ->
|
$(document).on 'turbolinks:load', ->
|
||||||
$('.digest .filter').each ->
|
return unless navigator.geolocation
|
||||||
|
|
||||||
|
$('.digest .filter:first-child').each ->
|
||||||
$(this).before '
|
$(this).before '
|
||||||
<a id="nearMe" href="#">
|
<a id="nearMe" href="#" title="⯐">
|
||||||
<em class="fa fa-2x fa-street-view"></em>
|
<em class="fa fa-2x fa-street-view"></em>
|
||||||
</a>'
|
</a>'
|
||||||
$('#nearMe').click (event) ->
|
$('#nearMe').click (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
nearMe()
|
navigator.geolocation.getCurrentPosition showPosition, (error) ->
|
||||||
|
switch error.code
|
||||||
nearMe = ->
|
when error.PERMISSION_DENIED
|
||||||
if (navigator.geolocation)
|
$('#nearMe').remove()
|
||||||
navigator.geolocation.getCurrentPosition showPosition
|
|
||||||
|
|
||||||
showPosition = (position) ->
|
showPosition = (position) ->
|
||||||
coords = "[#{position.coords.latitude}, #{position.coords.longitude}]"
|
coords = "[#{position.coords.latitude}, #{position.coords.longitude}]"
|
||||||
|
Loading…
Reference in New Issue
Block a user