1. create a project using city bars template in sencha architect

2. save your project name as CityBars

3. modify your controll code to:

Ext.define('CityBars.controller.Business', {
extend: 'Ext.app.Controller', config: {
refs: {
dataList: '#dataList',
listCard: '#listCard',
mainNav: 'mainnav',
detailCard: 'detailpanel'
}, control: {
"#dataList": {
itemtap: 'onListItemTap'
},
"detailpanel #callButton": {
tap: 'onCallButtonTap'
},
"detailpanel > map": {
activate: 'onMapActivate'
}
}
}, onListItemTap: function(dataview, index, target, record, e, eOpts) {
var map,
info,
details; if (record) {
details = Ext.create('CityBars.view.DetailPanel', {
title: 'Details'
}); // set the map
map = details.child('#detailMap');
map._record = record; // set the info
info = details.child('#contact').child('#info');
info.child('#photo').setData(record.data);
info.child('#data').setData(record.data); this.getMainNav().push(details);
}
}, onCallButtonTap: function(button, e, eOpts) { // TODO: Add custom phone call code here
window.location = 'tel:555-555-5555'; }, onMapActivate: function(newActiveItem, container, oldActiveItem, eOpts) {
var map = newActiveItem,
record = map._record,
lat = record.get('latitude'),
lng = record.get('longitude'),
centerMap = Ext.Function.createDelayed(function() {
map.setMapOptions({
zoom: 18
});
map.setMapCenter({
latitude: lat,
longitude: lng
});
}, 250),
geocoder, loc; if (lat && lng) {
centerMap();
} else {
geocoder = this._geocoder || (this._geocoder = new google.maps.Geocoder());
geocoder.geocode(
{address: [
record.get('address1'),
record.get('address2'),
record.get('address3'),
record.get('city'),
record.get('state_code'),
record.get('zip')
].join(', ')},
function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
loc = results[0].geometry.location;
lat = loc.lat();
lng = loc.lng();
record.set('latitude', lat);
record.set('longitude', lng);
centerMap();
} else {
Ext.Msg.alert("Could not find location: " + status);
}
}
);
} }, launch: function() { var me = this; // NOTE ABOUT YELP KEY
// You must use your own yelp key, available by registering (for free) with Yelp:
// http://www.yelp.com/developers/getting_started/api_overview
// (in this app, we use the Review Search API v1.0)
me.apiKey = '8UUJ-jfiOwttLyzTC56F6A'; // enter your own yelp key here // Get the location, then find businesses
Ext.Viewport.setMasked({ xtype: 'loadmask', message: 'Loading...' });
me.getLocation(function (location) { // then use Yelp to get the businesses
me.getBusinesses(location, function (store) { // then bind data to list and show it
me.getDataList().setStore(store); Ext.Viewport.setMasked(false); }); }); }, getLocation: function(callback) {
if (navigator && navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
callback(position);
}, function(error) {
// give a warning for error
});
}
}, getBusinesses: function(location, callback) { var store = Ext.data.StoreManager.lookup('BusinessStore'),
url = 'http://api.yelp.com/business_review_search' +
'?ywsid=' + this.apiKey +
'&term=Bars' +
'&lat=37.785834' + //location.coords.latitude +
'&long=-122.406417';// + location.coords.longitude;
store.getProxy().setUrl(url);
store.load(function() {
callback(store);
}); } });

4. run sencha cmd to launch your application on your web server

sencha fs web start -map /Users/user1/Documents/CityBars

5. visit your web using the url , which likes the following format:http://localhost:1841

