Skip to content

Commit

Permalink
keybinding to query location
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Apr 28, 2017
1 parent 624002a commit 0fcd2b3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Mapscii.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = class Mapscii
@_draw()

.then =>
@_requestLocation()
@requestLocation()

_initTileSource: ->
@tileSource = new TileSource()
Expand Down Expand Up @@ -144,6 +144,8 @@ module.exports = class Mapscii
when "q"
process.exit 0

when "l" then @requestLocation true

when "w" then @zoomy = 1
when "s" then @zoomy = -1

Expand Down Expand Up @@ -188,13 +190,16 @@ module.exports = class Mapscii
"zoom: #{utils.digits @zoom, 2} "+
"mouse: #{@mousePosition.x-@width/2} #{@mousePosition.y-@height/2} "

_requestLocation: ->
requestLocation: (zoom = false) ->
@notify "Querying your location…"
queryLocation()
.then (location) =>
@setCenter(location.latitude, location.longitude)
@setCenter location.latitude, location.longitude
# TODO set zoom level according to precision
@zoom = 16
@zoom = 16 if zoom
@_draw()
.catch (error) =>
@notify "Couldn't query your location."

notify: (text) ->
@_write "\r\x1B[K"+text unless config.headless
Expand Down

0 comments on commit 0fcd2b3

Please sign in to comment.