@ReactProp(name = "region") public void setRegion(MapView mapView, @Nullable ReadableMap region) { if (region == null) return; AMap map = mapView.getMap(); Double lat = region.getDouble("latitude"); Double lng = region.getDouble("longitude"); Double lngDelta = region.getDouble("longitudeDelta"); Double latDelta = region.getDouble("latitudeDelta"); LatLngBounds bounds = new LatLngBounds( new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast ); if (mapView.getHeight() <= 0 || mapView.getWidth() <= 0) { map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), 10)); boundsToMove = bounds; } else { map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0)); } }
/** * 显示地理标记 * * @param mapView * @param array */ @ReactProp(name="marker") public void setMarker(MapView mapView, ReadableArray array) { Log.d(TAG, "marker:" + array); if (array != null) { for (int i = 0; i < array.size(); i++) { ReadableArray sub = array.getArray(i); //定义Maker坐标点 LatLng point = new LatLng(sub.getDouble(0), sub.getDouble(1)); //构建Marker图标 BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.icon_gcoding); //构建MarkerOption,用于在地图上添加Marker OverlayOptions option = new MarkerOptions() .position(point) .icon(bitmap) .draggable(true); //在地图上添加Marker,并显示 mapView.getMap().addOverlay(option); } } }
/** * Sets the user's location marker, if it has been enabled. * * @param map * @param cameraPosition */ @ReactProp(name = "cameraPosition") public void setCameraPosition(MapView map, ReadableMap cameraPosition) { float zoom = (float) cameraPosition.getDouble("zoom"); if (cameraPosition.hasKey("auto") && cameraPosition.getBoolean("auto")) { Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location == null) { return; } cameraUpdate = CameraUpdateFactory.newLatLngZoom( new LatLng(location.getLatitude(), location.getLongitude()), zoom ); map.getMapAsync(this); } else { cameraUpdate = CameraUpdateFactory.newLatLngZoom( new LatLng( cameraPosition.getDouble("latitude"), cameraPosition.getDouble("longitude") ), zoom ); map.getMapAsync(this); } }
/** * Adds marker icons to the map. * * @param map * @param markers */ @ReactProp(name = "markers") public void setMarkers(MapView map, ReadableArray markers) { this.markers = markers; map.getMapAsync(this); }
/** * Sets the user's location marker, if it has been enabled. * * @param showsUserLocation */ @ReactProp(name = "showsUserLocation") public void setShowsUserLocation(MapView map, boolean showsUserLocation) { this.showsUserLocation = showsUserLocation; map.getMapAsync(this); }
/** * Controls whether scroll gestures are enabled (default) or disabled. * * @param map * @param scrollGestures */ @ReactProp(name = "scrollGestures") public void setScrollGestures(MapView map, boolean scrollGestures) { this.scrollGestures = scrollGestures; map.getMapAsync(this); }
/** * Controls whether zoom gestures are enabled (default) or disabled. * * @param map * @param zoomGestures */ @ReactProp(name = "zoomGestures") public void setZoomGestures(MapView map, boolean zoomGestures) { this.zoomGestures = zoomGestures; map.getMapAsync(this); }
/** * Controls whether tilt gestures are enabled (default) or disabled. * * @param map * @param tiltGestures */ @ReactProp(name = "tiltGestures") public void setTiltGestures(MapView map, boolean tiltGestures) { this.tiltGestures = tiltGestures; map.getMapAsync(this); }
/** * Controls whether rotate gestures are enabled (default) or disabled. * * @param map * @param rotateGestures */ @ReactProp(name = "rotateGestures") public void setRotateGestures(MapView map, boolean rotateGestures) { this.rotateGestures = rotateGestures; map.getMapAsync(this); }
/** * Enables or disables the compass. * * @param map * @param compassButton */ @ReactProp(name = "compassButton") public void setCompassButton(MapView map, boolean compassButton) { this.compassButton = compassButton; map.getMapAsync(this); }
/** * Enables or disables the My Location button. * * @param map * @param myLocationButton */ @ReactProp(name = "myLocationButton") public void setMyLocationButton(MapView map, boolean myLocationButton) { this.myLocationButton = myLocationButton; map.getMapAsync(this); }
@ReactProp(name = "torchMode") public void toggleTorch(CameraView view, @Nullable Boolean flagValue) { if (flagValue) { view.setFlash(true); } else { view.setFlash(false); } }
@ReactProp(name = "values") public void setValues(Spinner view, ReadableArray values) { view.setValues(values); }
@ReactProp(name = "selected") public void setSelected(Spinner view, int selected) { view.setSelected(selected); }
@ReactProp(name = "viewFinderDisplay") public void setViewFinderDisplay(RNCameraView view, @Nullable Boolean viewFinderDisplay) { if(viewFinderDisplay != null) { view.setViewFinderDisplay(viewFinderDisplay); } }
@ReactProp(name = "viewFinderBackgroundColor") public void setViewFinderBackgroundColor(RNCameraView view, @Nullable String viewFinderBackgroundColor) { if (viewFinderBackgroundColor != null) { view.setMaskColor(viewFinderBackgroundColor); } }
@ReactProp(name = "viewFinderBorderColor") public void setViewFinderBorderColor(RNCameraView view, @Nullable String viewFinderBorderColor) { if (viewFinderBorderColor != null) { view.setBorderColor(viewFinderBorderColor); } }
@ReactProp(name = "viewFinderBorderWidth") public void setViewFinderBorderWidth(RNCameraView view, @Nullable Integer viewFinderBorderWidth) { if (viewFinderBorderWidth != null) { view.setBorderStrokeWidth(viewFinderBorderWidth); } }
@ReactProp(name = "viewFinderBorderLength") public void setViewFinderBorderLength(RNCameraView view, @Nullable Integer viewFinderBorderLength) { if (viewFinderBorderLength != null) { view.setBorderLineLength(viewFinderBorderLength); } }
@ReactProp(name = "viewFinderDrawLaser") public void setViewFinderDrawLaser(RNCameraView view, @Nullable Boolean viewFinderDrawLaser) { if (viewFinderDrawLaser != null) { view.setDrawLaser(viewFinderDrawLaser); } }
@ReactProp(name = "viewFinderLaserColor") public void setViewFinderLaserColor(RNCameraView view, @Nullable String viewFinderLaserColor) { if (viewFinderLaserColor != null) { view.setLaserColor(viewFinderLaserColor); } }
@ReactProp(name = "type") public void setCameraType(RNCameraView view, @Nullable String cameraType) { if (cameraType != null) { view.setCameraType(cameraType); } }
@ReactProp(name = "torchMode") public void setTorchMode(RNCameraView view, @Nullable String torchMode) { if (torchMode != null) { view.setTorchMode(torchMode); } }
@ReactProp(name = "autoFocus") public void setAutoFocus(RNCameraView view, @Nullable Boolean autoFocus) { if (autoFocus != null) { view.setAutoFocus(autoFocus); } }
@ReactProp(name = "mapType") public void setMapType(MapView mapView, @Nullable String mapType) { int typeId = MAP_TYPES.get(mapType); mapView.getMap().setMapType(typeId); }
@ReactProp(name = "startCapture") public void startCapture(CameraView view, @Nullable String flagValue) { if (flagValue.equals("true")) { view.takePicture(); } }
@ReactProp(name = "src") public void setSrc(AdView view, String src) { //Log.d("ReactAdMobManager", "inside set src"); }
@ReactProp(name = "radius", defaultInt = 0) public void setRadius(BlurryOverlayView view, int radius) { view.setRadiusAndUpdate(radius); }
@ReactProp(name = "sampling", defaultInt = 0) public void setSampling(BlurryOverlayView view, int sampling) { view.setSamplingAndUpdate(sampling); }
@ReactProp(name = "color") public void setColor(BlurryOverlayView view, String color) { view.setColorAndUpdate(color); }
@ReactProp(name = ViewProps.FONT_SIZE, defaultInt = 0) public void setTextSize(IconTextView view, Integer size) { Log.i("IconTextView", "setTextSize: "+ size + " | " + ViewProps.FONT_SIZE); view.setTextSize(size); }
@ReactProp(name = PROP_ICON) public void setText(IconTextView view, @Nullable String text) { Log.i("IconTextView", "setText: "+ text); view.setText(text); }
@ReactProp(name = PROP_COLOR, customType = "Color") public void setTextColor(IconTextView view, @Nullable Integer color) { Log.i("IconTextView", "setTextColor: " + color ); view.setTextColor(color); }
/** * Controls whether gestures by users are completely consumed by the map view when gestures are enabled (default YES). * * @param map * @param consumesGesturesInView */ @ReactProp(name = "consumesGesturesInView") public void setConsumesGesturesInView(MapView map, boolean consumesGesturesInView) { // Do nothing - this is an iOS feature that we're only implementing so that the Android // map package doesn't break. }
/** * 地图模式 * * @param mapView * @param type * 1. 普通 * 2.卫星 */ @ReactProp(name="mode", defaultInt = 1) public void setMode(MapView mapView, int type) { Log.i(TAG, "mode:" + type); mapView.getMap().setMapType(type); }
/** * 实时交通图 * * @param mapView * @param isEnabled */ @ReactProp(name="trafficEnabled", defaultBoolean = false) public void setTrafficEnabled(MapView mapView, boolean isEnabled) { Log.d(TAG, "trafficEnabled:" + isEnabled); mapView.getMap().setTrafficEnabled(isEnabled); }
/** * 实时道路热力图 * * @param mapView * @param isEnabled */ @ReactProp(name="heatMapEnabled", defaultBoolean = false) public void setHeatMapEnabled(MapView mapView, boolean isEnabled) { Log.d(TAG, "heatMapEnabled" + isEnabled); mapView.getMap().setBaiduHeatMapEnabled(isEnabled); }