Skip to content

Commit 0118a33

Browse files
authored
Merge pull request #14 from xewl/master
Feat: add Map ID
2 parents eeb5d1f + 3c4a191 commit 0118a33

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ $url = $map->setCenter('Tehran')
7373
| setScale(scale) | Set map scale. |
7474
| setSize(width, height) | Set map size. |
7575
| setMapType(type as MapType) | Set map type. |
76+
| setMapId(id) | Set a map ID previously created in Cloud Console. |
7677
| setFormat(format as Format) | Set map format. |
7778
| addMarker(center, label, color, size) | Add marker to map. |
7879
| addMarkerLatLng(latitude, longitude, label, color, size) | Add marker to map with latitude and longitude. |

src/GoogleStaticMap.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class GoogleStaticMap
1111
private $scale = '1';
1212
private $size = '600x300';
1313
private $mapType = MapType::RoadMap;
14+
private $mapId = null;
1415
private $format = Format::JPG;
1516
private $markers = [];
1617

@@ -128,6 +129,20 @@ public function setMapType($mapType)
128129
return $this;
129130
}
130131

132+
/**
133+
* Set map ID.
134+
*
135+
* @param string $mapId
136+
*
137+
* @return $this
138+
*/
139+
public function setMapId($mapId)
140+
{
141+
$this->mapId = $mapId;
142+
143+
return $this;
144+
}
145+
131146
/**
132147
* Set map image format.
133148
*
@@ -256,6 +271,9 @@ public function make()
256271
}
257272
$url .= '&size='.$this->size;
258273
$url .= '&maptype='.$this->mapType;
274+
if (!is_null($this->mapId)) {
275+
$url .= '&map_id='.$this->mapId;
276+
}
259277
$url .= '&format='.$this->format;
260278
$url .= '&visual_refresh=true';
261279

0 commit comments

Comments
 (0)