How to add a custom Google Static Map marker image

How to add my own marker image in Google Static Map?

I use the following URL 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 can only change the color and add a marker that already exists, but not the image I created.

+5
source share
2 answers

Yes, there is a section in the documentation explaining how to use custom images instead of their markers: https://developers.google.com/maps/documentation/staticmaps/intro#CustomIcons

eg.

 https://maps.googleapis.com/maps/api/staticmap?markers=icon:http://www.example.com/yourimage.png 

Here is also an example of using an encoded polyline.

 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_@ 

enter image description here

+6
source

this is a very common question and a very simple solution to add only

 &markers=icon:http://tinyurl.com/2ftvtt6|lat,lng 

clicking Api .so just your APi should look 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 information visit http://phpidiots.in/android/google-static-map-api/

:) enjoy your code

+1
source

All Articles