go-staticmaps icon indicating copy to clipboard operation
go-staticmaps copied to clipboard

Using NewTileProviderThunderforestOutdoors() results in 'API Key Required' watermark

Open danesparza opened this issue 4 years ago • 1 comments

Using NewTileProviderThunderforestOutdoors() results in 'API Key Required' watermark on the generated image.

How do we set an API key when using this tool?

Here's what I'm trying to do:

	ctx := sm.NewContext()
	ctx.SetSize(600, 360)
	ctx.SetZoom(zoom)
	ctx.SetTileProvider(sm.NewTileProviderThunderforestOutdoors())
	ctx.AddObject(
		sm.NewMarker(
			s2.LatLngFromDegrees(lat, long),
			color.RGBA{0xff, 0, 0, 0xff},
			16.0,
		),
	)

	img, err := ctx.Render()

danesparza avatar Oct 07 '21 20:10 danesparza

  1. visit https://www.thunderforest.com/, then sign up and login (free for Hobby Project)
  2. from your dashboard(https://manage.thunderforest.com/dashboard), you will see the outdoors tile layer's URL which looks like https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=xxxx
  3. codes:
thunderforestOutdoors := &sm.TileProvider{
	Name: "thunderforest-outdoors",
	Attribution: "Maps (c) Thundeforest; Data (c) OSM and contributors, ODbL",
	TileSize: 256,
	URLPattern: "https://%[1]s.tile.thunderforest.com/outdoors/%[2]d/%[3]d/%[4]d.png?apikey=xxxx",
	Shards: []string{"a", "b", "c"},
}

ctx := sm.NewContext()
ctx.SetSize(600, 360)
ctx.SetZoom(zoom)
ctx.SetTileProvider(thunderforestOutdoors)
ctx.AddObject(
sm.NewMarker(
		s2.LatLngFromDegrees(lat, long),
		color.RGBA{0xff, 0, 0, 0xff},
		16.0,
	),
)

img, err := ctx.Render()

shanghuiyang avatar Oct 11 '21 16:10 shanghuiyang