Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native React native maps初始缩放:0不适用于iOS_React Native_React Native Ios_React Native Maps - Fatal编程技术网

React native React native maps初始缩放:0不适用于iOS

React native React native maps初始缩放:0不适用于iOS,react-native,react-native-ios,react-native-maps,React Native,React Native Ios,React Native Maps,我找不到使iOS RN贴图从缩放级别0开始或缩小到0的方法 const allowScaling = false; const region = { latitude: 0, longitude: 0, latitudeDelta: 170, longitudeDelta: 180, }; return ( <View style={{ position: 'relative', width: '100%', height

我找不到使iOS RN贴图从缩放级别0开始或缩小到0的方法

const allowScaling = false;

const region = {
  latitude: 0,
  longitude: 0,
  latitudeDelta: 170,
  longitudeDelta: 180,
};

return (
  <View
    style={{
      position: 'relative',
      width: '100%',
      height: '100%',
      overflow: 'hidden',
    }}
  >
    <MapView
      ref={this.setRef}
      onPress={this.onPress}
      onLongPress={this.onLongPress}
      style={{ width: '100%', height: '100%' }}
      zoomControlEnabled
      provider={Platform.OS === 'ios' ? 'google' : 'osmdroid'}
      moveOnMarkerPress={false}
      customMapStyle={[
        {
          stylers: [
            {
              visibility: 'off',
            },
          ],
        },
      ]}
      rotateEnabled={false}
      scrollEnabled={allowScaling}
      pitchEnabled={allowScaling}
      zoomTapEnabled={allowScaling}
      zoomEnabled={allowScaling}
      cacheEnabled={false}
      initialRegion={region}
      onRegionChangeComplete={this.onRegionChange}
      maxZoomLevel={Platform.OS === 'ios' ? maxZoom : Math.max(maxZoom, 10)}
      minZoomLevel={0}
    >
      <UrlTile
        urlTemplate={`${url}/{z}/{x}/{y}/`}
        maximumZ={maxZoom}
        tileSize={256}
      />
      {this.renderMarker()}
    </MapView>
  </View>
依赖项:

"react-native-maps-osmdroid": "^0.26.1-rc1",
"react-native": "0.62.2",


注意:在尝试google map类型之前,我尝试了Apple map,问题也出现了。

相机设置控制缩放级别。如前所述

请注意,使用相机时,iOS和Google地图上的MapKit有所不同 如何指定高度。对于跨平台应用程序,它是 需要分别指定缩放级别和高度

有关如何指定缩放级别的示例,请参见此处()。请参见下面同一示例中的一些代码:

<MapView
          provider={this.props.provider}
          ref={ref => {
            this.map = ref;
          }}
          style={styles.map}
          initialCamera={{
            center: {
              latitude: LATITUDE,
              longitude: LONGITUDE,
            },
            pitch: 45,
            heading: 90,
            altitude: 1000,
            zoom: 10,
          }}
        />
{
this.map=ref;
}}
style={style.map}
初始摄像机={{
中心:{
纬度:纬度,
经度:经度,
},
投球:45分,
标题:90,
海拔:1000,
缩放:10,
}}
/>

如上所述,对于谷歌地图,请使用
zoom
prop定义缩放级别。
minZoomLevel
maxZoomLevel
控制最小值和最大值。

刚刚注意到,如果您还提供了
区域,则
初始摄像头
将被忽略。请确保提供一个或另一个。

在我使用
UrlTile时,相机缩放似乎也不起作用,但感谢您提供的解决方案,我不知道相机功能,它有一些非常好的功能!
type Camera = {
    center: {
       latitude: number,
       longitude: number,
   },
   pitch: number,
   heading: number

   // Only on iOS MapKit, in meters. The property is ignored by Google Maps.
   altitude: number.

   // Only when using Google Maps.
   zoom: number
}
<MapView
          provider={this.props.provider}
          ref={ref => {
            this.map = ref;
          }}
          style={styles.map}
          initialCamera={{
            center: {
              latitude: LATITUDE,
              longitude: LONGITUDE,
            },
            pitch: 45,
            heading: 90,
            altitude: 1000,
            zoom: 10,
          }}
        />