I am working on an application that is using the google maps javascript API and it seems like it would be good to be able to download screenshots of the currently rendered map in our application.
I can't seem to find any options in the api that describe how to do this.
Is there anyway to download an image of the currently rendered map? Currently we are using a HYBRID map type
This isn't an option in the Javascript API. However you might be able to achieve the same map using the Static maps API, which just generates a PNG image: https://developers.google.com/maps/documentation/staticmaps/
Related
I need to convert a map built with Google Maps to a static map.
The problem is that map has an amount of data (mainly circles), and its representation has to be doing a path description of its circunference, and I need some kind of accurate, a pure circle has to be displayed in the static mode, so each circle description is about 500 chars (encoded).
The Google Static Maps url limit is 8192 and its not enough for rendering those shapes.
There is another way for doing it? I also tried to use html2canvas, but it is forbidden by Google.
Google actually recently extended the URL limit to 8192, but if you need more than that you probably need to resort to taking a screenshot of a Google Maps JavaScript API map, as suggested by xomena.
A tool like PhantomJS [1] can help you write a script to automatically take a screenshot of a webpage (which you've drawn using the Google Maps JavaScript API).
[1] https://github.com/ariya/phantomjs/wiki/Screen-Capture
I have a small example that uses PhantomJS to take a screenshot of the page.
Here's the JavaScript Map with some information: http://jsbin.com/pevizusana/2/edit
Here's the PhantomJS code that will take a screenshot on this site: http://pastebin.com/gEXhG1dP
And here's the result: http://i.imgur.com/Mj951aP.jpg
I hope you find this information helpful.
I'm the author of osm-static-maps, It's an open source project that you can use as a cli or js library or self-hosted http server. It mimics google static maps and you can pass any amount of data to the map as a geojson.
See the project here for more instructions https://github.com/jperelli/osm-static-maps
i am an Brasilian Web Developer, and i am making an report of phone calls geolocation in an virtual PABX ( asterisk ), already working fine with google maps API V3.
OBJECTIVE Export this report into a PDF or Excel, so i am thinking in turn the map into a image, to export after:
What i already try:
Create a Static Map dont solve my problem because i have a marker for each calls, and i am clustering markers with MarkerClusterer
I converted my map in Canvas using html2canvas, after my html turned in canvas i used canvas2image to create an <img> element, for simple html this solution works perfect, but in case of google maps the result is that:
Unfortunately i cannot post images because i have no reputation, i always visit StackOverflow but its my first time making a question, but i can describe that the image generated from the canvas have just the gray google maps background and the number of markers of the markerclusterer.
You can see the image here to understand better:
I am thinking in something like take a screenshot of the page and crop to just pick map region, but any sugestions that can solve the problem or give me a way will be very welcome.
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.
P.S. 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"... :-)
I am trying to embed an existing, public Google Map into a website. Specifically this one:
http://goo.gl/maps/cHf2
Of course I could use the iframe embed to achieve this, but I would like a little more control over the map … I imagined being able to pull all the markers from the map and display them as an index next to the map. Kind of like Google already does, but embedded in my page with my own styles and images.
I have been digging through Google, Stack Overflow and the API instructions and couldn’t find any relevant posts. In the GET string of the map on Google we can see this chunk:
&msid=212828439842926497866.0004bfae4da003d8ffd1f&mid=1341413217
I thought in there might be a maps ID and I could use it to query the content of the map through the API? The intention is using Google Maps as a CMS for less technical minded people and not dealing with geo data in our own CMS.
Any help would be greatly appreciated. Maybe I am just missing the forest for the trees.
You can download the kml that specifies the markers in that page and display that on your API based map. This example defaults to displaying it using geoxml3, but you can hide that and display the KmlLayer version.
You should be able to just point KmlLayer to the link (I downloaded the kml and put it on my server so it would work with geoxml3).
Here is an example (taken directly from the documentation) that does that
here is the original
Usually u have to set up a little script + htmlpage on your server to run google maps,
but i was wondering - is it possible to use google maps directly?
i mean by just calling an url with parameters (gpoint coordinates, zoomfactor ..) and it loads the map fullscreen without having to use my own server?
Sounds like you might be after the static maps api. You can build a URL specifying the properties of the map like:
zoom
position
markers (including custom markers)
image size
etc
and you will get back a rendered image of the map. Something like:
Obviously this just gives you a fixed image of the map you are after. If you need a dynamic Google map, then you will need to use the Google Maps Javascript API.
Not hosted by Google. You might find some other website that uses the API to do the same thing.
Google Maps API