简体   繁体   中英

How do I use stamen maps with the static google maps api?

I'd like to be able to use the stamen maps watercolor layer in conjunction with the static maps api from Google.

I'm hoping this is simple but I'm not sure how to implement it...

A static maps URL looks something like this:

https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&sensor=false

And the Stamen maps information is here:

http://maps.stamen.com/#watercolor

Thanks a lot for your help!

If you go to this page you'll see that you can center on an area, select the map style and the image size, and then press the "MAKE" button. This will generate a static image which you can then reference.

Stamen doesn't offer a static maps URL you can use to generate maps from a lat/lng pair, like Google does. If this is for a one-off map, you'll be fine. Otherwise, it doesn't seem like you'd be able to easily (see below) dynamically generate static map images.

PS If you're really really interested, you could take a look at the page's JavaScript source and see that by calling generateExportURL() , you'd get the URL to start a server-side rendering of a static watercolor map. You'd then need to poll that same URL (using (for instance) a server-side proxy, as cross-domain restrictions won't allow you to poll this page from your JavaScript source) to check when the map's "status" changes from "not_started" to "finished"... :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM