@maccesar/titools 5.2.5 → 5.4.0

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.
Files changed (138) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +58 -97
  3. package/agents/ti-pro.md +4 -2
  4. package/commands/ti-audit.md +7 -5
  5. package/docs/examples.md +24 -13
  6. package/docs/knowledge-index.md +2 -1
  7. package/lib/config.js +1 -0
  8. package/package.json +1 -1
  9. package/skills/alloy-guides/SKILL.md +18 -179
  10. package/skills/alloy-guides/references/CLI_TASKS.md +17 -216
  11. package/skills/alloy-guides/references/CONCEPTS.md +27 -162
  12. package/skills/alloy-guides/references/CONTROLLERS.md +38 -236
  13. package/skills/alloy-guides/references/MODELS.md +47 -723
  14. package/skills/alloy-guides/references/MODELS_ADVANCED.md +21 -482
  15. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +12 -222
  16. package/skills/alloy-guides/references/VIEWS_STYLES.md +39 -358
  17. package/skills/alloy-guides/references/VIEWS_XML.md +36 -552
  18. package/skills/alloy-guides/references/WIDGETS.md +49 -127
  19. package/skills/alloy-howtos/SKILL.md +14 -169
  20. package/skills/alloy-howtos/references/best_practices.md +9 -113
  21. package/skills/alloy-howtos/references/cli_reference.md +18 -223
  22. package/skills/alloy-howtos/references/config_files.md +50 -133
  23. package/skills/alloy-howtos/references/debugging_troubleshooting.md +19 -63
  24. package/skills/alloy-howtos/references/samples.md +21 -138
  25. package/skills/ti-api/SKILL.md +10 -2
  26. package/skills/ti-api/references/api-android.md +36 -2
  27. package/skills/ti-api/references/api-app-platform.md +39 -3
  28. package/skills/ti-api/references/api-core.md +50 -18
  29. package/skills/ti-api/references/api-data-network.md +49 -35
  30. package/skills/ti-api/references/api-media.md +45 -27
  31. package/skills/ti-api/references/api-services.md +39 -9
  32. package/skills/ti-api/references/api-ui-android.md +33 -13
  33. package/skills/ti-api/references/api-ui-extras.md +41 -15
  34. package/skills/ti-api/references/api-ui-ios-animator.md +42 -26
  35. package/skills/ti-api/references/api-ui-ios.md +74 -2
  36. package/skills/ti-api/references/api-ui-lists.md +32 -16
  37. package/skills/ti-api/references/api-ui-text-input.md +34 -17
  38. package/skills/ti-api/references/api-ui-views.md +27 -1
  39. package/skills/ti-api/references/api-ui-windows-navigation.md +32 -18
  40. package/skills/ti-api/references/api-xml-global.md +66 -16
  41. package/skills/ti-create-release/SKILL.md +98 -0
  42. package/skills/ti-create-release/references/module-discovery.md +69 -0
  43. package/skills/ti-expert/references/adaptive-layouts.md +1 -1
  44. package/skills/ti-guides/SKILL.md +37 -76
  45. package/skills/ti-guides/references/advanced-data-and-images.md +122 -126
  46. package/skills/ti-guides/references/android-manifest.md +24 -83
  47. package/skills/ti-guides/references/app-distribution.md +31 -377
  48. package/skills/ti-guides/references/application-frameworks.md +127 -335
  49. package/skills/ti-guides/references/cli-reference.md +184 -633
  50. package/skills/ti-guides/references/commonjs-advanced.md +81 -231
  51. package/skills/ti-guides/references/compatibility-matrix.md +36 -75
  52. package/skills/ti-guides/references/hello-world.md +95 -70
  53. package/skills/ti-guides/references/hyperloop-native-access.md +52 -448
  54. package/skills/ti-guides/references/resources.md +174 -142
  55. package/skills/ti-guides/references/sdk-release-notes.md +28 -71
  56. package/skills/ti-guides/references/tiapp-config.md +222 -598
  57. package/skills/ti-howtos/SKILL.md +23 -123
  58. package/skills/ti-howtos/references/cross-platform-development.md +119 -324
  59. package/skills/ti-howtos/references/debugging-profiling.md +77 -445
  60. package/skills/ti-howtos/references/extending-titanium.md +199 -673
  61. package/skills/ti-howtos/references/local-data-sources.md +87 -300
  62. package/skills/ti-howtos/references/location-and-maps.md +86 -213
  63. package/skills/ti-howtos/references/media-apis.md +103 -223
  64. package/skills/ti-howtos/references/notification-services.md +86 -506
  65. package/skills/ti-howtos/references/remote-data-sources.md +97 -316
  66. package/skills/ti-howtos/references/using-modules.md +77 -133
  67. package/skills/ti-synthengine/SKILL.md +62 -111
  68. package/skills/ti-synthengine/assets/example/README.md +50 -59
  69. package/skills/ti-synthengine/assets/example/app.js +67 -65
  70. package/skills/ti-synthengine/assets/example/lib/sequenceOwner.js +39 -40
  71. package/skills/ti-synthengine/assets/example/lib/soundPreset.js +34 -0
  72. package/skills/ti-synthengine/assets/index.d.ts +122 -2
  73. package/skills/ti-synthengine/references/advanced-examples.md +4 -4
  74. package/skills/ti-synthengine/references/api.md +40 -18
  75. package/skills/ti-synthengine/references/audio-engine.md +15 -57
  76. package/skills/ti-synthengine/references/examples.md +63 -6
  77. package/skills/ti-synthengine/references/guide.md +61 -57
  78. package/skills/ti-synthengine/references/instruments-and-effects.md +15 -15
  79. package/skills/ti-synthengine/references/native-variation.md +53 -14
  80. package/skills/ti-synthengine/references/recipes-interaction.md +25 -20
  81. package/skills/ti-synthengine/references/recipes.md +19 -16
  82. package/skills/ti-synthengine/references/recommendations.md +12 -12
  83. package/skills/ti-synthengine/references/sound-api.md +197 -0
  84. package/skills/ti-synthengine/references/sound-design.md +7 -7
  85. package/skills/ti-synthengine/references/source-notes.md +62 -172
  86. package/skills/ti-synthengine/references/troubleshooting.md +17 -19
  87. package/skills/ti-synthengine/references/upgrade-2.0.0.md +40 -0
  88. package/skills/ti-ui/SKILL.md +28 -143
  89. package/skills/ti-ui/references/icons-and-splash-screens.md +74 -403
  90. package/skills/ti-ui/references/layouts-and-positioning.md +175 -402
  91. package/skills/ti-ui/references/listviews-and-performance.md +100 -703
  92. package/skills/ti-ui/references/platform-conventions.md +180 -0
  93. package/skills/ti-ui/references/user-interface.md +43 -0
  94. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +0 -102
  95. package/skills/alloy-howtos/references/custom_tags.md +0 -148
  96. package/skills/ti-guides/references/coding-best-practices.md +0 -149
  97. package/skills/ti-guides/references/javascript-primer.md +0 -414
  98. package/skills/ti-guides/references/reserved-words.md +0 -36
  99. package/skills/ti-guides/references/style-and-conventions.md +0 -103
  100. package/skills/ti-howtos/references/android-platform-deep-dives.md +0 -624
  101. package/skills/ti-howtos/references/automation-fastlane-appium.md +0 -96
  102. package/skills/ti-howtos/references/buffer-codec-streams.md +0 -162
  103. package/skills/ti-howtos/references/google-maps-v2.md +0 -172
  104. package/skills/ti-howtos/references/ios-map-kit.md +0 -149
  105. package/skills/ti-howtos/references/ios-platform-deep-dives.md +0 -611
  106. package/skills/ti-howtos/references/tutorials.md +0 -565
  107. package/skills/ti-howtos/references/web-content-integration.md +0 -287
  108. package/skills/ti-howtos/references/webpack-build-pipeline.md +0 -124
  109. package/skills/ti-synthengine/references/android-sim80-correction-evidence.zip +0 -0
  110. package/skills/ti-synthengine/references/android-sim80-correction.json +0 -162
  111. package/skills/ti-synthengine/references/audio-pipeline-validation.md +0 -19
  112. package/skills/ti-synthengine/references/bypass-physical-recheck-evidence.zip +0 -0
  113. package/skills/ti-synthengine/references/frontier-android-evidence.zip +0 -0
  114. package/skills/ti-synthengine/references/frontier-ipad-evidence.zip +0 -0
  115. package/skills/ti-synthengine/references/frontier-physical-validation.json +0 -1918
  116. package/skills/ti-synthengine/references/native-tone-repetition-validation.md +0 -59
  117. package/skills/ti-synthengine/references/native-variation-proposal.md +0 -182
  118. package/skills/ti-synthengine/references/native-variation-validation.md +0 -63
  119. package/skills/ti-synthengine/references/performance-review-evidence.zip +0 -0
  120. package/skills/ti-synthengine/references/performance-review.json +0 -1146
  121. package/skills/ti-synthengine/references/physical-validation.json +0 -1457
  122. package/skills/ti-synthengine/references/source-snapshot.json +0 -542
  123. package/skills/ti-synthengine/references/stats-performance.json +0 -2992
  124. package/skills/ti-synthengine/references/stats-performance.md +0 -82
  125. package/skills/ti-synthengine/references/studio-validation.json +0 -6202
  126. package/skills/ti-synthengine/references/unified-bypass-performance.json +0 -22425
  127. package/skills/ti-synthengine/references/unified-validation.json +0 -314
  128. package/skills/ti-ui/references/accessibility-deep-dive.md +0 -288
  129. package/skills/ti-ui/references/animation-and-matrices.md +0 -569
  130. package/skills/ti-ui/references/application-structures.md +0 -626
  131. package/skills/ti-ui/references/custom-fonts-styling.md +0 -549
  132. package/skills/ti-ui/references/event-handling.md +0 -401
  133. package/skills/ti-ui/references/gestures.md +0 -448
  134. package/skills/ti-ui/references/orientation.md +0 -374
  135. package/skills/ti-ui/references/platform-ui-android.md +0 -727
  136. package/skills/ti-ui/references/platform-ui-ios.md +0 -576
  137. package/skills/ti-ui/references/scrolling-views.md +0 -288
  138. package/skills/ti-ui/references/tableviews.md +0 -542
