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