@maccesar/titools 2.2.4 → 2.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -23
- package/lib/commands/update.js +4 -12
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +31 -31
- package/skills/alloy-guides/references/CONCEPTS.md +3 -3
- package/skills/alloy-guides/references/CONTROLLERS.md +1 -1
- package/skills/alloy-guides/references/MODELS.md +6 -6
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +1 -1
- package/skills/alloy-guides/references/VIEWS_XML.md +1 -1
- package/skills/alloy-guides/references/WIDGETS.md +1 -1
- package/skills/alloy-howtos/SKILL.md +27 -27
- package/skills/alloy-howtos/references/best_practices.md +9 -9
- package/skills/alloy-howtos/references/cli_reference.md +14 -14
- package/skills/alloy-howtos/references/config_files.md +16 -16
- package/skills/alloy-howtos/references/custom_tags.md +16 -16
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +11 -15
- package/skills/alloy-howtos/references/samples.md +19 -19
- package/skills/purgetss/SKILL.md +11 -1
- package/skills/purgetss/references/animation-system.md +1 -1
- package/skills/purgetss/references/cli-commands.md +3 -3
- package/skills/purgetss/references/customization-deep-dive.md +1 -1
- package/skills/purgetss/references/dynamic-component-creation.md +1 -1
- package/skills/purgetss/references/icon-fonts.md +4 -0
- package/skills/purgetss/references/installation-setup.md +8 -1
- package/skills/purgetss/references/migration-guide.md +4 -0
- package/skills/purgetss/references/tikit-components.md +193 -204
- package/skills/purgetss/references/ui-ux-design.md +1 -1
- package/skills/ti-expert/SKILL.md +78 -118
- package/skills/ti-expert/references/alloy-builtins.md +18 -18
- package/skills/ti-expert/references/alloy-structure.md +21 -21
- package/skills/ti-expert/references/anti-patterns.md +15 -15
- package/skills/ti-expert/references/cli-expert.md +15 -15
- package/skills/ti-expert/references/code-conventions.md +38 -38
- package/skills/ti-expert/references/contracts.md +8 -8
- package/skills/ti-expert/references/controller-patterns.md +14 -14
- package/skills/ti-expert/references/error-handling.md +11 -11
- package/skills/ti-expert/references/examples.md +12 -12
- package/skills/ti-expert/references/migration-patterns.md +24 -24
- package/skills/ti-expert/references/patterns.md +10 -10
- package/skills/ti-expert/references/performance-listview.md +16 -16
- package/skills/ti-expert/references/performance-optimization.md +41 -41
- package/skills/ti-expert/references/security-device.md +22 -22
- package/skills/ti-expert/references/security-fundamentals.md +19 -19
- package/skills/ti-expert/references/state-management.md +33 -33
- package/skills/ti-expert/references/testing-e2e-ci.md +25 -25
- package/skills/ti-expert/references/testing-unit.md +24 -24
- package/skills/ti-expert/references/theming.md +15 -15
- package/skills/ti-guides/SKILL.md +58 -60
- package/skills/ti-guides/references/advanced-data-and-images.md +33 -33
- package/skills/ti-guides/references/android-manifest.md +15 -15
- package/skills/ti-guides/references/app-distribution.md +70 -166
- package/skills/ti-guides/references/application-frameworks.md +96 -114
- package/skills/ti-guides/references/cli-reference.md +294 -294
- package/skills/ti-guides/references/coding-best-practices.md +42 -33
- package/skills/ti-guides/references/commonjs-advanced.md +57 -51
- package/skills/ti-guides/references/hello-world.md +36 -36
- package/skills/ti-guides/references/hyperloop-native-access.md +66 -66
- package/skills/ti-guides/references/javascript-primer.md +83 -101
- package/skills/ti-guides/references/reserved-words.md +9 -9
- package/skills/ti-guides/references/resources.md +75 -83
- package/skills/ti-guides/references/style-and-conventions.md +35 -28
- package/skills/ti-guides/references/tiapp-config.md +110 -74
- package/skills/ti-howtos/SKILL.md +88 -92
- package/skills/ti-howtos/references/android-platform-deep-dives.md +104 -104
- package/skills/ti-howtos/references/automation-fastlane-appium.md +39 -39
- package/skills/ti-howtos/references/buffer-codec-streams.md +60 -60
- package/skills/ti-howtos/references/cross-platform-development.md +115 -136
- package/skills/ti-howtos/references/debugging-profiling.md +167 -181
- package/skills/ti-howtos/references/extending-titanium.md +121 -121
- package/skills/ti-howtos/references/google-maps-v2.md +84 -82
- package/skills/ti-howtos/references/ios-map-kit.md +65 -60
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +123 -123
- package/skills/ti-howtos/references/local-data-sources.md +79 -78
- package/skills/ti-howtos/references/location-and-maps.md +116 -120
- package/skills/ti-howtos/references/media-apis.md +87 -86
- package/skills/ti-howtos/references/notification-services.md +250 -260
- package/skills/ti-howtos/references/remote-data-sources.md +98 -93
- package/skills/ti-howtos/references/tutorials.md +226 -216
- package/skills/ti-howtos/references/using-modules.md +73 -102
- package/skills/ti-howtos/references/web-content-integration.md +101 -103
- package/skills/ti-howtos/references/webpack-build-pipeline.md +52 -44
- package/skills/ti-ui/SKILL.md +85 -85
- package/skills/ti-ui/references/accessibility-deep-dive.md +57 -57
- package/skills/ti-ui/references/animation-and-matrices.md +79 -79
- package/skills/ti-ui/references/application-structures.md +96 -99
- package/skills/ti-ui/references/custom-fonts-styling.md +99 -99
- package/skills/ti-ui/references/event-handling.md +58 -58
- package/skills/ti-ui/references/gestures.md +62 -64
- package/skills/ti-ui/references/icons-and-splash-screens.md +88 -88
- package/skills/ti-ui/references/layouts-and-positioning.md +87 -97
- package/skills/ti-ui/references/listviews-and-performance.md +107 -107
- package/skills/ti-ui/references/orientation.md +87 -88
- package/skills/ti-ui/references/platform-ui-android.md +87 -81
- package/skills/ti-ui/references/platform-ui-ios.md +63 -61
- package/skills/ti-ui/references/scrolling-views.md +29 -29
- package/skills/ti-ui/references/tableviews.md +56 -56
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
# Location
|
|
1
|
+
# Location services and maps
|
|
2
2
|
|
|
3
|
-
## 1. GPS
|
|
3
|
+
## 1. GPS position tracking
|
|
4
4
|
|
|
5
5
|
### FusedLocationProvider (Android)
|
|
6
6
|
Since TiSDK 7.1.0, Titanium supports `FusedLocationProvider` for significant battery savings.
|
|
7
|
-
|
|
7
|
+
Requirement: include the `ti.playservices` module in your project.
|
|
8
8
|
|
|
9
|
-
### Accuracy
|
|
9
|
+
### Accuracy configuration
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
- `ACCURACY_BEST` -
|
|
13
|
-
- `ACCURACY_NEAREST_TEN_METERS` -
|
|
14
|
-
- `ACCURACY_HUNDRED_METERS` -
|
|
15
|
-
- `ACCURACY_KILOMETER` -
|
|
16
|
-
- `ACCURACY_THREE_KILOMETERS` -
|
|
11
|
+
iOS accuracy levels:
|
|
12
|
+
- `ACCURACY_BEST` - highest power (GPS)
|
|
13
|
+
- `ACCURACY_NEAREST_TEN_METERS` - medium-high power
|
|
14
|
+
- `ACCURACY_HUNDRED_METERS` - medium power
|
|
15
|
+
- `ACCURACY_KILOMETER` - low power
|
|
16
|
+
- `ACCURACY_THREE_KILOMETERS` - lowest power (cell/wifi)
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Key properties:
|
|
19
19
|
```javascript
|
|
20
20
|
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;
|
|
21
21
|
Ti.Geolocation.distanceFilter = 10; // meters - only fire if moved X meters
|
|
22
|
-
Ti.Geolocation.headingFilter = 5;
|
|
22
|
+
Ti.Geolocation.headingFilter = 5; // degrees - only fire if heading changed X degrees
|
|
23
23
|
Ti.Geolocation.preferredProvider = Ti.Geolocation.PROVIDER_GPS; // or PROVIDER_NETWORK
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Note: on many Android devices, a low-precision passive location provider is always enabled, even when the user disables GPS and Network providers. `Ti.Geolocation.locationServicesEnabled` may always return `true` on those devices.
|
|
27
27
|
|
|
28
|
-
### Android
|
|
28
|
+
### Android configuration modes
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Simple mode (ACCURACY_HIGH/LOW):
|
|
31
31
|
```javascript
|
|
32
32
|
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_HIGH;
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Manual mode (fine-grained control):
|
|
36
36
|
```javascript
|
|
37
37
|
const providerGps = Ti.Geolocation.Android.createLocationProvider({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
name: Ti.Geolocation.PROVIDER_GPS,
|
|
39
|
+
minUpdateDistance: 0.0,
|
|
40
|
+
minUpdateTime: 0
|
|
41
41
|
});
|
|
42
42
|
Ti.Geolocation.Android.addLocationProvider(providerGps);
|
|
43
43
|
Ti.Geolocation.Android.manualMode = true;
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
### Location
|
|
46
|
+
### Location permissions
|
|
47
47
|
|
|
48
48
|
```javascript
|
|
49
49
|
// Check permissions
|
|
50
50
|
if (Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE)) {
|
|
51
|
-
|
|
51
|
+
startTracking();
|
|
52
52
|
} else {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, (e) => {
|
|
54
|
+
if (e.success) {
|
|
55
|
+
startTracking();
|
|
56
|
+
} else {
|
|
57
|
+
Ti.API.error(`Permission denied: ${e.error}`);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
iOS plist keys (tiapp.xml):
|
|
64
64
|
```xml
|
|
65
65
|
<key>NSLocationWhenInUseUsageDescription</key>
|
|
66
66
|
<string>We need your location to show nearby places</string>
|
|
@@ -69,58 +69,58 @@ if (Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_U
|
|
|
69
69
|
<string>We need background location for navigation</string>
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
Note (iOS 11+): you must include `NSLocationAlwaysAndWhenInUseUsageDescription` even when requesting "Always" permission. Users can still choose "When in Use".
|
|
73
73
|
|
|
74
|
-
### One-
|
|
74
|
+
### One-time position
|
|
75
75
|
|
|
76
76
|
```javascript
|
|
77
77
|
if (Ti.Geolocation.locationServicesEnabled) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
Ti.Geolocation.getCurrentPosition((e) => {
|
|
79
|
+
if (e.error) {
|
|
80
|
+
Ti.API.error(`Error: ${e.error}`);
|
|
81
|
+
} else {
|
|
82
|
+
const coords = e.coords;
|
|
83
|
+
// { latitude, longitude, altitude, accuracy, heading, speed, timestamp }
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
86
|
}
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
### Continuous
|
|
89
|
+
### Continuous monitoring
|
|
90
90
|
|
|
91
91
|
```javascript
|
|
92
92
|
Ti.Geolocation.addEventListener('location', (e) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
if (e.error) {
|
|
94
|
+
Ti.API.error(`Error: ${e.error}`);
|
|
95
|
+
} else {
|
|
96
|
+
Ti.API.info(`${e.coords.latitude}, ${e.coords.longitude}`);
|
|
97
|
+
}
|
|
98
98
|
});
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
### Lifecycle
|
|
101
|
+
### Lifecycle management (critical for battery)
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
Android Activity events:
|
|
104
104
|
```javascript
|
|
105
105
|
let locationAdded = false;
|
|
106
106
|
const handleLocation = (e) => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
if (!e.error) {
|
|
108
|
+
Ti.API.info(e.coords);
|
|
109
|
+
}
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
function addHandler() {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
if (!locationAdded) {
|
|
114
|
+
Ti.Geolocation.addEventListener('location', handleLocation);
|
|
115
|
+
locationAdded = true;
|
|
116
|
+
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
function removeHandler() {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
if (locationAdded) {
|
|
121
|
+
Ti.Geolocation.removeEventListener('location', handleLocation);
|
|
122
|
+
locationAdded = false;
|
|
123
|
+
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// Add listeners
|
|
@@ -128,144 +128,140 @@ addHandler();
|
|
|
128
128
|
|
|
129
129
|
const activity = Ti.Android.currentActivity;
|
|
130
130
|
activity.addEventListener('destroy', removeHandler);
|
|
131
|
-
activity.addEventListener('pause', removeHandler);
|
|
132
|
-
activity.addEventListener('resume', addHandler);
|
|
131
|
+
activity.addEventListener('pause', removeHandler); // Stop when in background
|
|
132
|
+
activity.addEventListener('resume', addHandler); // Resume when foreground
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
### Compass/
|
|
135
|
+
### Compass/heading
|
|
136
136
|
|
|
137
137
|
```javascript
|
|
138
138
|
// One-time heading
|
|
139
139
|
Ti.Geolocation.getCurrentHeading((e) => {
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
Ti.API.info(e.heading.magneticHeading); // degrees from magnetic north
|
|
141
|
+
Ti.API.info(e.heading.trueHeading); // degrees from true north
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
// Continuous heading monitoring
|
|
145
145
|
Ti.Geolocation.addEventListener('heading', (e) => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
if (!e.error) {
|
|
147
|
+
Ti.API.info(`Heading: ${e.heading.magneticHeading}`);
|
|
148
|
+
}
|
|
149
149
|
});
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
The heading event object includes:
|
|
153
|
-
- `heading.magneticHeading`
|
|
154
|
-
- `heading.trueHeading`
|
|
155
|
-
- `heading.accuracy`
|
|
156
|
-
- `heading.x`, `heading.y`, `heading.z`
|
|
157
|
-
|
|
158
|
-
---
|
|
153
|
+
- `heading.magneticHeading` - degrees relative to magnetic north
|
|
154
|
+
- `heading.trueHeading` - degrees relative to true north (requires location)
|
|
155
|
+
- `heading.accuracy` - deviation in degrees (lower is better)
|
|
156
|
+
- `heading.x`, `heading.y`, `heading.z` - raw magnetometer data (microteslas)
|
|
159
157
|
|
|
160
158
|
## Geocoding
|
|
161
159
|
|
|
162
|
-
### Forward
|
|
160
|
+
### Forward geocoding (address → coordinates)
|
|
163
161
|
|
|
164
162
|
```javascript
|
|
165
163
|
Ti.Geolocation.forwardGeocoder('440 Bernardo Ave Mountain View CA', (e) => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
if (e.success) {
|
|
165
|
+
Ti.API.info(`Lat: ${e.latitude}, Lon: ${e.longitude}`);
|
|
166
|
+
}
|
|
169
167
|
});
|
|
170
168
|
```
|
|
171
169
|
|
|
172
|
-
|
|
170
|
+
With error handling:
|
|
173
171
|
```javascript
|
|
174
172
|
Ti.Geolocation.forwardGeocoder('1600 Amphitheatre Pkwy, Mountain View, CA', (e) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
173
|
+
if (!e.success || e.error) {
|
|
174
|
+
Ti.API.error(`Geocoding failed: ${e.error}`);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
Ti.API.info(`Lat: ${e.latitude}, Lng: ${e.longitude}`);
|
|
180
178
|
});
|
|
181
179
|
```
|
|
182
180
|
|
|
183
|
-
### Reverse
|
|
181
|
+
### Reverse geocoding (coordinates → places)
|
|
184
182
|
|
|
185
183
|
```javascript
|
|
186
184
|
Ti.Geolocation.reverseGeocoder(37.389569, -122.050212, (e) => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
185
|
+
if (e.success) {
|
|
186
|
+
e.places.forEach((place) => {
|
|
187
|
+
Ti.API.info(place.address); // Full address
|
|
188
|
+
Ti.API.info(place.city); // City name
|
|
189
|
+
Ti.API.info(place.country); // Country
|
|
190
|
+
Ti.API.info(place.zipcode); // Postal code
|
|
191
|
+
});
|
|
192
|
+
}
|
|
195
193
|
});
|
|
196
194
|
```
|
|
197
195
|
|
|
198
|
-
## 2. Native
|
|
196
|
+
## 2. Native maps (platform-specific details)
|
|
199
197
|
|
|
200
198
|
Due to the complexity of modern native maps, refer to the detailed guides:
|
|
201
199
|
|
|
202
|
-
-
|
|
203
|
-
-
|
|
204
|
-
|
|
205
|
-
---
|
|
200
|
+
- Google Maps v2 for Android: `google-maps-v2.md`
|
|
201
|
+
- iOS Map Kit: `ios-map-kit.md`
|
|
206
202
|
|
|
207
|
-
## Common
|
|
203
|
+
## Common map patterns
|
|
208
204
|
|
|
209
|
-
### Add
|
|
205
|
+
### Add annotation after map creation
|
|
210
206
|
|
|
211
207
|
```javascript
|
|
212
208
|
mapview.addAnnotation(annotation);
|
|
213
209
|
```
|
|
214
210
|
|
|
215
|
-
### Remove
|
|
211
|
+
### Remove annotation
|
|
216
212
|
|
|
217
213
|
```javascript
|
|
218
214
|
mapview.removeAnnotation(annotation);
|
|
219
215
|
```
|
|
220
216
|
|
|
221
|
-
### Remove
|
|
217
|
+
### Remove all annotations
|
|
222
218
|
|
|
223
219
|
```javascript
|
|
224
220
|
mapview.removeAllAnnotations();
|
|
225
221
|
```
|
|
226
222
|
|
|
227
|
-
### Select
|
|
223
|
+
### Select annotation programmatically
|
|
228
224
|
|
|
229
225
|
```javascript
|
|
230
226
|
mapview.selectAnnotation(annotation);
|
|
231
227
|
```
|
|
232
228
|
|
|
233
|
-
### Deselect
|
|
229
|
+
### Deselect annotation
|
|
234
230
|
|
|
235
231
|
```javascript
|
|
236
232
|
mapview.deselectAnnotation(annotation);
|
|
237
233
|
```
|
|
238
234
|
|
|
239
|
-
### Set
|
|
235
|
+
### Set region with animation
|
|
240
236
|
|
|
241
237
|
```javascript
|
|
242
238
|
mapview.setLocation({
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
239
|
+
latitude: 37.389569,
|
|
240
|
+
longitude: -122.050212,
|
|
241
|
+
animate: true
|
|
246
242
|
});
|
|
247
243
|
|
|
248
244
|
// Or for region
|
|
249
245
|
mapview.setRegion({
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
246
|
+
latitude: 37.389569,
|
|
247
|
+
longitude: -122.050212,
|
|
248
|
+
latitudeDelta: 0.05,
|
|
249
|
+
longitudeDelta: 0.05,
|
|
250
|
+
animate: true
|
|
255
251
|
});
|
|
256
252
|
```
|
|
257
253
|
|
|
258
|
-
### Zoom to
|
|
254
|
+
### Zoom to annotations
|
|
259
255
|
|
|
260
256
|
```javascript
|
|
261
|
-
mapview.showAnnotations([annotation1, annotation2], true);
|
|
257
|
+
mapview.showAnnotations([annotation1, annotation2], true); // true = animate
|
|
262
258
|
```
|
|
263
259
|
|
|
264
|
-
### Best
|
|
260
|
+
### Best practices
|
|
265
261
|
|
|
266
|
-
1.
|
|
267
|
-
2.
|
|
268
|
-
3.
|
|
269
|
-
4.
|
|
270
|
-
5.
|
|
271
|
-
6.
|
|
262
|
+
1. Battery life: remove location listeners when not needed. Use `distanceFilter` to reduce updates.
|
|
263
|
+
2. Accuracy: use the lowest accuracy that meets your needs.
|
|
264
|
+
3. Permissions: check permissions before requesting location. Handle denial gracefully.
|
|
265
|
+
4. Maps on Android: only one map view per application (legacy). Use `ti.map` for multiple views.
|
|
266
|
+
5. API keys: Google Maps API key required for Android (debug and production).
|
|
267
|
+
6. User location: requires location permissions (`NSLocationWhenInUseUsageDescription` for iOS).
|