diff --git a/client-side/googleMapAPI.js b/client-side/googleMapAPI.js index 972a766..9131936 100644 --- a/client-side/googleMapAPI.js +++ b/client-side/googleMapAPI.js @@ -177,7 +177,8 @@ GoogleMap.prototype = { marker = new google.maps.Marker({ position: position, map: base.map, - title: (("title" in markers[i]) ? markers[i]['title'] : null) + title: (("title" in markers[i]) ? markers[i]['title'] : null), + customField: (("customField" in markers[i]) ? markers[i]['customField'] : null) }); marker.setAnimation(base.doAdmination(item)); diff --git a/composer.json b/composer.json index 5667933..398ad32 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "olicek/google-map-api", + "name": "argonisius/google-map-api", "type": "library", "description": "Tool for paste google map to the page with markers", "keywords": ["google","maps", "nette"], @@ -25,4 +25,4 @@ "Oli\\GoogleAPI\\": "src" } } -} \ No newline at end of file +} diff --git a/docs/en/markers.md b/docs/en/markers.md index cb1de66..463455c 100644 --- a/docs/en/markers.md +++ b/docs/en/markers.md @@ -73,6 +73,14 @@ Set [message](https://developers.google.com/maps/documentation/javascript/exampl > Message can contains HTML tags +### setCustomField() + +``` +$markers->setCustomField($customField); +``` + +Set array of custom properties, which are accessible via JavaScript on `google.maps.Marker` object. + ### isMarkerClusterer() ``` diff --git a/src/Markers.php b/src/Markers.php index aa3f0b8..a08b06e 100644 --- a/src/Markers.php +++ b/src/Markers.php @@ -134,6 +134,28 @@ public function setMessage($message, $autoOpen = false) return $this; } + /** + * @param array $customField + * @return $this + * @throws LogicException + * @throws InvalidArgumentException + */ + public function setCustomField($customField) + { + if (!count($this->markers)) + { + throw new LogicException("setCustomField must be called after addMarker()"); + } + if (!is_array($customField)) + { + throw new InvalidArgumentException("customField must be array, $customField (".gettype($customField).") was given"); + } + end($this->markers); // move the internal pointer to the end of the array + $key = key($this->markers); + $this->markers[$key]['customField'] = $customField; + return $this; + } + /** * @param bool $cluster