Skip to content

Instantly share code, notes, and snippets.

@zpratt
Created March 29, 2015 06:07
Show Gist options
  • Save zpratt/87db98b7ebc36b31a2c2 to your computer and use it in GitHub Desktop.
Save zpratt/87db98b7ebc36b31a2c2 to your computer and use it in GitHub Desktop.
Custom Overlay - Define draw method
function positionOverlayByDimensions(projectedLatLng) {
var offsetHeight = this.el.offsetHeight,
offsetWidth = this.el.offsetWidth;
this.el.style.top = projectedLatLng.y - offsetHeight + 'px';
this.el.style.left = projectedLatLng.x - Math.floor(offsetWidth / 2) + 'px';
}
BaseOverlay.prototype.draw = function () {
var projection = this.getProjection(),
projectedLatLng = projection.fromLatLngToDivPixel(this.point);
positionOverlayByDimensions.call(this, projectedLatLng);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment