GooglemapMvc icon indicating copy to clipboard operation
GooglemapMvc copied to clipboard

Snapshot a map

Open philoushka opened this issue 9 years ago • 4 comments

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.

philoushka avatar Aug 14 '15 01:08 philoushka

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

jmelosegui avatar Aug 15 '15 16:08 jmelosegui

:astonished:

I will dig into that API and see if I can prototype something up to contribute to GooglemapMvc.

philoushka avatar Aug 15 '15 16:08 philoushka

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.

gcapnias avatar May 09 '16 13:05 gcapnias

Thanks for the insights, surely this will be helpful.

jmelosegui avatar May 09 '16 17:05 jmelosegui