Skip to content

Instantly share code, notes, and snippets.

@jondot
Created Jan 19, 2016
Embed
What would you like to do?
// MapView.js
var React = require('react-native');
var { View, Text, TouchableOpacity, requireNativeComponent } = React;
var RCTMapperManager = require('NativeModules').MapperManager;
class MapView extends React.Component {
foobar(){
RCTMapperManager.logstuff(
React.findNodeHandle(this),
"hello"
);
}
render() {
return (
<View>
<TouchableOpacity onPress={this.foobar.bind(this)} >
<Text> Foobarmap </Text>
</TouchableOpacity>
<RCTMap ref="map" {...this.props} />
</View>
)
}
}
MapView.propTypes = {
/**
* When this property is set to `true` and a valid camera is associated
* with the map, the camera’s pitch angle is used to tilt the plane
* of the map. When this property is set to `false`, the camera’s pitch
* angle is ignored and the map is always displayed as if the user
* is looking straight down onto it.
*/
pitchEnabled: React.PropTypes.bool,
};
var RCTMap = requireNativeComponent('RCTMapper', MapView);
module.exports = MapView;
//
// RCTMapManager.m
// keyboardanim
//
// Created by Dotan Nahum on 1/19/16.
// Copyright © 2016 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
// RCTMapManager.m
#import <MapKit/MapKit.h>
#import "RCTViewManager.h"
#import "RCTUIManager.h"
@interface RCTMapperManager : RCTViewManager
@end
@implementation RCTMapperManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [[MKMapView alloc] init];
}
RCT_EXPORT_VIEW_PROPERTY(pitchEnabled, BOOL)
RCT_EXPORT_METHOD(logstuff:(nonnull NSNumber *)reactTag
str:(NSString *)str)
{
NSLog(@" with tag #%@", reactTag);
[self.bridge.uiManager addUIBlock:
^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
UIView *view = viewRegistry[reactTag];
NSLog(@" with view #%@", view);
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment