Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
flopp committed Jan 30, 2021
1 parent 5796779 commit 05ab4e7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions examples/text-marker/text-marker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import (
// TextMarker
type TextMarker struct {
sm.MapObject
Position s2.LatLng
Text string
TextWidth float64
Position s2.LatLng
Text string
TextWidth float64
TextHeight float64
TipSize float64
TipSize float64
}

// NewTextMarker creates a new TextMarker
Expand All @@ -39,9 +39,9 @@ func NewTextMarker(pos s2.LatLng, text string) *TextMarker {
}

func (s *TextMarker) ExtraMarginPixels() (float64, float64, float64, float64) {
w := math.Max(4.0 + s.TextWidth, 2*s.TipSize)
w := math.Max(4.0+s.TextWidth, 2*s.TipSize)
h := s.TipSize + s.TextHeight + 4.0
return w*0.5, h, w*0.5, 0.0
return w * 0.5, h, w * 0.5, 0.0
}

func (s *TextMarker) Bounds() s2.Rect {
Expand All @@ -55,7 +55,7 @@ func (s *TextMarker) Draw(gc *gg.Context, trans *sm.Transformer) {
return
}

w := math.Max(4.0 + s.TextWidth, 2*s.TipSize)
w := math.Max(4.0+s.TextWidth, 2*s.TipSize)
h := s.TextHeight + 4.0
x, y := trans.LatLngToXY(s.Position)
gc.ClearPath()
Expand All @@ -76,13 +76,13 @@ func (s *TextMarker) Draw(gc *gg.Context, trans *sm.Transformer) {
gc.Stroke()

gc.SetRGBA(0.0, 0.0, 0.0, 1.0)
gc.DrawString(s.Text, x - s.TextWidth*0.5, y - s.TipSize - 4.0)
gc.DrawString(s.Text, x-s.TextWidth*0.5, y-s.TipSize-4.0)
}

func main() {
ctx := sm.NewContext()
ctx.SetSize(400, 300)

berlin := NewTextMarker(s2.LatLngFromDegrees(52.517037, 13.388860), "Berlin")
london := NewTextMarker(s2.LatLngFromDegrees(51.507322, 0.127647), "London")
paris := NewTextMarker(s2.LatLngFromDegrees(48.856697, 2.351462), "Paris")
Expand Down

0 comments on commit 05ab4e7

Please sign in to comment.