oxjs/demos/map/js/map.js

130 lines
4.7 KiB
JavaScript
Raw Normal View History

2011-05-21 07:08:52 +00:00
Ox.load('UI', {debug: true}, function() {
2011-03-04 16:25:29 +00:00
2011-05-23 19:38:52 +00:00
Ox.load('Geo', function() {
2011-03-05 08:53:34 +00:00
var width = window.innerWidth - 256,
height = window.innerHeight,
map = new Ox.Map({
clickable: true,
editable: true,
height: height,
2011-05-23 19:38:52 +00:00
places: Ox.COUNTRIES.map(function(place) {
2011-03-05 08:53:34 +00:00
return Ox.extend({
2011-03-05 15:34:16 +00:00
countryCode: place.code,
2011-03-05 08:53:34 +00:00
editable: true,
2011-03-05 15:34:16 +00:00
flag: place.code,
2011-03-05 08:53:34 +00:00
geoname: place.name,
name: place.name,
2011-03-05 15:34:16 +00:00
size: place.size,
type: 'Country',
lat: place.lat,
lng: place.lng,
2011-03-05 08:53:34 +00:00
south: place.south,
west: place.west,
north: place.north,
east: place.east
});
}),
/*
[
{
editable: true,
flag: 'UK',
geoname: 'Westminster, London, UK',
name: 'London',
//lat: 51.5001524,
lat: 51.52670875,
lng: -0.1262362,
south: 51.3493528,
west: -0.378358,
north: 51.7040647,
east: 0.1502295
},
{
editable: false,
flag: 'FR',
geoname: 'Paris, France',
name: 'Paris',
lat: 48.8566667,
lng: 2.3509871,
south: 48.8155414,
west: 2.2241006,
north: 48.9021461,
east: 2.4699099,
2011-03-04 16:25:29 +00:00
}
2011-03-05 08:53:34 +00:00
],
*/
2011-05-23 19:38:52 +00:00
showLabels: true,
2011-03-05 08:53:34 +00:00
statusbar: true,
toolbar: true,
width: width,
zoombar: true
})
.bindEvent({
2011-03-05 17:46:35 +00:00
resize: function(event, data) {
map.resizeMap();
},
2011-03-05 08:53:34 +00:00
selectplace: function(event, data) {
Ox.print('DATA', data)
panel.replaceElement(1, list = new Ox.TreeList({
data: Ox.isEmpty(data) ? [] : {
2011-05-29 09:52:33 +00:00
area: data.area,
2011-03-05 08:53:34 +00:00
components: data.components,
countryCode: data.countryCode,
crossesDateline: data.crossesDateline(),
east: data.east,
fullGeoname: data.fullGeoname,
geoname: data.geoname,
lat: data.lat,
lng: data.lng,
name: data.name,
north: data.north,
sizeEastWest: data.sizeEastWest,
sizeNorthSouth: data.sizeNorthSouth,
south: data.south,
west: data.west,
2011-03-05 15:34:16 +00:00
type: data.type
2011-03-05 08:53:34 +00:00
}
}));
2011-03-04 16:25:29 +00:00
}
2011-03-05 17:46:35 +00:00
});
2011-03-05 08:53:34 +00:00
list = new Ox.TreeList({
data: [],
width: 256
})
panel = new Ox.SplitPanel({
elements: [
{
element: map
},
{
element: list,
2011-03-05 17:46:35 +00:00
resizable: true,
resize: [128, 256, 384],
2011-03-05 08:53:34 +00:00
size: 256
}
],
orientation: 'horizontal'
})
.appendTo($('body'));
2011-03-04 16:25:29 +00:00
2011-03-05 17:46:35 +00:00
//setTimeout(function() {
//map.appendTo($('body'));
map.gainFocus();
//}, 2000)
/*
2011-03-05 08:53:34 +00:00
$(window).resize(function() {
map.options({
height: window.innerHeight,
width: window.innerWidth - 256
});
2011-03-04 16:25:29 +00:00
});
2011-03-05 17:46:35 +00:00
*/
2011-03-05 08:53:34 +00:00
2011-03-04 16:25:29 +00:00
});
});