2016-01-22 8 views
10

में Google मानचित्र मेरा लक्ष्य प्रतिक्रिया मूल में एक Google मानचित्र प्रदर्शित करना है। मैंने ऐसे उदाहरण देखे हैं जो Google मानचित्र एसडीके का उपयोग UIMapView या MapBox मानचित्र के साथ करते हैं, लेकिन यह वह नहीं है जिसे मैं ढूंढ रहा हूं।प्रतिक्रिया-मूल (आईओएस)

मुझे वर्तमान में कोई त्रुटि नहीं है। यहाँ मेरी कोड है:

index.ios.js

'use strict'; 
import React, { 
    AppRegistry, 
    Component, 
    StyleSheet, 
    Text, 
    View 
} from 'react-native'; 
import GoogleMaps from './ios/GoogleMaps.js'; 

class RCTGoogleMaps extends Component { 
    constructor(props) { 
     super(props); 
    } 

    render() { 
     return (
      <View style={styles.container}> 
       <GoogleMaps style={styles.map}/> 
      </View> 
     ); 
    } 
} 

const styles = StyleSheet.create({ 
    container: { 
     flex: 1, 
     justifyContent: 'center', 
     alignItems: 'center', 
     backgroundColor: '#F5FCFF' 
    }, 
    map: { 
     height: 500, 
     width: 300, 
     marginLeft: 50 
    } 
}); 

AppRegistry.registerComponent('RCTGoogleMaps',() => RCTGoogleMaps); 

ios/GoogleMaps.js

ios/RCTGoogleMapViewManager.h

#ifndef RCTGoogleMapViewManager_h 
#define RCTGoogleMapViewManager_h 

#import <Foundation/Foundation.h> 
#import "RCTViewManager.h" 
#import <UIKit/UIKit.h> 

@interface RCTGoogleMapViewManager : RCTViewManager<UITextViewDelegate> 
@end 

#endif /* RCTGoogleMapViewManager_h */ 

ios/GoogleMapViewManager.m

#import <Foundation/Foundation.h> 
#import "RCTGoogleMapViewManager.h" 
#import "RCTBridge.h" 
#import "RCTEventDispatcher.h" 
#import "UIView+React.h" 
@import GoogleMaps; 

@implementation RCTGoogleMapViewManager 
    RCT_EXPORT_MODULE() 

- (UIView *)view { 
    GMSMapView *mapView_; 
    // Create a GMSCameraPosition that tells the map to display the 
    // coordinate -33.86,151.20 at zoom level 6. 
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 
                  longitude:151.20 
                   zoom:6]; 
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
    mapView_.myLocationEnabled = YES; 
    UIView *newView_ = mapView_; 
    //self.view = mapView_; 

    // Creates a marker in the center of the map. 
    GMSMarker *marker = [[GMSMarker alloc] init]; 
    marker.position = CLLocationCoordinate2DMake(-33.86, 151.20); 
    marker.title = @"Sydney"; 
    marker.snippet = @"Australia"; 
    marker.map = mapView_; 
    return newView_; 
} 

RCT_EXPORT_VIEW_PROPERTY(text, NSString) 

@end 

घटक के चारों ओर एक लाल सीमा है, लेकिन अंदर कुछ भी प्रदर्शित नहीं होता है। मैं मूल प्रतिक्रिया करने के लिए नया हूं और स्टैक ओवरफ्लो में नया हूं। दुर्भाग्यवश, जब तक कि मेरे पास अधिक प्रतिष्ठा न हो, वे मुझे एक स्क्रीनशॉट अपलोड नहीं करने देंगे।

एक पंक्ति है जिसे मुझे बंद होने का संदेह है, लेकिन मुझे पता नहीं है कि इसे कैसे बदला जाए। RCTGoogleMapViewManager.h में पंक्ति # 8 कहता है, "@interface RCTGoogleMapViewManager: RCTViewManager"। मैंने अन्य कस्टम घटकों के लिए UITextViewDelegates का उपयोग किया है, लेकिन यह नक्शा टेक्स्ट व्यू नहीं है। यह हो सकता है, लेकिन मुझे कोई सुराग नहीं है।

किसी भी मदद की सराहना की जाएगी।

उत्तर

0

क्या आपने https://github.com/peterprokop/ReactNativeGoogleMaps चेक आउट किया है? यह काफी प्रारंभिक दिखता है लेकिन यह अभी भी आपके लिए बहुत उपयोगी होना चाहिए।

2

यदि घटक के चारों ओर एक लाल सीमा है लेकिन अंदर कुछ भी प्रदर्शित नहीं होता है, तो इसका मतलब है कि आपके पास कोई पुस्तकालय सही ढंग से लिंक नहीं है।

यहां दस्तावेज़ों को देखें: http://facebook.github.io/react-native/releases/0.25/docs/linking-libraries-ios.html