Skip to content

Commit

Permalink
Added style flag, fixed args issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed Jan 15, 2023
1 parent 19d07b1 commit 38cb3d6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mercator.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"os"
"flag"
"strconv"
"strings"

Expand All @@ -14,10 +14,18 @@ type model struct {
}

func main() {
args := os.Args[1:]
var style int
flag.IntVar(&style, "style", int(mapview.OpenStreetMaps), "map style to use (0 - 11)")
flag.Parse()

args := flag.Args()

m := NewModel()

if style >= 0 && style < 12 {
m.mv.SetStyle(mapview.Style(style))
}

var isLatLng bool = false
if len(args) == 2 {
lat, err1 := strconv.ParseFloat(args[0], 64)
Expand All @@ -27,7 +35,7 @@ func main() {
m.mv.SetLatLng(lat, lng, 15)
}
}
if len(args) < 2 || len(args) > 2 && !isLatLng {
if !isLatLng {
m.mv.SetLocation(strings.Join(args, " "), 15)
}

Expand Down

0 comments on commit 38cb3d6

Please # to comment.