Skip to content

Commit

Permalink
Upgrade to touch22. Work around the removal of lat/lng data in the
Browse files Browse the repository at this point in the history
Yelp API by issuing a separate GMaps geocoding request at the
time the map is displayed.
  • Loading branch information
lojjic committed Sep 4, 2013
1 parent d63670d commit f88a1ac
Show file tree
Hide file tree
Showing 18 changed files with 220 additions and 155 deletions.
17 changes: 6 additions & 11 deletions CityBars/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,17 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>citybars</title>
<script>
var Ext = Ext || {};
Ext.theme = {
name: "Default"
};
</script>
<script src="touch/sencha-touch-all.js"></script>
<link rel="stylesheet" href="touch/resources/css/sencha-touch.css">
<link rel="stylesheet" href="citybars.css">
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript">
if (!Ext.browser.is.WebKit) {
alert("The current browser is unsupported.\n\nSupported browsers:\n" +
"Google Chrome\n" +
"Apple Safari\n" +
"Mobile Safari (iOS)\n" +
"Android Browser\n" +
"BlackBerry Browser"
);
}
</script>
</head>
<body></body>
</html>
6 changes: 3 additions & 3 deletions CityBars/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* File: app.js
*
* This file was generated by Sencha Architect version 2.2.0.
* This file was generated by Sencha Architect version 2.2.2.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Sencha Touch 2.1.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.1.x. For more
* This file requires use of the Sencha Touch 2.2.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.2.x. For more
* details see http://www.sencha.com/license or contact [email protected].
*
* This file will be auto-generated each and everytime you save your project.
Expand Down
83 changes: 57 additions & 26 deletions CityBars/app/controller/Business.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* File: app/controller/Business.js
*
* This file was generated by Sencha Architect version 2.2.0.
* This file was generated by Sencha Architect version 2.2.2.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Sencha Touch 2.1.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.1.x. For more
* This file requires use of the Sencha Touch 2.2.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.2.x. For more
* details see http://www.sencha.com/license or contact [email protected].
*
* This file will be auto-generated each and everytime you save your project.
Expand All @@ -30,55 +30,86 @@ Ext.define('CityBars.controller.Business', {
},
"detailpanel button[text='Call']": {
tap: 'onCallButtonTap'
},
"detailpanel > map": {
activate: 'onMapActivate'
}
}
},

onListItemTap: function(dataview, index, target, record, e, eOpts) {
var me = this,
map,
lat,
lon,
loc,
marker,
info, details;
var map,
info,
details;

if (record) {

details = Ext.create('CityBars.view.DetailPanel', {
title: 'Details'
});

// set the map
map = details.child('#detailMap');
lat = record.get('latitude');
lon = record.get('longitude');

map.setMapOptions({
zoom: 18
});

// fixes a bug in touch 2.1.1
map.element.un('painted', 'setMapCenter', map);

map.setMapCenter({
latitude: lat,
longitude: lon
});
map._record = record;

// set the info
info = details.child('#contact').child('#info');
info.child('#photo').setData(record.data);
info.child('#data').setData(record.data);

me.getMainNav().push(details);
this.getMainNav().push(details);
}
},

onCallButtonTap: function(button, e, eOpts) {
alert('call tap');
},

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);
}
}
);
}

},

getLocation: function(callback) {
console.log('getLoc');
if (navigator && navigator.geolocation) {
Expand Down
12 changes: 9 additions & 3 deletions CityBars/app/model/Business.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* File: app/model/Business.js
*
* This file was generated by Sencha Architect version 2.2.0.
* This file was generated by Sencha Architect version 2.2.2.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Sencha Touch 2.1.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.1.x. For more
* This file requires use of the Sencha Touch 2.2.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.2.x. For more
* details see http://www.sencha.com/license or contact [email protected].
*
* This file will be auto-generated each and everytime you save your project.
Expand Down Expand Up @@ -54,6 +54,12 @@ Ext.define('CityBars.model.Business', {
},
{
name: 'photo_url'
},
{
name: 'city'
},
{
name: 'zip'
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions CityBars/app/store/BusinessStore.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* File: app/store/BusinessStore.js
*
* This file was generated by Sencha Architect version 2.2.0.
* This file was generated by Sencha Architect version 2.2.2.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Sencha Touch 2.1.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.1.x. For more
* This file requires use of the Sencha Touch 2.2.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.2.x. For more
* details see http://www.sencha.com/license or contact [email protected].
*
* This file will be auto-generated each and everytime you save your project.
Expand Down
6 changes: 3 additions & 3 deletions CityBars/app/view/DetailPanel.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* File: app/view/DetailPanel.js
*
* This file was generated by Sencha Architect version 2.2.0.
* This file was generated by Sencha Architect version 2.2.2.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Sencha Touch 2.1.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.1.x. For more
* This file requires use of the Sencha Touch 2.2.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.2.x. For more
* details see http://www.sencha.com/license or contact [email protected].
*
* This file will be auto-generated each and everytime you save your project.
Expand Down
6 changes: 3 additions & 3 deletions CityBars/app/view/ListContainer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* File: app/view/ListContainer.js
*
* This file was generated by Sencha Architect version 2.2.0.
* This file was generated by Sencha Architect version 2.2.2.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Sencha Touch 2.1.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.1.x. For more
* This file requires use of the Sencha Touch 2.2.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.2.x. For more
* details see http://www.sencha.com/license or contact [email protected].
*
* This file will be auto-generated each and everytime you save your project.
Expand Down
6 changes: 3 additions & 3 deletions CityBars/app/view/MainNav.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* File: app/view/MainNav.js
*
* This file was generated by Sencha Architect version 2.2.0.
* This file was generated by Sencha Architect version 2.2.2.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Sencha Touch 2.1.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.1.x. For more
* This file requires use of the Sencha Touch 2.2.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.2.x. For more
* details see http://www.sencha.com/license or contact [email protected].
*
* This file will be auto-generated each and everytime you save your project.
Expand Down
8 changes: 4 additions & 4 deletions CityBars/citybars.xds
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"appName": "MyApp",
"buildShouldOverwriteIndex": true
},
"xdsVersion": "2.2.0",
"xdsBuild": 909,
"xdsVersion": "2.2.2",
"xdsBuild": 991,
"schemaVersion": 1,
"upgradeVersion": 210000000499,
"framework": "touch21",
"upgradeVersion": 210000000503,
"framework": "touch22",
"topInstanceFileMap": {
"3e7eb33b-8bf5-47c1-b6db-b85e588a629a": {
"paths": [
Expand Down
Loading

0 comments on commit f88a1ac

Please sign in to comment.