how to run demo city bars using sencha architect的更多相关文章

  1. BZOJ1628: [Usaco2007 Demo]City skyline

    1628: [Usaco2007 Demo]City skyline Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 256  Solved: 210[Su ...

  2. Sencha Architect 安装与使用

    http://www.sencha.com/products/touch/ Sencha SDK Tools Advanced JavaScript and CSS Project Build Too ...

  3. SenchaTouch介绍和Sencha Architect介绍以及安装

    一.SenchaTouch介绍 Sencha Touch框架是世界上第一个基于HTML 5的Mobile App框架. 在Sencha Touch这个名词中,包括了两个组成部分,其中Sencha的前身 ...

  4. sencha architect/sencha touch , to prevent breakpoint lost when you debug

    add this to your loader config: Ext.Loader.setConfig({ disableCaching: false }); or : click 'applica ...

  5. 如何在版本控制工具中管理Sencha Architect的項目

    根據數次痛苦的經歷結合stack overflow上的解答,發現原來還是可以使用svn.git之類的版本控制工具管理Sencha Architect生成的項目的. 具體的要點如下,假定項目記作{PRO ...

  6. Sencha Architect 激活方法

     Sencha Architect 2是ExtJS和Sencha Touch的官方可视化IDE工具.最新版本是2.2,说是破解,其实是修改License来实现无限试用而已. 1.先下载安装官方软件,大 ...

  7. 简单破解 Sencha Architect 2.2 (ExtJs Designer)

    Sencha Architect 2是ExtJS和Sencha Touch的官方可视化IDE工具.最新版本是2.2,说是破解,其实是修改License来实现无限试用而已. 1.先下载安装官方软件,大约 ...

  8. Sencha Architect打开闪退问题修复

    删除以下位置的cache文件夹 C:\Users\Administrator\AppData\Local\Sencha\Sencha Architect 3.2\Cache bug解决参考 https ...

  9. 使用Sencha Architect开发Sencha Touch应用的整理

    官网:http://www.sencha.com/ 其实官网上的文档都很清楚了,不过整理一下总比较好 第一步,软件准备 注: 以下软件的安装本着这样两条原则 一是不要安装在中文目录下 二是不要安装在带 ...

随机推荐

  1. Objective-C Runtime之着魔的UIAlertView

    前言: 上篇文章写的是Runtime的一个入门教程,刚哥问我那个Associated Objects加回调是啥时候用,那我就来告诉你啦!我们在使用UIAlertView的时候用的多. 传统的UIAle ...

  2. httpURLConnection-网络请求的两种方式-get请求和post请求

    GET请求 /** * 从网络获取json数据,(String byte[}) * @param path * @return */ public static String getJsonByInt ...

  3. IOS中如何显示带有html标签的富文本

    NSString *strHTML = @"<p>你好</p><p>        这是一个例子,请显示</p><p>外加一个ta ...

  4. eclipse引用头文件报错问题-解决方法

    最近在做一个U-BOOT相关的项目,经过几天的折腾最终放弃使用VIM和一堆附加插件.最终的出的结论是对于中大型工程项目还是要启用一些专业的IDE比较稳妥,尽管VIM提供的各种插件累加在一起足以实现专业 ...

  5. 虚反矩阵指令pinv之应用

    pinv指令     在多数解的例子中,有时并不是仅要将其中一变数设定为零之解.为使整个系统得到最佳化,亦可利用pinv指令求得最小模组之合理解.pinv(A)又称为虚反矩阵(pseudoinvers ...

  6. 最大公约数与欧几里得(Euclid)算法

    ---恢复内容开始--- 记a, b的最大公约数为gcd(a, b).显然, gcd(a,b)=gcd(|a|,|b|). 计算最大公约数的Euclid算法基于下面定理: [GCD递归定理]对于任意非 ...

  7. Chomp!游戏 (组合游戏Combinatorial Games)

    http://blog.csdn.net/acdreamers/article/details/17021095 有一个n*m的棋盘,每次可以取走一个方格并拿掉它右边和上面的所有方格.拿到左下角的格子 ...

  8. Verilog-FPGA硬件电路设计之一——if语句优先级(always块中的阻塞赋值生成的组合逻辑电路是按照顺利执行的)

    出处:http://bbs.ednchina.com/BLOG_ARTICLE_3013262.HTM 综合软件:Quartus II 一.有优先级的if语句 if..else if.. else i ...

  9. JSON数据理解

    话说JSON数据平常用的确实挺多的,但是基本上只知道怎么用,对其一些细节并没有整理过,今儿趁着下午有点空,坐下来,学习整理下,并分享出来. 对于JSON,首先它只是一种数据格式,并非一种语言,虽然和j ...

  10. react 全局面包屑

    renderBreadcrumb() { const {routes} = this.props; const items = routes.map((route, idx) => { let ...