<! Doctype HTML>
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta charset = "UTF-8"/>
<Title> </title>
<LINK rel = "stylesheet" href = "SDK-touch/resources/CSS/sencha-touch.css"/>
<LINK rel = "stylesheet" href = "Resources/CSS/app.css"/>
<! -- <SCRIPT src = "SDK-touch/sencha-touch.js"> </SCRIPT> -->
<SCRIPT src = "SDK-touch/sencha-touch-all.js"> </SCRIPT>
<! -- <SCRIPT src = "SDK-touch/sencha-touch-all-debug.js"> </SCRIPT> -->
<! -- <SCRIPT src = "SDK-touch/sencha-touch-debug.js"> </SCRIPT> -->
<SCRIPT src = "app. js"> </SCRIPT>
</Head>
<Body>
</Body>
</Html>
/**
* Created by-PC on 2014/8/12.
*/
Ext. Define ('myapp. Controller. calculate ',{
Torad: function (d ){
Return D * Math. PI/180;
},
Getdisance: function (LAT1, lng1, LAT2, lng2) {// # the LAT is the latitude, and the LNG is the longitude. Be sure not to make a mistake.
VaR Dis = 0;
VaR radlat1 = This. torad (LAT1 );
VaR radlat2 = This. torad (LAT2 );
VaR deltalat = radlat1-radlat2;
VaR deltalng = This. torad (lng1)-This. torad (lng2 );
VaR Dis = 2 * Math. asin (math. SQRT (math. pow (math. sin (deltalat/2), 2) + math. cos (radlat1) * Math. cos (radlat2) * Math. pow (math. sin (deltalng/2), 2 )));
Return Dis * 6378137;
}
});
/**
* Created by-PC on 2014/8/12.
*/
Ext. Define ('myapp. Controller. controller ',{
Extend: 'ext. App. controller ',
Launch: function (){
This. callparent (arguments );
Console. Log ('launch ');
// Geographical coordinates of Tiananmen District, Beijing
VaR pk_la = 39.90960456049752;
VaR pk_lo = 116.3972282409668;
/* Ext. util. geolocation. getcurrentposition (function (position ){
Console. Log (position. coords. Latitude );
Console. Log (position. coords. longpolling );
});*/
// Var me_la = ext. device. geolocation. Latitude;
// Var me_lo = ext. device. geolocation. longpolling;
Navigator. geolocation. getcurrentposition (function (position ){
// Alert (position. coords. Latitude + '+ position. coords. longpolling );
// Var me_la = ext. device. geolocation. getlatitude; // cannot be obtained
// Var me_lo = ext. device. geolocation. getlongpolling; // cannot be obtained
VaR me_la = position. coords. Latitude;
VaR me_lo = position. coords. longpolling;
VaR G = ext. Create ('myapp. Controller. calculate ');
VaR distance = G. getdisance (pk_la, pk_lo, me_la, me_lo );
// Console. Log (me_la );
// Console. Log (me_lo );
// Console. Log (distance );
Ext. getcmp ('loclabelid'). setvalue (distance + 'meters ');
});
},
Init: function (){
This. callparent ();
Console. Log ('init1 ');
}
});
/**
* Created by-PC on 2014/8/12.
*/
Ext. Define ('myapp. View. maincontainer ',{
Extend: 'ext. iner ',
Alias: 'widget. maininer iner ',
Requires: ['ext. toolbar'],
Initialize: function (){
This. callparent ();
VaR toptoolbar = {
Xtype: 'toolbar ',
Title: 'linear distance ',
Docked: 'top ',
Items :[
{
Xtype: 'spacer'
}
]
};
VaR loclabel = {
Xtype: 'textfield ',
Name: 'title ',
Label: 'the distance between you and Tiananmen Square is :',
ID: 'loclabelid'
};
This. Add ([
Toptoolbar,
Loclabel
]);
}
/* Config :{
Layout :{
Type: 'fit'
}
}*/
});
650) This. width = 650; "src =" http://img.blog.csdn.net/20140814191701663? Watermark/2/text/plain/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma ==/ dissolve/70/gravity/Southeast "/>