Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code example docs not working, 400 Bad Request OSM #90

Open
RemcoAn opened this issue Oct 28, 2024 · 1 comment
Open

code example docs not working, 400 Bad Request OSM #90

RemcoAn opened this issue Oct 28, 2024 · 1 comment

Comments

@RemcoAn
Copy link

RemcoAn commented Oct 28, 2024

The example provided at the documentation does not seem to work:

package main

import (
	"image/color"

	sm "github.com/flopp/go-staticmaps"
	"github.com/fogleman/gg"
	"github.com/golang/geo/s2"
)

func main() {
	ctx := sm.NewContext()
	ctx.SetSize(400, 300)
	ctx.AddObject(
		sm.NewMarker(
			s2.LatLngFromDegrees(52.514536, 13.350151),
			color.RGBA{0xff, 0, 0, 0xff},
			16.0,
		),
	)

	img, err := ctx.Render()
	if err != nil {
		panic(err)
	}

	if err := gg.SavePNG("my-map.png", img); err != nil {
		panic(err)
	}
}
2024/10/28 15:51:00 Error downloading tile file: GET https://c.tile.openstreetmap.org/30/576689288/352165953.png: 400 Bad Request
2024/10/28 15:51:00 Error downloading tile file: GET https://c.tile.openstreetmap.org/30/576689287/352165954.png: 400 Bad Request
2024/10/28 15:51:00 Error downloading tile file: GET https://a.tile.openstreetmap.org/30/576689289/352165953.png: 400 Bad Request
2024/10/28 15:51:00 Error downloading tile file: GET https://a.tile.openstreetmap.org/30/576689288/352165954.png: 400 Bad Request
2024/10/28 15:51:00 Error downloading tile file: GET https://b.tile.openstreetmap.org/30/576689289/352165954.png: 400 Bad Request
2024/10/28 15:51:00 Error downloading tile file: GET https://b.tile.openstreetmap.org/30/576689287/352165953.png: 400 Bad Request
@RemcoAn RemcoAn changed the title code example docs not working code example docs not working, 400 Bad Request OSM Oct 28, 2024
@RemcoAn
Copy link
Author

RemcoAn commented Oct 28, 2024

Fix:

package main

import (
	"image/color"

	sm "github.com/flopp/go-staticmaps"
	"github.com/fogleman/gg"
	"github.com/golang/geo/s2"
)

func main() {
	ctx := sm.NewContext()
	ctx.SetSize(600, 400)
	ctx.SetZoom(14)
	ctx.AddObject(
		sm.NewMarker(
			s2.LatLngFromDegrees(52.514536, 13.350151),
			color.RGBA{0xff, 0, 0, 0xff},
			16.0,
		),
	)

	img, err := ctx.Render()
	if err != nil {
		panic(err)
	}

	err = gg.SavePNG("my-map.png", img)
	if err != nil {
		panic(err)
	}
}

Difference:

	ctx.SetSize(600, 400)
	ctx.SetZoom(14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant