2011-07-29 18:48:43 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-05-16 08:24:46 +00:00
|
|
|
|
|
|
|
/*@
|
|
|
|
Ox.MapImage <f:Ox.Element> MapImage Object
|
|
|
|
() -> <f> MapImage Object
|
|
|
|
(options) -> <f> MapImage Object
|
|
|
|
(options, self) -> <f> MapImage Object
|
|
|
|
options <o> Options object
|
2011-05-16 10:49:48 +00:00
|
|
|
height <n|360> image height (px)
|
|
|
|
places <a|o|[]> array of either names (''), points ([0, 0]),
|
|
|
|
or objects ({name, point, highlight})
|
|
|
|
type <s|satellite> map type ('hybrid', 'roadmap', 'satellite', 'terrain')
|
|
|
|
width <n|640> image width (px)
|
|
|
|
self <o> shared private variable
|
2011-05-16 08:24:46 +00:00
|
|
|
@*/
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.MapImage = function(options, self) {
|
|
|
|
|
|
|
|
var self = self || {},
|
2011-06-19 17:48:32 +00:00
|
|
|
that = Ox.Element('<img>', self)
|
2011-04-22 22:03:10 +00:00
|
|
|
.defaults({
|
|
|
|
height: 360,
|
|
|
|
markerColorHighlight: 'yellow',
|
|
|
|
markerColorNormal: 'blue',
|
|
|
|
places: [],
|
|
|
|
type: 'satellite',
|
|
|
|
width: 640
|
|
|
|
})
|
|
|
|
.options(options || {})
|
|
|
|
|
2011-09-17 18:36:09 +00:00
|
|
|
Ox.extend(self, {
|
2011-04-22 22:03:10 +00:00
|
|
|
markers: {
|
|
|
|
highlight: [],
|
|
|
|
normal: []
|
|
|
|
},
|
|
|
|
src: 'http://maps.google.com/maps/api/staticmap?sensor=false' +
|
|
|
|
'&size=' + self.options.width + 'x' + self.options.height +
|
|
|
|
'&maptype=' + self.options.type
|
|
|
|
});
|
|
|
|
|
|
|
|
if (self.options.places.length) {
|
|
|
|
self.options.places.forEach(function(place) {
|
|
|
|
if (Ox.isString(place)) {
|
|
|
|
self.markers.normal.push(place);
|
|
|
|
} else if (Ox.isArray(place)) {
|
|
|
|
self.markers.normal.push(place.join(','));
|
|
|
|
} else {
|
|
|
|
self.markers[place.highlight ? 'highlight' : 'normal']
|
|
|
|
.push('point' in place ? place.point.join(',') : place.name)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Ox.forEach(self.markers, function(markers, k) {
|
|
|
|
if (markers.length) {
|
|
|
|
self.src += '&markers=icon:' + 'http://dev.pan.do:8000' +
|
2011-04-27 19:49:18 +00:00
|
|
|
Ox.UI.PATH + 'png/marker' +
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.toTitleCase(self.options['markerColor' + Ox.toTitleCase(k)]) +
|
|
|
|
'.png|' + markers.join('|')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
self.src += '¢er=0,0&zoom=2'
|
|
|
|
}
|
|
|
|
|
|
|
|
that.attr({
|
|
|
|
src: self.src
|
|
|
|
});
|
|
|
|
|
2011-04-29 12:40:51 +00:00
|
|
|
self.setOption = function(key, value) {
|
2011-04-22 22:03:10 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|