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

Commit 23c3d30

Browse files
committed
fixing issue 113 , adding a timeout to delay creation so that the map may exist.
1 parent d61c9ff commit 23c3d30

File tree

6 files changed

+46
-33
lines changed

6 files changed

+46
-33
lines changed

dist/angular-google-maps.js

+20-19
Original file line numberDiff line numberDiff line change
@@ -1001,22 +1001,25 @@
10011001
this.onDestroy = __bind(this.onDestroy, this);
10021002
this.onWatch = __bind(this.onWatch, this);
10031003
this.validateScope = __bind(this.validateScope, this);
1004-
var opts, self,
1004+
var self,
10051005
_this = this;
10061006
MarkerParentModel.__super__.constructor.call(this, scope, element, attrs, mapCtrl, $timeout);
10071007
self = this;
1008-
opts = this.createMarkerOptions(scope.coords, scope.icon, scope.options, mapCtrl.getMap());
1009-
this.gMarker = new google.maps.Marker(opts);
1010-
element.data('instance', this.gMarker);
1011-
this.scope = scope;
1012-
google.maps.event.addListener(this.gMarker, 'click', function() {
1013-
if (_this.doClick && (scope.click != null)) {
1014-
return $timeout(function() {
1015-
return _this.scope.click();
1016-
});
1017-
}
1008+
$timeout(function() {
1009+
var opts;
1010+
opts = _this.createMarkerOptions(scope.coords, scope.icon, scope.options, mapCtrl.getMap());
1011+
_this.gMarker = new google.maps.Marker(opts);
1012+
element.data('instance', _this.gMarker);
1013+
_this.scope = scope;
1014+
google.maps.event.addListener(_this.gMarker, 'click', function() {
1015+
if (_this.doClick && (scope.click != null)) {
1016+
return $timeout(function() {
1017+
return _this.scope.click();
1018+
});
1019+
}
1020+
});
1021+
return _this.$log.info(_this);
10181022
});
1019-
this.$log.info(this);
10201023
}
10211024

10221025
MarkerParentModel.prototype.validateScope = function(scope) {
@@ -1507,13 +1510,11 @@
15071510
};
15081511
}
15091512

1510-
IMarker.prototype.controller = {
1511-
controller: [
1512-
'$scope', '$element', function($scope, $element) {
1513-
throw new Exception("Not Implemented!!");
1514-
}
1515-
]
1516-
};
1513+
IMarker.prototype.controller = [
1514+
'$scope', '$element', function($scope, $element) {
1515+
throw new Exception("Not Implemented!!");
1516+
}
1517+
];
15171518

15181519
IMarker.prototype.link = function(scope, element, attrs, ctrl) {
15191520
throw new Exception("Not implemented!!");

dist/angular-google-maps.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example-controller.js

+8
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,17 @@ function ExampleController ($scope, $timeout, $log) {
230230
genRandomMarkers(numberOfMarkers,$scope);
231231
}
232232

233+
$scope.searchLocation = {
234+
latitude: 30.1451,
235+
longitude: -99.6680
236+
};
233237
$scope.onMarkerClicked = onMarkerClicked
234238

235239
$timeout(function () {
240+
// $scope.searchLocation = {
241+
// latitude: 30.0,
242+
// longitude: -100
243+
// };
236244
$scope.map.infoWindow.show = true;
237245
dynamicMarkers = [
238246
{

example/example.html

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ <h1>angular-google-maps example</h1>
7979

8080
<trafficlayer show="map.showTraffic" />
8181

82+
<marker coords="searchLocation">
83+
</marker>
8284
<markers models="map.randomMarkers" coords="'self'" icon="'icon'" click="'onClicked'" doCluster="true">
8385
</markers>
8486

src/coffee/directives/api/i-marker.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
click: '&click',
2424
options: '=options'
2525
}
26-
controller: controller: ['$scope','$element', ($scope, $element) ->
26+
controller: ['$scope','$element', ($scope, $element) ->
2727
throw new Exception("Not Implemented!!")
2828
]
2929
link: (scope, element, attrs, ctrl) =>

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

+13-11
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88
constructor: (scope, element, attrs, mapCtrl,$timeout) ->
99
super(scope, element, attrs, mapCtrl,$timeout)
1010
self = @
11-
opts = @createMarkerOptions(scope.coords,scope.icon,scope.options,mapCtrl.getMap())
12-
#using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the index)
13-
@gMarker = new google.maps.Marker(opts)
14-
element.data('instance', @gMarker)
15-
@scope = scope
16-
google.maps.event.addListener(@gMarker, 'click', =>
17-
if @doClick and scope.click?
18-
$timeout( =>
19-
@scope.click()
20-
)
11+
$timeout( =>
12+
opts = @createMarkerOptions(scope.coords,scope.icon,scope.options,mapCtrl.getMap())
13+
#using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the index)
14+
@gMarker = new google.maps.Marker(opts)
15+
element.data('instance', @gMarker)
16+
@scope = scope
17+
google.maps.event.addListener(@gMarker, 'click', =>
18+
if @doClick and scope.click?
19+
$timeout( =>
20+
@scope.click()
21+
)
22+
)
23+
@$log.info(@)
2124
)
22-
@$log.info(@)
2325

2426
validateScope:(scope)=>
2527
super(scope) or angular.isUndefined(scope.coords.latitude) or angular.isUndefined(scope.coords.longitude)

0 commit comments

Comments
 (0)