maplibre-gl-js-amplify
Version:
MapLibre Plugin to Support Amplify Geo Integration
33 lines (32 loc) • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createMarker = void 0;
const constants_1 = require("./constants");
function createMarker(options) {
const fillColor = (options === null || options === void 0 ? void 0 : options.fillColor) ? options.fillColor : constants_1.MARKER_COLOR;
const strokeColor = (options === null || options === void 0 ? void 0 : options.strokeColor) ? options.strokeColor : constants_1.COLOR_WHITE;
const lineWidth = (options === null || options === void 0 ? void 0 : options.lineWidth) ? options.lineWidth : 4;
return {
width: 64,
height: 64,
data: new Uint8Array(64 * 64 * 4),
onAdd: function () {
const canvas = document.createElement('canvas');
canvas.width = this.width;
canvas.height = this.height;
this.context = canvas.getContext('2d');
},
render: function () {
const context = this.context;
const markerShape = new Path2D(constants_1.LOCATION_MARKER);
context.stroke(markerShape);
context.fillStyle = fillColor;
context.strokeStyle = strokeColor;
context.lineWidth = lineWidth;
context.fill(markerShape);
this.data = context.getImageData(0, 0, this.width, this.height).data;
return true;
},
};
}
exports.createMarker = createMarker;