@@ -62,6 +62,7 @@ const CameraAnimation = () => {
62
62
const [paddingRight , setPaddingRight ] = useState (0 );
63
63
const [paddingTop , setPaddingTop ] = useState (0 );
64
64
const [paddingBottom , setPaddingBottom ] = useState (0 );
65
+ const [zoom , setZoom ] = useState (10 );
65
66
const [minZoom , setMinZoom ] = useState< number | undefined > (undefined );
66
67
const [maxZoom , setMaxZoom ] = useState< number | undefined > (undefined );
67
68
@@ -165,6 +166,34 @@ const CameraAnimation = () => {
165
166
[easing],
166
167
);
167
168
169
+ const zoomCounter = useMemo (() => {
170
+ const disabled = coordinates .length > 1 ;
171
+
172
+ return (
173
+ < View style= {{ flex: 1 , paddingHorizontal: 10 }}>
174
+ < View style= {{ flex: 0 , alignItems: ' center' }}>
175
+ < Text style= {{ fontWeight: ' bold' , opacity: disabled ? 0.4 : 1 }}>
176
+ {zoom}
177
+ < / Text >
178
+ < / View>
179
+ < Slider
180
+ thumbStyle= {[
181
+ styles .thumb ,
182
+ { backgroundColor: disabled ? ' lightgray' : ' black' },
183
+ ]}
184
+ trackStyle= {{ opacity: disabled ? 0.1 : 1 }}
185
+ value= {zoom}
186
+ disabled= {disabled}
187
+ minimumValue= {1 }
188
+ maximumValue= {20 }
189
+ onSlidingComplete= {(_value ) => {
190
+ setZoom (Math .round (_value));
191
+ }}
192
+ / >
193
+ < / View>
194
+ );
195
+ }, [coordinates .length , zoom]);
196
+
168
197
const paddingCounter = useCallback (
169
198
(value: number, setValue : (value : number ) => void , label: string) => {
170
199
return (
@@ -174,11 +203,7 @@ const CameraAnimation = () => {
174
203
< Text style= {{ fontWeight: ' bold' }}> {` ${ Math .round (value)} ` }< / Text >
175
204
< / View>
176
205
< Slider
177
- thumbStyle= {{
178
- backgroundColor: ' black' ,
179
- width: 15 ,
180
- height: 15 ,
181
- }}
206
+ thumbStyle= {styles .thumb }
182
207
value= {value}
183
208
minimumValue= {0 }
184
209
maximumValue= {500 }
@@ -200,16 +225,12 @@ const CameraAnimation = () => {
200
225
< View style= {{ flex: 1 , paddingHorizontal: 10 }}>
201
226
< View style= {{ flex: 0 , alignItems: ' center' }}>
202
227
< Text > {label}< / Text >
203
- < Text style= {{ fontWeight: ' bold' }}> { ` ${
204
- value ?? ' Not set'
205
- } ` } </Text>
228
+ < Text style= {{ fontWeight: ' bold' }}>
229
+ { ` ${ value ?? ' Not set' } ` }
230
+ </Text>
206
231
</View>
207
232
<Slider
208
- thumbStyle={{
209
- backgroundColor: 'black',
210
- width: 15,
211
- height: 15,
212
- }}
233
+ thumbStyle={styles.thumb}
213
234
value={value}
214
235
minimumValue={-1}
215
236
maximumValue={20}
@@ -232,7 +253,7 @@ const CameraAnimation = () => {
232
253
<MapView style={styles.map}>
233
254
<Camera
234
255
{...centerOrBounds}
235
- zoomLevel={12 }
256
+ zoomLevel={zoom }
236
257
minZoomLevel={minZoom}
237
258
maxZoomLevel={maxZoom}
238
259
padding={{
@@ -276,6 +297,13 @@ const CameraAnimation = () => {
276
297
277
298
<Divider style={styles.divider} />
278
299
300
+ <Text style={styles.sectionText}>Zoom</Text>
301
+ <View style={[styles.buttonRow, { marginBottom: -6 }]}>
302
+ {zoomCounter}
303
+ </View>
304
+
305
+ <Divider style={styles.divider} />
306
+
279
307
<Text style={styles.sectionText}>Padding</Text>
280
308
<View style={[styles.buttonRow, { marginTop: 6 }]}>
281
309
{paddingCounter(paddingTop, setPaddingTop, 'Top')}
@@ -321,6 +349,11 @@ const styles = StyleSheet.create({
321
349
divider: {
322
350
marginVertical: 8,
323
351
},
352
+ thumb: {
353
+ backgroundColor: 'black',
354
+ width: 15,
355
+ height: 15,
356
+ },
324
357
});
325
358
326
359
export default CameraAnimation;
0 commit comments