allow for dynamically colored and sized map markers
This commit is contained in:
parent
5f95fd9da4
commit
74099f8642
1 changed files with 23 additions and 13 deletions
|
@ -15,10 +15,8 @@ Ox.MapMarker <f> MapMarker Object
|
|||
Ox.MapMarker = function(options) {
|
||||
|
||||
options = Ox.extend({
|
||||
color: [255, 0, 0],
|
||||
map: null,
|
||||
place: null,
|
||||
size: 16
|
||||
place: null
|
||||
}, options);
|
||||
|
||||
var that = this,
|
||||
|
@ -202,11 +200,18 @@ Ox.MapMarker = function(options) {
|
|||
function setOptions() {
|
||||
// workaround to prevent marker from appearing twice
|
||||
// after setting draggable from true to false (google maps bug)
|
||||
var fix = that.marker.getDraggable() && !that.place.editing;
|
||||
var fix = that.marker.getDraggable() && !that.place.editing,
|
||||
color = that.map.options('markerColor'),
|
||||
size = that.map.options('markerSize');
|
||||
//Ox.Log('Map', 'setOptions, that.map: ', that.map)
|
||||
if (that.map.options('showTypes')) {
|
||||
if (color == 'auto') {
|
||||
that.color = typeColor[that.place.type];
|
||||
} else if (Ox.isArray(color)) {
|
||||
that.color = color;
|
||||
} else {
|
||||
that.color = color(that.place);
|
||||
}
|
||||
if (size == 'auto') {
|
||||
that.size = 8;
|
||||
Ox.forEach(areaSize, function(size, area) {
|
||||
if (that.place.area >= area) {
|
||||
|
@ -215,6 +220,11 @@ Ox.MapMarker = function(options) {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
} else if (Ox.isNumber(size)) {
|
||||
that.size = size;
|
||||
} else {
|
||||
that.size = size(that.place);
|
||||
}
|
||||
that.marker.setOptions({
|
||||
// fixme: cursor remains pointer
|
||||
cursor: that.place.editing ? 'move' : 'pointer',
|
||||
|
|
Loading…
Reference in a new issue