Commit 1f632d25 authored by Qiu Xiang's avatar Qiu Xiang

添加更多显示控制

parent 4250b9fd
...@@ -2,6 +2,7 @@ package com.qiuxiang; ...@@ -2,6 +2,7 @@ package com.qiuxiang;
import com.amap.api.maps.AMap; import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdateFactory; import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.model.MyLocationStyle;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.SimpleViewManager; import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
...@@ -14,8 +15,7 @@ class AMapViewManager extends SimpleViewManager<AMapView> { ...@@ -14,8 +15,7 @@ class AMapViewManager extends SimpleViewManager<AMapView> {
"standard", AMap.MAP_TYPE_NORMAL, "standard", AMap.MAP_TYPE_NORMAL,
"satellite", AMap.MAP_TYPE_SATELLITE, "satellite", AMap.MAP_TYPE_SATELLITE,
"navigation", AMap.MAP_TYPE_NAVI, "navigation", AMap.MAP_TYPE_NAVI,
"night", AMap.MAP_TYPE_NIGHT, "night", AMap.MAP_TYPE_NIGHT
"bus", AMap.MAP_TYPE_BUS
); );
@Override @Override
...@@ -30,6 +30,9 @@ class AMapViewManager extends SimpleViewManager<AMapView> { ...@@ -30,6 +30,9 @@ class AMapViewManager extends SimpleViewManager<AMapView> {
@ReactProp(name = "showsUserLocation") @ReactProp(name = "showsUserLocation")
public void setMyLocationEnabled(AMapView view, boolean enabled) { public void setMyLocationEnabled(AMapView view, boolean enabled) {
MyLocationStyle locationStyle = new MyLocationStyle();
locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_SHOW);
view.map.setMyLocationStyle(locationStyle);
view.map.setMyLocationEnabled(enabled); view.map.setMyLocationEnabled(enabled);
} }
...@@ -38,6 +41,11 @@ class AMapViewManager extends SimpleViewManager<AMapView> { ...@@ -38,6 +41,11 @@ class AMapViewManager extends SimpleViewManager<AMapView> {
view.map.showIndoorMap(show); view.map.showIndoorMap(show);
} }
@ReactProp(name = "showsIndoorSwitch")
public void setIndoorSwitchEnabled(AMapView view, boolean show) {
view.ui.setIndoorSwitchEnabled(show);
}
@ReactProp(name = "showsBuildings") @ReactProp(name = "showsBuildings")
public void showBuildings(AMapView view, boolean show) { public void showBuildings(AMapView view, boolean show) {
view.map.showBuildings(show); view.map.showBuildings(show);
...@@ -53,12 +61,12 @@ class AMapViewManager extends SimpleViewManager<AMapView> { ...@@ -53,12 +61,12 @@ class AMapViewManager extends SimpleViewManager<AMapView> {
view.ui.setCompassEnabled(show); view.ui.setCompassEnabled(show);
} }
@ReactProp(name = "showZoomControls") @ReactProp(name = "showsZoomControls")
public void setZoomControlsEnabled(AMapView view, boolean enabled) { public void setZoomControlsEnabled(AMapView view, boolean enabled) {
view.ui.setZoomControlsEnabled(enabled); view.ui.setZoomControlsEnabled(enabled);
} }
@ReactProp(name = "showScale") @ReactProp(name = "showsScale")
public void setScaleControlsEnabled(AMapView view, boolean enabled) { public void setScaleControlsEnabled(AMapView view, boolean enabled) {
view.ui.setScaleControlsEnabled(enabled); view.ui.setScaleControlsEnabled(enabled);
} }
...@@ -112,4 +120,9 @@ class AMapViewManager extends SimpleViewManager<AMapView> { ...@@ -112,4 +120,9 @@ class AMapViewManager extends SimpleViewManager<AMapView> {
public void setRotateGesturesEnabled(AMapView view, boolean enabled) { public void setRotateGesturesEnabled(AMapView view, boolean enabled) {
view.ui.setRotateGesturesEnabled(enabled); view.ui.setRotateGesturesEnabled(enabled);
} }
@ReactProp(name = "tiltEnabled")
public void setTiltGesturesEnabled(AMapView view, boolean enabled) {
view.ui.setTiltGesturesEnabled(enabled);
}
} }
import {requireNativeComponent} from 'react-native' import {PropTypes} from 'react'
import {View} from 'react-native' import {requireNativeComponent, View} from 'react-native'
export default requireNativeComponent('AMapView', { export default requireNativeComponent('AMapView', {
name: 'AMapView', name: 'AMapView',
propTypes: { propTypes: {
...View.propTypes, ...View.propTypes,
showsUserLocation: PropTypes.bool,
showsIndoorMap: PropTypes.bool,
showsIndoorSwitch: PropTypes.bool,
showsBuildings: PropTypes.bool,
showsMapText: PropTypes.bool,
showsCompass: PropTypes.bool,
showsZoomControls: PropTypes.bool,
showsScale: PropTypes.bool,
showsMyLocationButton: PropTypes.bool,
showsTraffic: PropTypes.bool,
mapTextZIndex: PropTypes.number,
maxZoomLevel: PropTypes.number,
minZoomLevel: PropTypes.number,
zoomLevel: PropTypes.number,
mapType: PropTypes.string,
zoomEnabled: PropTypes.bool,
scrollEnabled: PropTypes.bool,
rotateEnabled: PropTypes.bool,
tiltEnabled: PropTypes.bool,
}, },
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment