oxjs/demos/listmap/js/listmap.js
2011-11-24 19:38:10 +01:00

71 lines
No EOL
2.4 KiB
JavaScript

Ox.load({UI: {}, Geo: {}}, function() {
var markerColor = {
'Northern America': [64, 64, 255],
'Central America': [0, 0, 255],
'Caribbean': [0, 0, 128],
'Southern America': [0, 255, 0],
'Northern Europe': [255, 255, 192],
'Western Europe': [255, 255, 0],
'Eastern Europe': [255, 128, 0],
'Southern Europe': [128, 128, 0],
'Northern Africa': [128, 128, 128],
'Western Africa': [64, 64, 128],
'Middle Africa': [64, 64, 64],
'Eastern Africa': [128, 64, 64],
'Southern Africa': [64, 128, 64],
'Western Asia': [255, 128, 128],
'Central Asia': [255, 0, 0],
'Eastern Asia': [128, 0, 0],
'Southern Asia': [255, 0, 255],
'South-Eastern Asia': [128, 0, 128],
'Australia and New Zealand': [0, 128, 128],
'Micronesia': [192, 255, 255],
'Melanesia': [0, 255, 255],
'Polynesia': [128, 128, 255],
'Antarctica': [192, 192, 192]
},
$listmap = new Ox.ListMap({
height: window.innerHeight,
places: Ox.COUNTRIES.map(function(place) {
return {
alternativeNames: Ox.compact([place.google, place.imdb, place.wikipedia]),
area: place.area,
countryCode: place.code,
editable: true,
flag: place.code,
geoname: place.name,
id: place.code,
markerColor: markerColor[place.region] || [128,128,128],
name: place.name,
type: 'country',
lat: place.lat,
lng: place.lng,
south: place.south,
west: place.west,
north: place.north,
east: place.east
};
}),
width: window.innerWidth
})
.bindEvent({
geocode: function(event, data) {
Ox.print(event)
Ox.print(JSON.stringify(data))
}
})
.appendTo(Ox.UI.$body);
$(window).resize(function() {
Ox.print('RESIZE', window.innerHeight)
$listmap.options({
height: window.innerHeight,
width: window.innerWidth
});
});
window.$listmap = $listmap;
});