Ext.setup({
tabletStartupScreen: "tablet_startup.png",
phoneStartupScreen:"phone_startup.png",
icon:"icon.png",
glossOnIcon:false,
onReady:function(){
// timeline component작성
var timeline =new Ext.Component({
title:"Timeline",
cls:"timeline",
scroll:"vertical",
tpl:[
'<tpl for=".">',
'<div class="tweet">',
'<div class="avatar"><img src="{profile_image_url}" /></div>',
'<div class="tweet-content">',
'<h2>{form_user}</h2>',
'<p>{text}</p>',
'</div>',
'</div>',
'</tpl>'
]
});
// timeline 생성 끝;
console.info( 'timeline', timeline );
// map생성
var map = new Ext.Map({
title: "Map",
useCurrentLocation:true,
mapOptions:{zoom:12}
});
// tabpanel생성
var panel =new Ext.TabPanel({
fullscreen:true,
cardSwitchAnimation:'slide',
items:[map, timeline]
});
// addMarker함수 선언
var addMarker =function( tweet, position ) {
var marker = new google.maps.Marker({map:map.map, position:position});
};
var refresh =function(){
var coords = map.geo.coords;
Ext.util.JSONP.request({
url:"http://search.twitter.com/search.json",
callbackKey:"callback",
params:{
geocode: coords.latitude + "," + coords.longitude +","+"5mi",
rpp:30
},
callback: function( data ){
data =data.results;
// update the tweets in timeline
timeline.update( data );
console.info( 'tweet*data', data );
// add points to the map
for( var i=0, ln=data.length; i<ln; i++ ) {
var tweet = data[i];
// tweet에 지오정보를 가지고 있다면
if( tweet.geo && tweet.geo.coordinates ){
var position = new google.maps.LatLng( tweet.geo.coordinates[0], tweet.geo.coordinates[1] );
//console.info( 'position', position );
addMarker( tweet, position );
}
}
}
});
// json request끝
}; // refresh끝
// map update와 refresh바인딩
map.geo.on( 'update', refresh );
var tabBar = panel.getTabBar();
tabBar.addDocked({
xtype:"button",
ui :"mask",
iconCls:"refresh",
dock:"right",
stretch:false,
align:"center",
handler:refresh
});
}
});