Reputation: 61
I'm trying to fix the static maps on my websites to show a marker for the address in the map.
I got the code from another website and make the address part dynamic using php, this is how my code looks now:
http://maps.googleapis.com/maps/api/staticmap?center=988%20N%20Hill%20St,%20Los%20Angeles,%20United%20States&maptype=roadmap&zoom=14&size=300x250&sensor=false&maptype=HYBRID&markers=color:blue|label:988%20N%20Hill%20St,%20Los%20Angeles,%20United%20States
I also tried to do it with an api key like this:
http://maps.googleapis.com/maps/api/staticmap?key=MYKEYHERE¢er=988%20N%20Hill%20St,%20Los%20Angeles,%20United%20States&maptype=roadmap&zoom=14&size=300x250&sensor=false&maptype=HYBRID&markers=color:blue|label:988%20N%20Hill%20St,%20Los%20Angeles,%20United%20States
But it didn't change anything, the map works but the marker doesn't show.
Anyone knows what I can do to solve this?
Thanks!
Upvotes: 0
Views: 825
Reputation: 1182
The label part of the marker is incomplete, you should either provide a valid label or remove this part from your URL. The working URLs should look like as below. I've broken the URLs into multiple lines for better readability. You can click on the labels to see working links.
http://maps.googleapis.com/maps/api/staticmap
?center=988%20N%20Hill%20St,%20Los%20Angeles,%20United%20States
&maptype=roadmap
&zoom=14
&size=300x250
&sensor=false
&maptype=HYBRID
&markers=color:blue
|988%20N%20Hill%20St,%20Los%20Angeles,%20United%20States
http://maps.googleapis.com/maps/api/staticmap
?center=988%20N%20Hill%20St,%20Los%20Angeles,%20United%20States
&maptype=roadmap
&zoom=14
&size=300x250
&sensor=false
&maptype=HYBRID
&markers=color:blue
|label:A
|988%20N%20Hill%20St,%20Los%20Angeles,%20United%20States
Reference: https://developers.google.com/maps/documentation/static-maps/intro#MarkerStyles
label:
(optional) specifies a single uppercase alphanumeric character from the set {A-Z, 0-9}. (The requirement for uppercase characters is new to this version of the API.) Note that default and mid sized markers are the only markers capable of displaying analphanumeric-character
parameter.tiny
andsmall
markers are not capable of displaying an alphanumeric-character.
Upvotes: 2