Skip to content

Commit 0c09678

Browse files
committed
Version 1.17.1
1 parent 1002cd3 commit 0c09678

File tree

13 files changed

+169
-75
lines changed

13 files changed

+169
-75
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngmap",
3-
"version": "1.17.0",
3+
"version": "1.17.1",
44
"main": "./build/scripts/ng-map.js",
55
"homepage": "https://github.com/allenhwkim/angularjs-google-maps",
66
"authors": [

build/docs/NgMap.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ <h1 class="title">
190190
<h3 class="subsection-title">Methods</h3>
191191
<dl>
192192
<dt>
193-
<a href="source/NgMap.html#line70" class="name-link">
193+
<a href="source/NgMap.html#line69" class="name-link">
194194
<h4 class="name">
195195
addMap
196196
<span class="signature">(mapController)</span>
@@ -235,7 +235,7 @@ <h5>Returns:</h5>
235235
</dd>
236236
</dl><dl>
237237
<dt>
238-
<a href="source/NgMap.html#line83" class="name-link">
238+
<a href="source/NgMap.html#line82" class="name-link">
239239
<h4 class="name">
240240
deleteMap
241241
<span class="signature">(mapController)</span>
@@ -265,7 +265,7 @@ <h5>Parameters:</h5>
265265
</dd>
266266
</dl><dl>
267267
<dt>
268-
<a href="source/NgMap.html#line114" class="name-link">
268+
<a href="source/NgMap.html#line113" class="name-link">
269269
<h4 class="name">
270270
getGeoLocation
271271
<span class="signature">(address, options)</span>
@@ -319,7 +319,7 @@ <h5>Returns:</h5>
319319
<a href="source/NgMap.html#line41" class="name-link">
320320
<h4 class="name">
321321
getMap
322-
<span class="signature">(options)</span>
322+
<span class="signature">(optional,)</span>
323323
</h4>
324324
</a>
325325
</dt>
@@ -334,11 +334,11 @@ <h5>Parameters:</h5>
334334
</thead>
335335
<tbody>
336336
<tr>
337-
<td class="name">options</td>
337+
<td class="name">optional,</td>
338338
<td class="type"><span class="param-type">
339-
Hash
339+
String
340340
</span></td>
341-
<td class="description last"><p>optional, e.g., {id: 'foo, timeout: 5000}</p></td>
341+
<td class="description last"><p>id e.g., 'foo'</p></td>
342342
</tr>
343343
</tbody>
344344
</table>
@@ -390,7 +390,7 @@ <h5>Parameters:</h5>
390390
</dd>
391391
</dl><dl>
392392
<dt>
393-
<a href="source/NgMap.html#line149" class="name-link">
393+
<a href="source/NgMap.html#line148" class="name-link">
394394
<h4 class="name">
395395
observeAndSet
396396
<span class="signature">(attrName, object)</span>
@@ -441,7 +441,7 @@ <h5>Returns:</h5>
441441
</dd>
442442
</dl><dl>
443443
<dt>
444-
<a href="source/NgMap.html#line203" class="name-link">
444+
<a href="source/NgMap.html#line202" class="name-link">
445445
<h4 class="name">
446446
setDefaultOptions
447447
<span class="signature">(options)</span>
@@ -481,7 +481,7 @@ <h5>Parameters:</h5>
481481
</dd>
482482
</dl><dl>
483483
<dt>
484-
<a href="source/NgMap.html#line178" class="name-link">
484+
<a href="source/NgMap.html#line177" class="name-link">
485485
<h4 class="name">
486486
setStyle
487487
<span class="signature">(map)</span>

build/docs/NgMapPool.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ <h3 class="subsection-title">Members</h3>
208208
<h3 class="subsection-title">Methods</h3>
209209
<dl>
210210
<dt>
211-
<a href="source/NgMapPool.html#line40" class="name-link">
211+
<a href="source/NgMapPool.html#line57" class="name-link">
212212
<h4 class="name">
213213
getMapInstance
214214
<span class="signature">(el)</span>
@@ -253,7 +253,7 @@ <h5>Returns:</h5>
253253
</dd>
254254
</dl><dl>
255255
<dt>
256-
<a href="source/NgMapPool.html#line71" class="name-link">
256+
<a href="source/NgMapPool.html#line88" class="name-link">
257257
<h4 class="name">
258258
resetMapInstances
259259
</h4>
@@ -266,7 +266,7 @@ <h4 class="name">
266266
</dd>
267267
</dl><dl>
268268
<dt>
269-
<a href="source/NgMapPool.html#line60" class="name-link">
269+
<a href="source/NgMapPool.html#line77" class="name-link">
270270
<h4 class="name">
271271
returnMapInstance
272272
<span class="signature">(an)</span>

build/docs/source/NgMap.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,13 @@ <h1 class="title">
210210
/**
211211
* @memberof NgMap
212212
* @function getMap
213-
* @param {Hash} options optional, e.g., {id: 'foo, timeout: 5000}
213+
* @param {String} optional, id e.g., 'foo'
214214
* @returns promise
215215
*/
216-
var getMap = function(options) {
217-
options = options || {};
216+
var getMap = function(id) {
217+
id = typeof id === 'object' ? id.id : id;
218218
var deferred = $q.defer();
219-
var id = options.id || 0;
220-
var timeout = options.timeout || 2000;
219+
var timeout = 2000;
221220
function waitForMap(timeElapsed){
222221
if(mapControllers[id]){
223222
deferred.resolve(mapControllers[id].map);

build/docs/source/NgMapPool.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,26 @@ <h1 class="title">
194194
mapInstances.push(map);
195195
return map;
196196
};
197-
var find = function(el) { //jshint ignore:line
197+
var findById = function(el, id) {
198198
var notInUseMap;
199199
for (var i=0; i&lt;mapInstances.length; i++) {
200200
var map = mapInstances[i];
201+
if (map.id == id && !map.inUse) {
202+
var mapDiv = map.getDiv();
203+
el.appendChild(mapDiv);
204+
notInUseMap = map;
205+
break;
206+
}
207+
}
208+
return notInUseMap;
209+
};
210+
var findUnused = function(el) { //jshint ignore:line
211+
var notInUseMap;
212+
for (var i=0; i&lt;mapInstances.length; i++) {
213+
var map = mapInstances[i];
214+
if (map.id) {
215+
continue;
216+
}
201217
if (!map.inUse) {
202218
var mapDiv = map.getDiv();
203219
el.appendChild(mapDiv);
@@ -214,7 +230,7 @@ <h1 class="title">
214230
* @return map instance for the given element
215231
*/
216232
var getMapInstance = function(el) {
217-
var map = find(el);
233+
var map = findById(el, el.id) || findUnused(el);
218234
if (!map) {
219235
map = add(el);
220236
} else {

build/docs/source/ngMap.ng-map.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ <h1 class="title">
230230
return {
231231
restrict: 'AE',
232232
controller: '__MapController',
233-
conrollerAs: 'ngmap'
233+
controllerAs: 'ngmap'
234234
};
235235
};
236236
angular.module('ngMap').directive('map', [mapDirective]);

build/docs/source/ngmap.custom-marker.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ <h1 class="title">
253253
zIndex && (this.zIndex = zIndex); /* jshint ignore:line */
254254
this.el.style.zIndex = this.zIndex;
255255
};
256+
CustomMarker.prototype.getVisible = function() {
257+
return this.visible;
258+
};
256259
CustomMarker.prototype.setVisible = function(visible) {
257260
this.el.style.display = visible ? 'inline-block' : 'none';
258261
this.visible = visible;
@@ -297,7 +300,7 @@ <h1 class="title">
297300
var customMarker = new CustomMarker(options);
298301
scope.$watch('[' + varsToWatch.join(',') + ']', function() {
299302
customMarker.setContent(orgHtml, scope);
300-
});
303+
}, true);
301304
customMarker.setContent(element[0].innerHTML, scope);
302305
var classNames = element[0].firstElementChild.className;
303306
customMarker.addClass('custom-marker');

build/scripts/ng-map.debug.js

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* AngularJS Google Maps Ver. 1.16.8
2+
* AngularJS Google Maps Ver. 1.17.0
33
*
44
* The MIT License (MIT)
55
*
@@ -128,6 +128,9 @@ angular.module('ngMap', []);
128128
for (var k2 in vm.map.customMarkers) {
129129
bounds.extend(vm.map.customMarkers[k2].getPosition());
130130
}
131+
if (vm.mapOptions.maximumZoom) {
132+
vm.enableMaximumZoomCheck = true; //enable zoom check after resizing for markers
133+
}
131134
vm.map.fitBounds(bounds);
132135
};
133136

@@ -236,6 +239,18 @@ angular.module('ngMap', []);
236239
$parse($attrs.mapInitialized)($scope, {map: vm.map});
237240
}
238241
});
242+
243+
//add maximum zoom listeners if zoom-to-include-markers and and maximum-zoom are valid attributes
244+
if (mapOptions.zoomToIncludeMarkers && mapOptions.maximumZoom) {
245+
google.maps.event.addListener(vm.map, 'zoom_changed', function() {
246+
if (vm.enableMaximumZoomCheck == true) {
247+
vm.enableMaximumZoomCheck = false;
248+
google.maps.event.addListenerOnce(vm.map, 'bounds_changed', function() {
249+
vm.map.setZoom(Math.min(mapOptions.maximumZoom, vm.map.getZoom()));
250+
});
251+
}
252+
});
253+
}
239254
};
240255

241256
$scope.google = google; //used by $scope.eval to avoid eval()
@@ -257,7 +272,14 @@ angular.module('ngMap', []);
257272
vm.eventListeners = {};
258273

259274
if (options.lazyInit) { // allows controlled initialization
260-
vm.map = {id: $attrs.id}; //set empty, not real, map
275+
// parse angular expression for dynamic ids
276+
if (!!$attrs.id && $attrs.id.startsWith('{{') && $attrs.id.endsWith('}}')) {
277+
var idExpression = $attrs.id.slice(2,-2);
278+
var mapId = $parse(idExpression)($scope);
279+
} else {
280+
var mapId = $attrs.id;
281+
}
282+
vm.map = {id: mapId}; //set empty, not real, map
261283
NgMap.addMap(vm);
262284
} else {
263285
vm.initializeMap();
@@ -563,7 +585,7 @@ angular.module('ngMap', []);
563585

564586
scope.$watch('[' + varsToWatch.join(',') + ']', function() {
565587
customMarker.setContent(orgHtml, scope);
566-
});
588+
}, true);
567589

568590
customMarker.setContent(element[0].innerHTML, scope);
569591
var classNames = element[0].firstElementChild.className;
@@ -1554,7 +1576,7 @@ angular.module('ngMap', []);
15541576
return {
15551577
restrict: 'AE',
15561578
controller: '__MapController',
1557-
conrollerAs: 'ngmap'
1579+
controllerAs: 'ngmap'
15581580
};
15591581
};
15601582

@@ -2807,10 +2829,27 @@ angular.module('ngMap', []);
28072829
return map;
28082830
};
28092831

