Roy Savion
Roy Savion

Reputation: 61

Static Google Map Not Showing Marker

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&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

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

Answers (1)

Elin Y.
Elin Y.

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.

Without label:

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

With label:

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 an alphanumeric-character parameter. tiny and small markers are not capable of displaying an alphanumeric-character.

Upvotes: 2

Related Questions