File tree Expand file tree Collapse file tree 6 files changed +27
-15
lines changed Expand file tree Collapse file tree 6 files changed +27
-15
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " ngmap" ,
3- "version" : " 1.16.1 " ,
3+ "version" : " 1.16.2 " ,
44 "main" : " ./build/scripts/ng-map.js" ,
55 "homepage" : " https://github.com/allenhwkim/angularjs-google-maps" ,
66 "authors" : [
Original file line number Diff line number Diff line change @@ -233,16 +233,20 @@ <h1 class="title">
233233 position && (this.position = position); /* jshint ignore:line */
234234 if (this.getProjection() && typeof this.position.lng == 'function') {
235235 var posPixel = this.getProjection().fromLatLngToDivPixel(this.position);
236- //delayed left/top calculation. with/height are not set instantly
237236 var _this = this;
238- var delay = _this.el.offsetWidth ? 0 : 300;
239- $timeout(function() {
237+ var setPosition = function() {
240238 var x = Math.round(posPixel.x - (_this.el.offsetWidth/2));
241239 var y = Math.round(posPixel.y - _this.el.offsetHeight - 10); // 10px for anchor
242240 _this.el.style.left = x + "px";
243241 _this.el.style.top = y + "px";
244242 _this.el.style.visibility = "visible";
245- }, delay);
243+ };
244+ if (_this.el.offsetWidth && _this.el.offsetHeight) {
245+ setPosition();
246+ } else {
247+ //delayed left/top calculation when width/height are not set instantly
248+ $timeout(setPosition, 300);
249+ }
246250 }
247251 };
248252 CustomMarker.prototype.setZIndex = function(zIndex) {
Original file line number Diff line number Diff line change @@ -459,16 +459,20 @@ angular.module('ngMap').config([
459459
460460 if ( this . getProjection ( ) && typeof this . position . lng == 'function' ) {
461461 var posPixel = this . getProjection ( ) . fromLatLngToDivPixel ( this . position ) ;
462- //delayed left/top calculation. with/height are not set instantly
463462 var _this = this ;
464- var delay = _this . el . offsetWidth ? 0 : 300 ;
465- $timeout ( function ( ) {
463+ var setPosition = function ( ) {
466464 var x = Math . round ( posPixel . x - ( _this . el . offsetWidth / 2 ) ) ;
467465 var y = Math . round ( posPixel . y - _this . el . offsetHeight - 10 ) ; // 10px for anchor
468466 _this . el . style . left = x + "px" ;
469467 _this . el . style . top = y + "px" ;
470468 _this . el . style . visibility = "visible" ;
471- } , delay ) ;
469+ } ;
470+ if ( _this . el . offsetWidth && _this . el . offsetHeight ) {
471+ setPosition ( ) ;
472+ } else {
473+ //delayed left/top calculation when width/height are not set instantly
474+ $timeout ( setPosition , 300 ) ;
475+ }
472476 }
473477 } ;
474478
Original file line number Diff line number Diff line change @@ -459,16 +459,20 @@ angular.module('ngMap').config([
459459
460460 if ( this . getProjection ( ) && typeof this . position . lng == 'function' ) {
461461 var posPixel = this . getProjection ( ) . fromLatLngToDivPixel ( this . position ) ;
462- //delayed left/top calculation. with/height are not set instantly
463462 var _this = this ;
464- var delay = _this . el . offsetWidth ? 0 : 300 ;
465- $timeout ( function ( ) {
463+ var setPosition = function ( ) {
466464 var x = Math . round ( posPixel . x - ( _this . el . offsetWidth / 2 ) ) ;
467465 var y = Math . round ( posPixel . y - _this . el . offsetHeight - 10 ) ; // 10px for anchor
468466 _this . el . style . left = x + "px" ;
469467 _this . el . style . top = y + "px" ;
470468 _this . el . style . visibility = "visible" ;
471- } , delay ) ;
469+ } ;
470+ if ( _this . el . offsetWidth && _this . el . offsetHeight ) {
471+ setPosition ( ) ;
472+ } else {
473+ //delayed left/top calculation when width/height are not set instantly
474+ $timeout ( setPosition , 300 ) ;
475+ }
472476 }
473477 } ;
474478
Original file line number Diff line number Diff line change 11{
22 "name" : " ngmap" ,
3- "version" : " 1.16.1 " ,
3+ "version" : " 1.16.2 " ,
44 "main" : " build/scripts/ng-map.js" ,
55 "dependencies" : {},
66 "engines" : {
You can’t perform that action at this time.
0 commit comments