2810-
var find = function(el) { //jshint ignore:line
2832+
var findById = function(el, id) {
2833+
var notInUseMap;
2834+
for (var i=0; i<mapInstances.length; i++) {
2835+
var map = mapInstances[i];
2836+
if (map.id == id && !map.inUse) {
2837+
var mapDiv = map.getDiv();
2838+
el.appendChild(mapDiv);
2839+
notInUseMap = map;
2840+
break;
2841+
}
2842+
}
2843+
return notInUseMap;
2844+
};
2845+
2846+
var findUnused = function(el) { //jshint ignore:line
28112847
var notInUseMap;
28122848
for (var i=0; i<mapInstances.length; i++) {
28132849
var map = mapInstances[i];
2850+
if (map.id) {
2851+
continue;
2852+
}
28142853
if (!map.inUse) {
28152854
var mapDiv = map.getDiv();
28162855
el.appendChild(mapDiv);
@@ -2828,7 +2867,7 @@ angular.module('ngMap', []);
28282867
* @return map instance for the given element
28292868
*/
28302869
var getMapInstance = function(el) {
2831-
var map = find(el);
2870+
var map = findById(el, el.id) || findUnused(el);
28322871
if (!map) {
28332872
map = add(el);
28342873
} else {
@@ -2923,15 +2962,14 @@ angular.module('ngMap', []);
29232962
/**
29242963
* @memberof NgMap
29252964
* @function getMap
2926-
* @param {Hash} options optional, e.g., {id: 'foo, timeout: 5000}
2965+
* @param {String} optional, id e.g., 'foo'
29272966
* @returns promise
29282967
*/
2929-
var getMap = function(options) {
2930-
options = options || {};
2931-
var deferred = $q.defer();
2968+
var getMap = function(id) {
2969+
id = typeof id === 'object' ? id.id : id;
29322970

2933-
var id = options.id || 0;
2934-
var timeout = options.timeout || 2000;
2971+
var deferred = $q.defer();
2972+
var timeout = 2000;
29352973

29362974
function waitForMap(timeElapsed){
29372975
if(mapControllers[id]){

0 commit comments

Comments
 (0)