2011-11-05 16:46:53 +00:00
|
|
|
'use strict';
|
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
/*@
|
2012-05-22 13:14:40 +00:00
|
|
|
Ox.MapMarkerImage <f> MapMarkerImage Object
|
2012-05-31 10:32:54 +00:00
|
|
|
(options) -> <o> google.maps.MarkerImage
|
2011-05-16 10:49:48 +00:00
|
|
|
options <o> Options object
|
|
|
|
color <a|[255, 0, 0]> marker color
|
|
|
|
mode <s|normal> can be: normal, selected, editing
|
|
|
|
size <n|16> size
|
|
|
|
type <s|place> can be: place, result, rectangle
|
|
|
|
@*/
|
|
|
|
|
2011-04-27 19:24:33 +00:00
|
|
|
Ox.MapMarkerImage = (function() {
|
|
|
|
|
|
|
|
var cache = {};
|
|
|
|
|
|
|
|
return function(options) {
|
|
|
|
|
|
|
|
options = Ox.extend({
|
|
|
|
color: [255, 0, 0],
|
|
|
|
mode: 'normal', // normal, selected, editing
|
2012-03-07 13:28:45 +00:00
|
|
|
rectangle: false,
|
2011-04-27 19:24:33 +00:00
|
|
|
size: 16,
|
2012-05-26 15:48:19 +00:00
|
|
|
type: 'place' // place, result
|
2011-04-27 19:24:33 +00:00
|
|
|
}, options);
|
|
|
|
|
|
|
|
var index = [
|
|
|
|
options.type, options.mode, options.size, options.color.join(',')
|
|
|
|
].join(';');
|
|
|
|
|
|
|
|
if (!cache[index]) {
|
2012-03-07 13:28:45 +00:00
|
|
|
var color = options.rectangle ? [0, 0, 0, 0]
|
2012-05-24 07:45:33 +00:00
|
|
|
: options.color.concat(
|
2012-01-17 17:56:26 +00:00
|
|
|
[options.type == 'place' ? 0.75 : 0.25]
|
|
|
|
),
|
2012-05-24 07:45:33 +00:00
|
|
|
border = (
|
|
|
|
options.mode == 'normal' ? [0, 0, 0]
|
|
|
|
: options.mode == 'selected' ? [255, 255, 255]
|
|
|
|
: [128, 128, 255]
|
|
|
|
).concat([options.type == 'result' ? 0.5 : 1]),
|
2011-04-27 19:24:33 +00:00
|
|
|
c = Ox.canvas(options.size, options.size),
|
|
|
|
image,
|
|
|
|
r = options.size / 2;
|
|
|
|
c.context.fillStyle = 'rgba(' + color.join(', ') + ')';
|
|
|
|
c.context.arc(r, r, r - 2, 0, 360);
|
|
|
|
c.context.fill();
|
|
|
|
c.context.beginPath();
|
|
|
|
c.context.lineWidth = 2;
|
2011-10-31 17:00:26 +00:00
|
|
|
c.context.strokeStyle = 'rgba(' + border.join(', ') + ')';
|
2011-04-27 19:24:33 +00:00
|
|
|
c.context.arc(r, r, r - 1, 0, 360);
|
|
|
|
c.context.stroke();
|
|
|
|
cache[index] = new google.maps.MarkerImage(
|
|
|
|
c.canvas.toDataURL(),
|
|
|
|
new google.maps.Size(options.size, options.size),
|
|
|
|
new google.maps.Point(0, 0),
|
|
|
|
new google.maps.Point(r, r)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cache[index];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
}());
|