@@ -1,162 +0,0 @@
1
- # Buffer, Codec, and streams
2
-
3
- Guide to binary data manipulation and data flows in Titanium SDK.
4
-
5
- ## 1. Titanium.Buffer
6
-
7
- Buffers are mutable, resizable containers for bytes (byte arrays).
8
-
9
- ### Creating buffers
10
- ```javascript
11
- // Empty buffer (initial length 0)
12
- const buffer0 = Ti.createBuffer();
13
-
14
- // Empty 512-byte buffer
15
- const buffer1 = Ti.createBuffer({ length: 512 });
16
-
17
- // Buffer initialized with a string (UTF-8 by default)
18
- const buffer2 = Ti.createBuffer({ value: 'Hello World' });
19
-
20
- // Buffer initialized with explicit charset
21
- const buffer3 = Ti.createBuffer({ value: 'Hello World', type: Ti.Codec.CHARSET_UTF16 });
22
- ```
23
-
24
- ### Common operations
25
- ```javascript
26
- const b1 = Ti.createBuffer({ value: 'Part 1. ' });
27
- const b2 = Ti.createBuffer({ value: 'Part 2.' });
28
-
29
- // Append (resizes b1)
30
- b1.append(b2);
31
-
32
- // Insert at position (resizes buffer as needed)
33
- const extra = Ti.createBuffer({ value: 'X' });
34
- b1.insert(extra, 1); // insert extra at index 1
35
-
36
- // Truncate
37
- b1.length = 10;
38
-
39
- // Direct array access — buffer is NOT auto-extended; values must be byte values
40
- b1[0] = 72; // 'H' (ASCII). b1[100] = 1 would throw if index >= b1.length
41
-
42
- // Free memory
43
- b1.release();
44
- ```
45
-
46
- ## 2. Titanium.Codec
47
-
48
- The Codec module encodes and decodes primitive data (numbers and strings) to and from buffers.
49
-
50
- ### Encoding numbers
51
- ```javascript
52
- const buffer = Ti.createBuffer({ length: 8 });
53
- Ti.Codec.encodeNumber({
54
- source: 12345,
55
- dest: buffer,
56
- type: Ti.Codec.TYPE_INT,
57
- byteOrder: Ti.Codec.BIG_ENDIAN
58
- });
59
- ```
60
-
61
- ### Encoding strings
62
- ```javascript
63
- // Encode a string into a buffer; returns the byte length written
64
- const buffer = Ti.createBuffer({ length: 1024 });
65
- const encodedLength = Ti.Codec.encodeString({
66
- source: 'hello world',
67
- dest: buffer
68
- });
69
- // Trim buffer to actual content
70
- buffer.length = encodedLength;
71
- ```
72
-
73
- ### Decoding strings
74
- ```javascript
75
- const text = Ti.Codec.decodeString({
76
- source: buffer,
77
- charset: Ti.Codec.CHARSET_UTF8
78
- });
79
- ```
80
-
81
- ### Supported types and charsets
82
-
83
- Numeric types: `TYPE_BYTE`, `TYPE_SHORT`, `TYPE_INT`, `TYPE_LONG`, `TYPE_FLOAT`, `TYPE_DOUBLE`
84
-
85
- String charsets: `CHARSET_UTF8`, `CHARSET_UTF16`, `CHARSET_UTF16BE`, `CHARSET_UTF16LE`, `CHARSET_ISO_LATIN1`
86
-
87
- ### Position parameter
88
- The `position` parameter controls where encoding or decoding starts in the buffer:
89
- ```javascript
90
- Ti.Codec.encodeNumber({
91
- source: 42,
92
- dest: buffer,
93
- position: 4, // start writing at byte 4
94
- type: Ti.Codec.TYPE_INT
95
- });
96
- ```
97
-
98
- ## 3. Streams
99
-
100
- Streams let you read and write data in a serialized, memory-efficient way.
101
-
102
- ### Stream types
103
- 1. BufferStream: for reading and writing in-memory buffers
104
- 2. FileStream: for file operations (more efficient than `file.read()`)
105
- 3. BlobStream: read-only for Blob objects (images, camera)
106
-
107
- Stream modes: `Ti.Filesystem.MODE_READ`, `Ti.Filesystem.MODE_WRITE`, `Ti.Filesystem.MODE_APPEND`
108
-
109
- ### Example: BufferStream
110
- ```javascript
111
- const buffer = Ti.createBuffer({ length: 1024 });
112
- const stream = Ti.Stream.createStream({
113
- source: buffer,
114
- mode: Ti.Stream.MODE_WRITE
115
- });
116
-
117
- stream.write(Ti.createBuffer({ value: 'Stream data' }));
118
- stream.close();
119
- ```
120
-
121
- ### Example: FileStream (chunk-based reading)
122
- ```javascript
123
- const file = Ti.Filesystem.getFile('large_file.txt');
124
- const instream = file.open(Ti.Filesystem.MODE_READ);
125
- const buffer = Ti.createBuffer({ length: 1024 }); // 1KB chunks
126
-
127
- let bytesRead = 0;
128
- while ((bytesRead = instream.read(buffer)) > 0) {
129
- Ti.API.info(`Read ${bytesRead} bytes`);
130
- // Process buffer...
131
- }
132
- instream.close();
133
- ```
134
-
135
- ### Example: BlobStream (camera to file)
136
- ```javascript
137
- Ti.Media.showCamera({
138
- success: (e) => {
139
- const instream = Ti.Stream.createStream({
140
- source: e.media,
141
- mode: Ti.Stream.MODE_READ
142
- });
143
-
144
- const outfile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'photo.jpg');
145
- const outstream = outfile.open(Ti.Filesystem.MODE_WRITE);
146
-
147
- const buffer = Ti.createBuffer({ length: 4096 });
148
- let readBytes = 0;
149
- while ((readBytes = instream.read(buffer)) > 0) {
150
- outstream.write(buffer, 0, readBytes);
151
- }
152
-
153
- instream.close();
154
- outstream.close();
155
- }
156
- });
157
- ```
158
-
159
- ## 4. Best practices
160
- - Always close streams to avoid memory leaks and file locks.
161
- - Use chunks for large files or networking (for example, 1KB or 4KB) to avoid saturating RAM.
162
- - Buffers vs Blobs: Buffers are mutable; Blobs are immutable. Convert a Blob to a Buffer if you need to modify bytes.
@@ -1,172 +0,0 @@
1
- # Google Maps v2 for Android
2
-
3
- Guide to implementing native maps on Android using the `ti.map` module (v2).
4
-
5
- ## 1. Initial configuration
6
-
7
- ### Module installation
8
- Add the module to `tiapp.xml`:
9
-
10
- ```xml
11
- <modules>
12
- <module platform="android">ti.map</module>
13
- </modules>
14
- ```
15
-
16
- ### Obtaining an API key (Google Cloud Console)
17
- 1. Create a project in the Google Cloud Console.
18
- 2. Enable "Maps SDK for Android".
19
- 3. Generate an API key. You will need the application ID from your `tiapp.xml` and the SHA-1 fingerprint from your keystore.
20
-
21
- #### Get SHA-1 (debug)
22
- ```bash
23
- keytool -list -v -keystore ~/Library/Application\ Support/titanium/mobilesdk/osx/<VERSION>/android/dev_keystore
24
- ```
25
- Default password: empty (press Enter).
26
-
27
- ### Configure tiapp.xml
28
- Add the API key in the Android section:
29
-
30
- ```xml
31
- <android xmlns:android="http://schemas.android.com/apk/res/android">
32
- <manifest>
33
- <application>
34
- <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="YOUR_API_KEY_HERE"/>
35
- </application>
36
- </manifest>
37
- </android>
38
- ```
39
-
40
- ## 2. Google Play Services verification
41
-
42
- Verify availability before rendering the map:
43
-
44
- ```javascript
45
- const MapModule = require('ti.map');
46
- const rc = MapModule.isGooglePlayServicesAvailable();
47
-
48
- switch (rc) {
49
- case MapModule.SUCCESS:
50
- Ti.API.info('Google Play Services available');
51
- break;
52
- case MapModule.SERVICE_MISSING:
53
- Ti.API.error('Google Play Services is missing');
54
- break;
55
- case MapModule.SERVICE_VERSION_UPDATE_REQUIRED:
56
- Ti.API.error('Google Play Services needs update');
57
- break;
58
- case MapModule.SERVICE_DISABLED:
59
- Ti.API.error('Google Play Services is disabled');
60
- break;
61
- case MapModule.SERVICE_INVALID:
62
- Ti.API.error('Google Play Services is invalid');
63
- break;
64
- }
65
- ```
66
-
67
- ## 3. Using the map view
68
-
69
- ### Basic creation
70
- ```javascript
71
- const MapModule = require('ti.map');
72
- const mapView = MapModule.createView({
73
- mapType: MapModule.NORMAL_TYPE,
74
- userLocation: true,
75
- traffic: true, // Show real-time traffic
76
- animate: true,
77
- region: {
78
- latitude: -33.87365,
79
- longitude: 151.20689,
80
- latitudeDelta: 0.1,
81
- longitudeDelta: 0.1
82
- }
83
- });
84
- ```
85
-
86
- ### Map types
87
- - `MapModule.NORMAL_TYPE`: standard map
88
- - `MapModule.SATELLITE_TYPE`: satellite imagery
89
- - `MapModule.TERRAIN_TYPE`: terrain map
90
- - `MapModule.HYBRID_TYPE`: satellite with labels
91
-
92
- ## 4. Advanced annotations (pins)
93
-
94
- ```javascript
95
- const opera = MapModule.createAnnotation({
96
- latitude: -33.8569,
97
- longitude: 151.2153,
98
- title: 'Sydney Opera House',
99
- subtitle: 'NSW, Australia',
100
- pincolor: MapModule.ANNOTATION_VIOLET,
101
- image: 'custom_pin.png', // Custom image
102
- draggable: true, // Allow pin dragging
103
- // Complete custom view (replaces the pin)
104
- customView: Ti.UI.createLabel({ text: 'Pin', backgroundColor: 'white' })
105
- });
106
-
107
- mapView.addAnnotation(opera);
108
- ```
109
-
110
- ### Additional annotation properties
111
- - `customView`: a `Ti.UI.View` that replaces the entire annotation (takes precedence over `image`)
112
- - `centerOffset`: `{x, y}` offset for the annotation relative to the coordinate
113
- - `canShowCallout`: whether tapping shows the info bubble (default: `true`)
114
-
115
- Precedence: `customView` > `image` > default pin. For buttons: `leftView`/`rightView` take precedence over `leftButton`/`rightButton`.
116
-
117
- ### Available pin colors
118
- `ANNOTATION_AZURE`, `BLUE`, `CYAN`, `GREEN`, `MAGENTA`, `ORANGE`, `RED`, `ROSE`, `VIOLET`, `YELLOW`.
119
-
120
- ## 5. Routes (polylines)
121
-
122
- ```javascript
123
- const route = MapModule.createRoute({
124
- width: 5,
125
- color: '#f00',
126
- points: [
127
- { latitude: -33.8569, longitude: 151.2153 },
128
- { latitude: -33.8522, longitude: 151.2105 }
129
- ]
130
- });
131
-
132
- mapView.addRoute(route);
133
- ```
134
-
135
- ## 6. Critical events
136
-
137
- ```javascript
138
- // Detect click on annotation or its buttons
139
- mapView.addEventListener('click', (e) => {
140
- if (e.clicksource === 'pin') {
141
- Ti.API.info(`Pin clicked: ${e.title}`);
142
- }
143
- });
144
-
145
- // Detect drag state changes
146
- // e.newState holds the drag state constant; e.annotation holds the annotation object
147
- mapView.addEventListener('pinchangedragstate', (e) => {
148
- if (e.newState === MapModule.ANNOTATION_DRAG_STATE_END) {
149
- Ti.API.info(`Dropped at: ${e.annotation.latitude}, ${e.annotation.longitude}`);
150
- }
151
- });
152
- // Drag states: ANNOTATION_DRAG_STATE_START, ANNOTATION_DRAG_STATE_END
153
-
154
- // Detect region changes
155
- mapView.addEventListener('regionchanged', (e) => {
156
- Ti.API.info(`New region: ${e.latitude}, ${e.longitude} (delta: ${e.latitudeDelta}, ${e.longitudeDelta})`);
157
- });
158
-
159
- // Detect complete rendering
160
- mapView.addEventListener('complete', (e) => {
161
- Ti.API.info('Map loaded');
162
- });
163
- ```
164
-
165
- ## 7. Migration from legacy Titanium.Map
166
-
167
- The `ti.map` module replaced the legacy `Titanium.Map` API. Key differences: use `NORMAL_TYPE` instead of `STANDARD_TYPE`, `ANNOTATION_VIOLET` instead of `ANNOTATION_PURPLE`, and routes are created with `Map.createRoute()` instead of abstract data types. Multiple MapView instances are supported.
168
-
169
- ## 8. Limitations and troubleshooting
170
- - Single map: Android (legacy) only allows one MapView instance per application. v2 allows multiple views.
171
- - Blank map: verify the API key and make sure `android:anyDensity` is not set to true in the manifest if you use old resolutions.
172
- - Simulator: Google Maps v2 is not compatible with the standard emulator without x86 Google Play Services. Test on a real device.
@@ -1,149 +0,0 @@
1
- # iOS Map Kit
2
-
3
- Guide to implementing native maps on iOS with the `ti.map` module.
4
-
5
- ## 1. Initial configuration
6
-
7
- ### Module installation
8
- Add the module to `tiapp.xml`:
9
-
10
- ```xml
11
- <modules>
12
- <module platform="iphone">ti.map</module>
13
- </modules>
14
- ```
15
-
16
- ### Location permissions (Info.plist)
17
- Add the required usage descriptions in `tiapp.xml`:
18
-
19
- ```xml
20
- <ios>
21
- <plist>
22
- <dict>
23
- <key>NSLocationWhenInUseUsageDescription</key>
24
- <string>We need your location to show it on the map.</string>
25
- <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
26
- <string>We need continuous location access for navigation.</string>
27
- </dict>
28
- </plist>
29
- </ios>
30
- ```
31
-
32
- iOS 11+: include both `NSLocationWhenInUseUsageDescription` and `NSLocationAlwaysAndWhenInUseUsageDescription`. Users can still choose "When in Use" even if you request "Always".
33
-
34
- ## 2. Using the map view
35
-
36
- ### Basic creation
37
- ```javascript
38
- const MapModule = require('ti.map');
39
- const mapView = MapModule.createView({
40
- mapType: MapModule.NORMAL_TYPE, // Also: SATELLITE_TYPE, HYBRID_TYPE, STANDARD_TYPE (alias for NORMAL_TYPE with labels)
41
- userLocation: true,
42
- rotatesEnabled: true, // Allow two-finger rotation
43
- region: {
44
- latitude: 48.8582,
45
- longitude: 2.2945,
46
- latitudeDelta: 0.02,
47
- longitudeDelta: 0.02
48
- }
49
- });
50
- ```
51
-
52
- ## 3. 3D camera (perspective)
53
-
54
- iOS lets you tilt and rotate the map for 3D views.
55
-
56
- Important: the map must be visible on screen before using camera APIs. Wait for the `complete` event before calling `animateCamera()` or setting camera properties.
57
-
58
- ```javascript
59
- const myCam = MapModule.createCamera({
60
- altitude: 300, // meters above ground
61
- centerCoordinate: { latitude: 48.8582, longitude: 2.2945 },
62
- heading: -45, // angle relative to North
63
- pitch: 60 // tilt angle downward
64
- });
65
-
66
- // Apply camera with animation
67
- mapView.animateCamera({
68
- camera: myCam,
69
- curve: Ti.UI.ANIMATION_CURVE_EASE_IN,
70
- duration: 1000
71
- });
72
-
73
- // Additional 3D view properties
74
- mapView.pitchEnabled = true;
75
- mapView.showsBuildings = true; // 3D buildings
76
- ```
77
-
78
- ## 4. iOS annotations
79
-
80
- ### iOS pin colors
81
- iOS supports only three pin color constants (unlike Android's ten):
82
- - `MapModule.ANNOTATION_GREEN`
83
- - `MapModule.ANNOTATION_PURPLE`
84
- - `MapModule.ANNOTATION_RED`
85
-
86
- ### System buttons and callouts
87
- iOS allows native buttons in the pin callout (popup window).
88
-
89
- ```javascript
90
- const bridge = MapModule.createAnnotation({
91
- latitude: -33.8522,
92
- longitude: 151.2105,
93
- title: 'Harbour Bridge',
94
- subtitle: 'Port Jackson',
95
- pincolor: MapModule.ANNOTATION_PURPLE,
96
- // iOS system buttons in the callout
97
- leftButton: Ti.UI.iOS.SystemButton.INFO_DARK,
98
- rightButton: Ti.UI.iOS.SystemButton.CONTACT_ADD,
99
- canShowCallout: true // Controls whether tapping the annotation shows the callout bubble (default: true)
100
- });
101
-
102
- mapView.addAnnotation(bridge);
103
- ```
104
-
105
- ### Center offset
106
- If you use a custom pin image that is not centered:
107
-
108
- ```javascript
109
- const customPin = MapModule.createAnnotation({
110
- image: 'flag.png',
111
- centerOffset: { x: 10, y: -20 } // Visually moves the pin
112
- });
113
- ```
114
-
115
- ## 5. Advanced routes
116
-
117
- ### Overlay levels
118
- Control whether the route appears above labels or above roads.
119
-
120
- ```javascript
121
- const route = MapModule.createRoute({
122
- points: routePoints,
123
- color: '#00f',
124
- width: 4,
125
- level: MapModule.OVERLAY_LEVEL_ABOVE_LABELS // default
126
- // or MapModule.OVERLAY_LEVEL_ABOVE_ROADS (below labels)
127
- });
128
- ```
129
-
130
- ## 6. Events
131
-
132
- Key map events: `click`, `complete` (map loaded), `regionchanged`, `pinchangedragstate`.
133
-
134
- Same as Android, but with specialized `clicksource` values for system buttons:
135
-
136
- ```javascript
137
- mapView.addEventListener('click', (e) => {
138
- if (e.clicksource === 'leftButton' || e.clicksource === 'rightButton') {
139
- Ti.API.info('Callout button clicked');
140
- }
141
- });
142
-
143
- // e.newState holds the drag state constant; e.annotation holds the annotation object
144
- mapView.addEventListener('pinchangedragstate', (e) => {
145
- if (e.newState === MapModule.ANNOTATION_DRAG_STATE_END) {
146
- Ti.API.info(`Dropped at: ${e.annotation.latitude}, ${e.annotation.longitude}`);
147
- }
148
- });
149
- ```