Generate Static Map?

1,343 views
Skip to first unread message

Jake Wilson

unread,
May 25, 2014, 12:51:05 AM5/25/14
to leafl...@googlegroups.com
Google Maps has this sweet API, where you can generate a static map image, with markers and everything, from a URL:


Example:
&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318
&markers=color:red%7Clabel:C%7C40.718217,-73.998284&sensor=false

Does Leaflet have any way to accomplish such a thing?  I would feed it map tiles, bounds coordinates, render various polygons and markers and stuff on the map, and then have it spit out an image of everything all together.  Is this possible?

scott rivas

unread,
Jun 4, 2014, 4:01:44 PM6/4/14
to leafl...@googlegroups.com
I was wondering the exact same thing.

Olav Peeters

unread,
Jun 4, 2014, 5:41:46 PM6/4/14
to leafl...@googlegroups.com
You could disable all controls when you define the map, e.g.:

var your_map = L.map('your_map', {
    dragging: false,
    touchZoom: false,
    scrollWheelZoom: false,
    doubleClickZoom: false,
    boxZoom: false,
    tap: false,
    keyboard: false,
    zoomControl: false,
    attributionControl: false,
    prefix: false
}).fitBounds([[49.5, 3.5],[51.5, 5.5]]);


same effect...
Cheers,
Olav
--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pierre Huault

unread,
Jun 12, 2014, 11:35:21 AM6/12/14
to leafl...@googlegroups.com
Hi,

I have the exact same problem but your solution does not have the same effect. When you call staticmap service, it only returns an image. When you disable all controls, you still have to load the leaflet.js. 
In my case, I have to improve the page weight. Loading a .js with all the linked tiles, this will add ~200ko to the weight however only loading the image will add ~20ko.

I'm still interested if someone have found a solution :)

Thanks,
Message has been deleted

JaVaWa

unread,
Jun 16, 2014, 8:52:37 PM6/16/14
to leafl...@googlegroups.com

Leaflet is a dynamic, client-side mapping framework, so no: you can't create static maps with it...

You have to use a web service like that from Google, Bing, MapQuest or similar ones.

Actually my first answer isn't completely true: you could create your own web service using something like PhantomJS and Leaflet running on a web server. This requires quite some knowledge and a dedicated web server where you can install your own software.


Op donderdag 12 juni 2014 17:35:21 UTC+2 schreef Pierre Huault:
Reply all
Reply to author
Forward
0 new messages