GooglemapMvc
GooglemapMvc copied to clipboard
Snapshot a map
I realize this question is not in-scope to your library.
What methods does a dev have to take a map with plotted points and save as an image?
I've tried creating a partial view and rendering out, but no answers to my question yet.
Actually this is a feature I have in my TODO list for a while now. That feature is called Static Maps. But is a completely different way to render the map.
I will try to prototype what I think should be the way to go inside my control, and maybe if you really need that feature you can take over and finish it. :P
:astonished:
I will dig into that API and see if I can prototype something up to contribute to GooglemapMvc.
Some help on this:
In order to implement Static Maps you have to implement a method that created a url that describes the snapshot.
- First you need a second key in order to use the api - this is a server key, not the client key the browser uses.
- The rest of the efford is to create a url like: 'https://maps.googleapis.com/maps/api/staticmap?center={0},{1}&zoom=19&size=600x480&maptype=hybrid&language=el&scale=1&markers=color:red%7C{0},{1}&key=XXX-XXXX'. 'Center' is a point, 'zoom' is a number (int), 'size' is the size of the image returned (it has size restrictions), maptype is a string that describes the google layer, scale is the map scale.
- Last is the markers array. When comes to 1 or 2 markers, there is no problem. When you need more markers or a path, you need to know that there is a limit of 2K for the url size. More information on https://developers.google.com/maps/documentation/static-maps/intro.
Thanks for the insights, surely this will be helpful.