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) {
|
Ox.MapMarker = function(options) {
|
||||||
|
|
||||||
options = Ox.extend({
|
options = Ox.extend({
|
||||||
color: [255, 0, 0],
|
|
||||||
map: null,
|
map: null,
|
||||||
place: null,
|
place: null
|
||||||
size: 16
|
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
var that = this,
|
var that = this,
|
||||||
|
@ -202,19 +200,31 @@ Ox.MapMarker = function(options) {
|
||||||
function setOptions() {
|
function setOptions() {
|
||||||
// workaround to prevent marker from appearing twice
|
// workaround to prevent marker from appearing twice
|
||||||
// after setting draggable from true to false (google maps bug)
|
// 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)
|
//Ox.Log('Map', 'setOptions, that.map: ', that.map)
|
||||||
if (that.map.options('showTypes')) {
|
if (color == 'auto') {
|
||||||
that.color = typeColor[that.place.type];
|
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) {
|
||||||
|
that.size = size;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (Ox.isNumber(size)) {
|
||||||
|
that.size = size;
|
||||||
|
} else {
|
||||||
|
that.size = size(that.place);
|
||||||
}
|
}
|
||||||
that.size = 8;
|
|
||||||
Ox.forEach(areaSize, function(size, area) {
|
|
||||||
if (that.place.area >= area) {
|
|
||||||
that.size = size;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
that.marker.setOptions({
|
that.marker.setOptions({
|
||||||
// fixme: cursor remains pointer
|
// fixme: cursor remains pointer
|
||||||
cursor: that.place.editing ? 'move' : 'pointer',
|
cursor: that.place.editing ? 'move' : 'pointer',
|
||||||
|
|
Loading…
Reference in a new issue