|
67 | 67 | _handlers = [], // event handlers
|
68 | 68 | _windows = [], // InfoWindow objects
|
69 | 69 | o = angular.extend({}, _defaults, opts),
|
70 |
| - that = this; |
| 70 | + that = this, |
| 71 | + currentInfoWindow = null; |
71 | 72 |
|
72 | 73 | this.center = opts.center;
|
73 | 74 | this.zoom = o.zoom;
|
|
178 | 179 | });
|
179 | 180 | };
|
180 | 181 |
|
181 |
| - this.addMarker = function (lat, lng, label, url, |
| 182 | + this.addMarker = function (lat, lng, icon, infoWindowContent, label, url, |
182 | 183 | thumbnail) {
|
183 | 184 |
|
184 | 185 | if (that.findMarker(lat, lng) != null) {
|
|
187 | 188 |
|
188 | 189 | var marker = new google.maps.Marker({
|
189 | 190 | position: new google.maps.LatLng(lat, lng),
|
190 |
| - map: _instance |
| 191 | + map: _instance, |
| 192 | + icon: icon |
191 | 193 | });
|
192 | 194 |
|
193 | 195 | if (label) {
|
|
197 | 199 | if (url) {
|
198 | 200 |
|
199 | 201 | }
|
| 202 | + |
| 203 | + if (infoWindowContent != null) { |
| 204 | + var infoWindow = new google.maps.InfoWindow({ |
| 205 | + content: infoWindowContent |
| 206 | + }); |
| 207 | + |
| 208 | + google.maps.event.addListener(marker, 'click', function() { |
| 209 | + if (currentInfoWindow != null) { |
| 210 | + currentInfoWindow.close(); |
| 211 | + } |
| 212 | + infoWindow.open(_instance, marker); |
| 213 | + currentInfoWindow = infoWindow; |
| 214 | + }); |
| 215 | + } |
200 | 216 |
|
201 | 217 | // Cache marker
|
202 | 218 | _markers.unshift(marker);
|
|
206 | 222 | "lat": lat,
|
207 | 223 | "lng": lng,
|
208 | 224 | "draggable": false,
|
| 225 | + "icon": icon, |
| 226 | + "infoWindowContent": infoWindowContent, |
209 | 227 | "label": label,
|
210 | 228 | "url": url,
|
211 | 229 | "thumbnail": thumbnail
|
|
438 | 456 |
|
439 | 457 | angular.forEach(newValue, function (v, i) {
|
440 | 458 | if (!_m.hasMarker(v.latitude, v.longitude)) {
|
441 |
| - _m.addMarker(v.latitude, v.longitude); |
| 459 | + _m.addMarker(v.latitude, v.longitude, v.icon, v.infoWindow); |
442 | 460 | }
|
443 | 461 | });
|
444 | 462 |
|
|
0 commit comments