Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit e970c8d

Browse files
committed
getMap checks on markerchildmodel should only happen if it is expected to be drawn immediatley. Clustering the drawing is delayed. issue #772 #783
1 parent 24939b6 commit e970c8d

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

dist/angular-google-maps.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,8 @@ Nicholas McCready - https://twitter.com/nmccready
14091409
ClustererMarkerManager = (function(_super) {
14101410
__extends(ClustererMarkerManager, _super);
14111411

1412+
ClustererMarkerManager.type = 'ClustererMarkerManager';
1413+
14121414
function ClustererMarkerManager(gMap, opt_markers, opt_options, opt_events) {
14131415
var self;
14141416
this.opt_events = opt_events;
@@ -1423,6 +1425,7 @@ Nicholas McCready - https://twitter.com/nmccready
14231425
this.addMany = __bind(this.addMany, this);
14241426
this.add = __bind(this.add, this);
14251427
ClustererMarkerManager.__super__.constructor.call(this);
1428+
this.type = ClustererMarkerManager.type;
14261429
self = this;
14271430
this.opt_options = opt_options;
14281431
if ((opt_options != null) && opt_markers === void 0) {
@@ -1568,6 +1571,8 @@ Nicholas McCready - https://twitter.com/nmccready
15681571

15691572
MarkerManager.include(FitHelper);
15701573

1574+
MarkerManager.type = 'MarkerManager';
1575+
15711576
function MarkerManager(gMap, opt_markers, opt_options) {
15721577
this.getGMarkers = __bind(this.getGMarkers, this);
15731578
this.fit = __bind(this.fit, this);
@@ -1579,6 +1584,7 @@ Nicholas McCready - https://twitter.com/nmccready
15791584
this.addMany = __bind(this.addMany, this);
15801585
this.add = __bind(this.add, this);
15811586
MarkerManager.__super__.constructor.call(this);
1587+
this.type = MarkerManager.type;
15821588
this.gMap = gMap;
15831589
this.gMarkers = new PropMap();
15841590
this.$log = Logger;
@@ -2273,7 +2279,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
22732279
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
22742280

22752281
angular.module("google-maps.directives.api.models.child".ns()).factory("MarkerChildModel".ns(), [
2276-
"ModelKey".ns(), "GmapUtil".ns(), "Logger".ns(), "EventsHelper".ns(), "PropertyAction".ns(), "MarkerOptions".ns(), "IMarker".ns(), function(ModelKey, GmapUtil, $log, EventsHelper, PropertyAction, MarkerOptions, IMarker) {
2282+
"ModelKey".ns(), "GmapUtil".ns(), "Logger".ns(), "EventsHelper".ns(), "PropertyAction".ns(), "MarkerOptions".ns(), "IMarker".ns(), "MarkerManager".ns(), function(ModelKey, GmapUtil, $log, EventsHelper, PropertyAction, MarkerOptions, IMarker, MarkerManager) {
22772283
var MarkerChildModel, keys;
22782284
keys = ['coords', 'icon', 'options', 'fit'];
22792285
MarkerChildModel = (function(_super) {
@@ -2526,13 +2532,13 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
25262532
this.gMarker.key = this.id;
25272533
}
25282534
this.gMarkerManager.add(this.gMarker);
2529-
if (this.gMarker && this.gMarker.getMap()) {
2535+
if (this.gMarker && (this.gMarker.getMap() || this.gMarkerManager.type !== MarkerManager.type)) {
25302536
this.deferred.resolve(this.gMarker);
25312537
} else {
25322538
if (!this.gMarker) {
25332539
this.deferred.reject("gMarker is null");
25342540
}
2535-
if (!this.gMarker.getMap()) {
2541+
if (!(this.gMarker.getMap() && this.gMarkerManager.type === MarkerManager.type)) {
25362542
this.deferred.reject("gMarker has no map");
25372543
}
25382544
}

dist/angular-google-maps.min.js

-9
This file was deleted.

example/issue-772-info-window-show-state.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<ui-gmap-google-map center="map.center" zoom="map.zoom"
1616
draggable="true" options="options" bounds="map.bounds">
1717
<ui-gmap-markers models="randomMarkers" coords="'self'"
18-
icon="'icon'" fit='true' click="'onClick'" events="markersEvents">
18+
icon="'icon'" fit='true' click="'onClick'" events="markersEvents" doCluster='true'>
1919
<ui-gmap-windows show="'show'">
2020
<div ng-non-bindable>{{text}}</div>
2121
</ui-gmap-windows>

src/coffee/directives/api/managers/clusterer-marker-manager.coffee

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
angular.module("google-maps.directives.api.managers".ns())
22
.factory "ClustererMarkerManager".ns(), ["Logger".ns(), "FitHelper".ns(), "PropMap".ns(), ($log, FitHelper, PropMap) ->
33
class ClustererMarkerManager extends FitHelper
4+
@type = 'ClustererMarkerManager'
45
constructor: (gMap, opt_markers, opt_options, @opt_events) ->
56
super()
7+
@type = ClustererMarkerManager.type
68
self = @
79
@opt_options = opt_options
810
if opt_options? and opt_markers == undefined
@@ -84,4 +86,4 @@ angular.module("google-maps.directives.api.managers".ns())
8486
throw "GMarkers out of Sync in MarkerClusterer" if @getGMarkers().length != @propMapGMarkers.length
8587

8688
ClustererMarkerManager
87-
]
89+
]

src/coffee/directives/api/managers/marker-manager.coffee

+2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ angular.module("google-maps.directives.api.managers".ns())
22
.factory "MarkerManager".ns(), ["Logger".ns(), "FitHelper".ns(), "PropMap".ns(), (Logger, FitHelper, PropMap) ->
33
class MarkerManager extends FitHelper
44
@include FitHelper
5+
@type = 'MarkerManager'
56
constructor: (gMap, opt_markers, opt_options) ->
67
super()
8+
@type = MarkerManager.type
79
@gMap = gMap
810
@gMarkers = new PropMap()
911
@$log = Logger

src/coffee/directives/api/models/child/marker-child-model.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
angular.module("google-maps.directives.api.models.child".ns())
22
.factory "MarkerChildModel".ns(), [ "ModelKey".ns(), "GmapUtil".ns(),
33
"Logger".ns(), "EventsHelper".ns(),"PropertyAction".ns(),
4-
"MarkerOptions".ns(), "IMarker".ns(),
5-
(ModelKey, GmapUtil, $log, EventsHelper, PropertyAction, MarkerOptions, IMarker) ->
4+
"MarkerOptions".ns(), "IMarker".ns(), "MarkerManager".ns(),
5+
(ModelKey, GmapUtil, $log, EventsHelper, PropertyAction, MarkerOptions, IMarker, MarkerManager) ->
66
keys = ['coords', 'icon', 'options', 'fit']
77
class MarkerChildModel extends ModelKey
88
@include GmapUtil
@@ -149,11 +149,11 @@ angular.module("google-maps.directives.api.models.child".ns())
149149
@gMarker.key = @id if @id?
150150
@gMarkerManager.add @gMarker
151151

152-
if @gMarker and @gMarker.getMap()
152+
if @gMarker and (@gMarker.getMap() or @gMarkerManager.type != MarkerManager.type)
153153
@deferred.resolve @gMarker
154154
else
155155
@deferred.reject "gMarker is null" unless @gMarker
156-
@deferred.reject "gMarker has no map" unless @gMarker.getMap()
156+
@deferred.reject "gMarker has no map" unless @gMarker.getMap() and @gMarkerManager.type == MarkerManager.type
157157

158158
if @model[@fitKey]
159159
@gMarkerManager.fit()

0 commit comments

Comments
 (0)