|
15 | 15 | import com.facebook.react.uimanager.UIManagerModule; |
16 | 16 |
|
17 | 17 |
|
| 18 | +import org.osmdroid.api.IGeoPoint; |
| 19 | + |
18 | 20 | import java.io.Closeable; |
19 | 21 | import java.io.IOException; |
20 | 22 |
|
@@ -132,39 +134,34 @@ public static void closeQuietly(Closeable closeable) { |
132 | 134 | // }); |
133 | 135 | // } |
134 | 136 |
|
135 | | -// @ReactMethod |
136 | | -// public void getCamera(final int tag, final Promise promise) { |
137 | | -// final ReactApplicationContext context = getReactApplicationContext(); |
138 | | -// |
139 | | -// UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class); |
140 | | -// uiManager.addUIBlock(new UIBlock() |
141 | | -// { |
142 | | -// @Override |
143 | | -// public void execute(NativeViewHierarchyManager nvhm) |
144 | | -// { |
145 | | -// OsmMapView view = (OsmMapView) nvhm.resolveView(tag); |
146 | | -// if (view == null) { |
147 | | -// promise.reject("AirMapView not found"); |
148 | | -// return; |
149 | | -// } |
150 | | -// |
151 | | -// |
152 | | -// CameraPosition position = view.map.getCameraPosition(); |
153 | | -// |
154 | | -// WritableMap centerJson = new WritableNativeMap(); |
155 | | -// centerJson.putDouble("latitude", position.target.latitude); |
156 | | -// centerJson.putDouble("longitude", position.target.longitude); |
157 | | -// |
158 | | -// WritableMap cameraJson = new WritableNativeMap(); |
159 | | -// cameraJson.putMap("center", centerJson); |
160 | | -// cameraJson.putDouble("heading", (double)position.bearing); |
161 | | -// cameraJson.putDouble("zoom", (double)position.zoom); |
162 | | -// cameraJson.putDouble("pitch", (double)position.tilt); |
163 | | -// |
164 | | -// promise.resolve(cameraJson); |
165 | | -// } |
166 | | -// }); |
167 | | -// } |
| 137 | + @ReactMethod |
| 138 | + public void getCamera(final int tag, final Promise promise) { |
| 139 | + final ReactApplicationContext context = getReactApplicationContext(); |
| 140 | + |
| 141 | + UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class); |
| 142 | + uiManager.addUIBlock(new UIBlock() |
| 143 | + { |
| 144 | + @Override |
| 145 | + public void execute(NativeViewHierarchyManager nvhm) |
| 146 | + { |
| 147 | + OsmMapView view = (OsmMapView) nvhm.resolveView(tag); |
| 148 | + if (view == null) { |
| 149 | + promise.reject("AirMapView not found", "AirMapView not found"); |
| 150 | + return; |
| 151 | + } |
| 152 | + |
| 153 | + IGeoPoint position = view.getCameraPosition(); |
| 154 | + |
| 155 | + WritableMap centerJson = new WritableNativeMap(); |
| 156 | + centerJson.putDouble("latitude", position.getLatitude()); |
| 157 | + centerJson.putDouble("longitude", position.getLongitude()); |
| 158 | + |
| 159 | + WritableMap cameraJson = new WritableNativeMap(); |
| 160 | + cameraJson.putMap("center", centerJson); |
| 161 | + promise.resolve(cameraJson); |
| 162 | + } |
| 163 | + }); |
| 164 | + } |
168 | 165 |
|
169 | 166 | // @ReactMethod |
170 | 167 | // public void pointForCoordinate(final int tag, ReadableMap coordinate, final Promise promise) { |
@@ -253,7 +250,7 @@ public void getMapBoundaries(final int tag, final Promise promise) { |
253 | 250 | public void execute(NativeViewHierarchyManager nvhm) { |
254 | 251 | OsmMapView view = (OsmMapView) nvhm.resolveView(tag); |
255 | 252 | if (view == null) { |
256 | | - promise.reject("AirMapView not found"); |
| 253 | + promise.reject("AirMapView not found", "AirMapView not found"); |
257 | 254 | return; |
258 | 255 | } |
259 | 256 |
|
|
0 commit comments