How to takesnapshot of googlemap in flutter - google-maps

please i am new to flutter googlemaps., I would like to take a screenshot of googlemap showing directions between two markers, currently i used the screenshot plugin but this only captured a blank image. Please help a brother.

You can use the takeSnapshot method from the GoogleMapController class of the google_maps_flutter package. This method returns an image bytes of the map.
Here's the github link for the sample code.

I'll suggest to use "Map Static API" which gives you a jpg image (with markers and anything you want) passing the lat and long.
Link: https://developers.google.com/maps/documentation/maps-static/overview
Example:
https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap
&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
&key=YOUR_API_KEY
Result:

Related

Convert Google map with huge amount of data to a static using Google Static Maps

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

android googlemap export to share

I have an app with a google map fragment. I have added some markers and polygons, all within a 1km square.
Ultimately I would like to export the map to a pdf using code. Im guessing the first step would be to create a kml file with my objects.
Does anyone have any pointers?
Thanks
You can take bitmap of the map by calling map.snapshot(...)
https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.html#snapshot(com.google.android.gms.maps.GoogleMap.SnapshotReadyCallback)
After this you can make with bitmap what you want, export to pdf with some library and share, for example.

How to add custom marker image Google Static Map

How to add custom marker image Google Static Map?
I am using the following URL in order to get a static map
https://maps.googleapis.com/maps/api/staticmap?size=250x250&markers=color:red%7C$marker_start&markers=color:green%7C$marker_end&path=weight:3%7Ccolor:red%7Cenc:$encodedString
I am only able to change color and add a marker that already exists but not the image that created by me.
Yes, the documentation has a section explaining how to use your own images instead of their markers:
https://developers.google.com/maps/documentation/staticmaps/intro#CustomIcons
e.g.
https://maps.googleapis.com/maps/api/staticmap?markers=icon:http://www.example.com/yourimage.png
Here's an example using an encoded polyline too.
https://maps.googleapis.com/maps/api/staticmap?markers=icon:http://www.gravatar.com/avatar/e5594b71e9f54f3e73f6294b054f5616?s=32%26d=identicon%26r=PG|54.763228,-130.617302&size=400x400&path=weight:3%7Ccolor:orange%7Cenc:_fisIp~u%7CU}%7Ca#pytA_~b#hhCyhS~hResU%7C%7Cx#oig#rwg#amUfbjA}f[roaAynd#%7CvXxiAt{ZwdUfbjAewYrqGchH~vXkqnAria#c_o#inc#k{g#i%60]o%7CF}vXaj\h%60]ovs#?yi_#rcAgtO%7Cj_AyaJren#nzQrst#zuYh%60]v%7CGbldEuzd#%7C%7Cx#spD%7CtrAzwP%7Cd_#yiB~vXmlWhdPez\_{Km_%60#~re#ew^rcAeu_#zhyByjPrst#ttGren#aeNhoFemKrvdAuvVidPwbVr~j#or#f_z#ftHr{ZlwBrvdAmtHrmT{rOt{Zz}E%7Cc%7C#o%7CLpn~AgfRpxqBfoVz_iAocAhrVjr#rh~#jzKhjp#%60%60NrfQpcHrb^k%7CDh_z#nwB%7Ckb#a{R%7Cyh#uyZ%7CllByuZpzw#wbd#rh~#%7C%7CFhqs#teTztrAupHhyY}t]huf#e%7CFria#o}GfezAkdW%7C}[ocMt_Neq#ren#e~Ika#pgE%7Ci%7CAfiQ%7C%60l#uoJrvdAgq#fppAsjGhg%60#%7ChQpg{Ai_V%7C%7Cx#mkHhyYsdP%7CxeA~gF%7C}[mv%60#t_NitSfjp#c}Mhg%60#sbChyYq}e#rwg#atFff}#ghN~zKybk#fl}A}cPftcAite#tmT__Lha#u~DrfQi}MhkSqyWivIumCria#ciO_tHifm#fl}A{rc#fbjAqvg#rrqAcjCf%7Ci#mqJtb^s%7C#fbjA{wDfs%60BmvEfqs#umWt_Nwn^pen#qiBr%60xAcvMr{Zidg#dtjDkbM%7Cd_#
it is very common question and very simple soluion for that to Add only
&markers=icon:http://tinyurl.com/2ftvtt6|lat,lng
while hitting that Api.so simply
your APi must be see like this
http://maps.google.com/maps/api/staticmap?center=40.714728,-73.998672&markers=icon:http://tinyurl.com/2ftvtt6|40.714728,-73.998672&zoom=12&size=400x400&sensor=false
and for more info please visit http://phpidiots.in/android/google-static-map-api/
:) enjoy your code
I help solution here for the marker in google compose Android : enter link description here

Custom Marker Icon not showing Google Static Maps v2

I am using the Static Google Maps API v2 to download a static image of a map view with a singular marker just showing one image. However, the image added to the marker parameter of the url doesn't seem to be making any difference, and just a red marker is shown at the location.
Please can you tell me where I am going wrong?
http://maps.googleapis.com/maps/api/staticmap
?center=37.446754,-77.572746
&size=70x61
&maptype=roadmap
&sensor=true
&scale=2
&zoom=15
&key=some_key
&markers=icon:https://foursquare.com/img/categories_v2/shops/financial_bg_64.png|37.446754,-77.572746
your image URL must remove the letter S HTTPS secure site, so work, for example like this:
http://foursquare.com/img/categories_v2/shops/financial_bg_64.png
complete code:
http://maps.googleapis.com/maps/api/staticmap?
center=37.446754,-77.572746&size=70x61&maptype=roadmap&sensor=false
&scale=2&zoom=15
&markers=icon:http://foursquare.com/img/categories_v2/shops/financial_bg_64.png|37.446754,-77.572746
In my experience,
There is no such requirement of http or https just care for icon size .
icon size should not exceed more than 64X64 pixels in size , Static map will happily show the custom icon . accept if found correct #max_
http://maps.googleapis.com/maps/api/staticmap?
center=37.446754,-77.572746&size=70x61&maptype=roadmap&sensor=false
&scale=2&zoom=15
&markers=icon:http://foursquare.com/img/categories_v2/shops/financial_64X64.png|37.446754,-77.572746
off course use your image with below 64X64 dimension instead of
http://foursquare.com/img/categories_v2/shops/financial_64X64.png
You're actually not doing anything wrong, it's Google to blame:
"The Google Static Maps API does not support custom icon URLs that use HTTPS"

google maps: find out coordinates

i'm parsing some html data which has google maps embedded (displaying just one certain point) and i was wondering:
how can i find out the exact geographic coordinates of that point?
thx
I will look into this further but if you are able to see the Google Maps representation, you can type this into your browser and it will pinpoint the exact center location:
javascript:void(prompt('',gApplication.getMap().getCenter()));
Very useful if you want to get quick lat/long values. Is this the kind of info you need?
Parsing HTML files and want to find what point map is displaying?
This is likely not be possible (correct me if I am wrong). The map is a JavaScript object that only exists inside a browser - it is only text code in the html file. Map variables and data only exist inside the JavaScript engine running inside the browser, their dynamic variable state cannot be stored in a file ahead of time.
If the site is displaying a static map image then we have a different story. Just parse the URL to google static maps requesting the map image.
i found out that the actual coordinates were stored in the html :)
Have you tried the LatLng Marker lab in google map?