2017-03-12 5 views
1

현재 React-native-maps를 사용하는 반응이있는 네이티브 앱에서 작업하고 있습니다. 현재 현재 왼쪽 상단 구석을 얻고 있습니다 (lat & long)와) (북 & 긴 오른쪽 하단 모서리React 네이티브 맵은 왼쪽 위 모서리와 오른쪽 아래 모서리 위도와 경도를 얻습니다.

<MapView.Animated 
     onRegionChange={this.onRegionChange.bind(this)} 
     showsUserLocation 
     initialRegion={{ 
      latitude: coords.latitude, 
      longitude: coords.longitude, 
      latitudeDelta: LATITUDE_DELTA, 
      longitudeDelta: LONGITUDE_DELTA, 
     }} 
     style={{ flex: 1 }} 
     > 
     <MapView.Marker 
      coordinate={{ latitude: coords.latitude, longitude: coords.longitude }} 
     > 
     <MapView.Callout style={{ position: 'relative', width: 150}}> 
     <PlaceCard /> 
     </MapView.Callout> 
    </MapView.Marker> 
</MapView.Animated> 

그 활용하는 방법에 대한 어떤 생각?!

답변

2

(REGION.latitude, REGION.longitude)이지도의 중심이고 델타가지도에 표시된 최소 및 최대 위도/경도 사이의 거리 (도) 인 경우 topLeft 및 bottomRight 점을 가져올 수 있어야합니다. 아래처럼 :

  { 
       latlng: { 
        latitude: REGION.latitude+(REGION.latitudeDelta/2), 
        longitude: REGION.longitude-(REGION.longitudeDelta/2) 
       }, 
       title:'topLeft' 

      }, 
      { 
       latlng: { 
        latitude: REGION.latitude-(REGION.latitudeDelta/2), 
        longitude: REGION.longitude+(REGION.longitudeDelta/2) 
       }, 
       title:'bottomRight' 

      } 
+0

왼쪽 위 또는 오른쪽 위? 그리고 오른쪽 아래 또는 아래쪽 왼쪽 ?? 델타를 어떻게 계산할 수 있습니까? –

+1

델타를 계산하려면이 링크가 유용 할 수 있습니다. https://github.com/airbnb/react-native-maps/issues/505. 위의 응답을 몇 가지 값 (음수 값 포함)으로 테스트하고 topLeft 및 bottomRight의 표시를 확인 표시합니다. –