From 7d5b74e554de3328fcd16b2c21fd49dbf2ccba9a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 17 Apr 2016 11:11:09 +1200 Subject: Update custom openlayers arrow style --- web/arrowstyle.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'web/arrowstyle.js') diff --git a/web/arrowstyle.js b/web/arrowstyle.js index ad0ba08ee..a39e04cdf 100644 --- a/web/arrowstyle.js +++ b/web/arrowstyle.js @@ -3,6 +3,7 @@ goog.provide('ol.style.Arrow'); goog.require('goog.asserts'); goog.require('ol'); goog.require('ol.color'); +goog.require('ol.dom'); goog.require('ol.has'); goog.require('ol.render.canvas'); goog.require('ol.style.AtlasManager'); @@ -336,18 +337,13 @@ ol.style.Arrow.prototype.render_ = function(atlasManager) { if (atlasManager === undefined) { // no atlas manager is used, create a new canvas - this.canvas_ = /** @type {HTMLCanvasElement} */ - (document.createElement('CANVAS')); - - this.canvas_.height = size; - this.canvas_.width = size; + var context = ol.dom.createCanvasContext2D(size, size); + this.canvas_ = context.canvas; // canvas.width and height are rounded to the closest integer size = this.canvas_.width; imageSize = size; - var context = /** @type {CanvasRenderingContext2D} */ - (this.canvas_.getContext('2d')); this.draw_(renderOptions, context, 0, 0); this.createHitDetectionCanvas_(renderOptions); @@ -453,15 +449,9 @@ ol.style.Arrow.prototype.createHitDetectionCanvas_ = function(renderOptions) { // if no fill style is set, create an extra hit-detection image with a // default fill style - this.hitDetectionCanvas_ = /** @type {HTMLCanvasElement} */ - (document.createElement('CANVAS')); - var canvas = this.hitDetectionCanvas_; - - canvas.height = renderOptions.size; - canvas.width = renderOptions.size; + var context = ol.dom.createCanvasContext2D(renderOptions.size, renderOptions.size); + this.hitDetectionCanvas_ = context.canvas; - var context = /** @type {CanvasRenderingContext2D} */ - (canvas.getContext('2d')); this.drawHitDetectionCanvas_(renderOptions, context, 0, 0); }; -- cgit v1.2.3