Skip to content

Commit 54ab2a6

Browse files
author
Paul MacLean
committed
Custom Marker Directive
- Return from setPosition if the getProjection() returns null. -Solves issue where a marker clusterer removes markers from the map and getProjection().fromLatLnToPixel() throws a TypeError
1 parent dd72478 commit 54ab2a6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

directives/custom-marker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@
7171
if (this.getProjection() && typeof this.position.lng == 'function') {
7272
console.log(_this.getProjection());
7373
var setPosition = function() {
74+
if (!_this.getProjection()) { return; }
7475
var posPixel = _this.getProjection().fromLatLngToDivPixel(_this.position);
7576
var x = Math.round(posPixel.x - (_this.el.offsetWidth/2));
7677
var y = Math.round(posPixel.y - _this.el.offsetHeight - 10); // 10px for anchor
7778
_this.el.style.left = x + "px";
7879
_this.el.style.top = y + "px";
7980
_this.el.style.visibility = "visible";
8081
};
81-
if (_this.el.offsetWidth && _this.el.offsetHeight) {
82+
if (_this.el.offsetWidth && _this.el.offsetHeight) {
8283
setPosition();
8384
} else {
8485
//delayed left/top calculation when width/height are not set instantly

0 commit comments

Comments
 (0)