Skip to content

Commit aaccf37

Browse files
committed
Merge branch 'main' into upgrade-android-sdk-to-200.7
2 parents 53b1e86 + 3b993a0 commit aaccf37

File tree

10 files changed

+116
-45
lines changed

10 files changed

+116
-45
lines changed

arcgis_map_sdk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Checkout the example app `example/lib/main.dart` for more details.
108108
| addViewPadding ||||
109109
| toggleBaseMap ||||
110110
| moveCamera ||||
111-
| moveCameraToPoints | |||
111+
| moveCameraToPoints | |||
112112
| use AutoPanMode | |||
113113
| exportImage | |||
114114
| zoomIn ||||

arcgis_map_sdk/lib/src/arcgis_map_controller.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ class ArcgisMapController {
183183
);
184184
}
185185

186+
/// Moves the camera to the provided [points] and makes sure that all of
187+
/// them are visible.
188+
/// Currently, [padding] is only supported on mobile.
186189
Future<void> moveCameraToPoints({
187190
required List<LatLng> points,
188191
double? padding,

arcgis_map_sdk_ios/ios/Classes/ArcgisMapView.swift

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
7575
mapView = AGSMapView.init(frame: frame)
7676

7777
super.init()
78-
78+
7979
if let isAttributionTextVisible = mapOptions.isAttributionTextVisible {
8080
mapView.isAttributionTextVisible = isAttributionTextVisible
8181
}
@@ -180,12 +180,12 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
180180
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
181181
return
182182
}
183-
183+
184184
guard let lodFactor = args["lodFactor"] as? Int else {
185185
result(FlutterError(code: "missing_data", message: "lodFactor not provided", details: nil))
186186
return
187187
}
188-
188+
189189
let currentZoomLevel = convertScaleToZoomLevel(mapView.mapScale)
190190
let totalZoomLevel = currentZoomLevel + lodFactor
191191
if (totalZoomLevel > convertScaleToZoomLevel(map.maxScale)) {
@@ -207,12 +207,12 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
207207
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
208208
return
209209
}
210-
210+
211211
guard let lodFactor = args["lodFactor"] as? Int else {
212212
result(FlutterError(code: "missing_data", message: "lodFactor not provided", details: nil))
213213
return
214214
}
215-
215+
216216
let currentZoomLevel = convertScaleToZoomLevel(mapView.mapScale)
217217
let totalZoomLevel = currentZoomLevel - lodFactor
218218
if (totalZoomLevel < convertScaleToZoomLevel(map.minScale)) {
@@ -223,13 +223,13 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
223223
result(success)
224224
}
225225
}
226-
226+
227227
private func onRotate(_ call: FlutterMethodCall, _ result:@escaping FlutterResult) {
228228
guard let angleDouble = call.arguments as? Double else {
229229
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
230230
return
231231
}
232-
232+
233233
mapView.setViewpointRotation(angleDouble) { success in
234234
result(success)
235235
}
@@ -240,7 +240,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
240240
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
241241
return
242242
}
243-
243+
244244
do {
245245
let padding: ViewPadding = try JsonUtil.objectOfJson(args)
246246

@@ -269,7 +269,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
269269
let animationOptions: AnimationOptions? = animationDict == nil ? nil : try JsonUtil.objectOfJson(animationDict!)
270270

271271
let scale: Double
272-
272+
273273
if let zoomLevel = zoomLevel {
274274
scale = convertZoomLevelToMapScale(zoomLevel)
275275
} else {
@@ -322,26 +322,26 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
322322
return
323323
}
324324

325-
325+
326326
let existingIds = defaultGraphicsOverlay.graphics.compactMap { object in
327327
let graphic = object as! AGSGraphic
328328
return graphic.attributes["id"] as? String
329329
}
330-
330+
331331
let hasExistingGraphics = newGraphics.contains(where: { object in
332332
let graphic = object
333333
guard let id = graphic.attributes["id"] as? String else {
334334
return false
335335
}
336-
336+
337337
return existingIds.contains(id)
338338
})
339-
339+
340340
if(hasExistingGraphics) {
341341
result(false)
342342
return
343343
}
344-
344+
345345
// addObjects causes an internal exceptions this is why we add
346346
// them in this for loop instead.
347347
// ArcGis is the best <3.
@@ -356,7 +356,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
356356
result(FlutterError(code: "missing_data", message: "graphicId not provided", details: nil))
357357
return
358358
}
359-
359+
360360
let newGraphics = defaultGraphicsOverlay.graphics.filter({ element in
361361
let graphic = element as! AGSGraphic
362362
let id = graphic.attributes["id"] as? String
@@ -365,7 +365,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
365365

366366
defaultGraphicsOverlay.graphics.removeAllObjects()
367367
defaultGraphicsOverlay.graphics.addObjects(from: newGraphics)
368-
368+
369369
result(true)
370370
}
371371

@@ -374,9 +374,9 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
374374
result(FlutterError(code: "missing_data", message: "baseMapString not provided", details: nil))
375375
return
376376
}
377-
377+
378378
map.basemap = AGSBasemap(style: parseBaseMapStyle(baseMapString))
379-
379+
380380
result(true)
381381
}
382382

@@ -394,12 +394,12 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
394394
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
395395
return
396396
}
397-
397+
398398
guard let enabled = args["enabled"] as? Bool else {
399399
result(FlutterError(code: "missing_data", message: "enabled arguments", details: nil))
400400
return
401401
}
402-
402+
403403
setMapInteractive(enabled)
404404
result(true)
405405
}
@@ -514,7 +514,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
514514
mapView.locationDisplay.autoPanMode = autoPanMode
515515
result(true)
516516
}
517-
517+
518518
private func onGetAutoPanMode(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
519519
// autoPanMode.rawValue is any of [0; 3]:
520520
// https://developers.arcgis.com/ios/api-reference/_a_g_s_location_display_8h.html
@@ -524,17 +524,17 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
524524
}
525525
return result(stringName)
526526
}
527-
527+
528528
private func onSetWanderExtentFactor(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
529529
guard let factor = call.arguments as? Double else {
530530
result(FlutterError(code: "missing_data", message: "Invalid argument, expected an WanderExtentFactor as Double.", details: nil))
531531
return
532532
}
533-
533+
534534
mapView.locationDisplay.wanderExtentFactor = Float(factor)
535535
result(true)
536536
}
537-
537+
538538
private func onGetWanderExtentFactor(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
539539
return result(mapView.locationDisplay.wanderExtentFactor)
540540
}
@@ -561,13 +561,13 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
561561
result(FlutterError(code: "invalid_data", message: "Unknown data source type \(String(describing: type))", details: nil))
562562
}
563563
}
564-
564+
565565
private func onUpdateIsAttributionTextVisible(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
566566
guard let isVisible = call.arguments as? Bool else {
567567
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
568568
return
569569
}
570-
570+
571571
mapView.isAttributionTextVisible = isVisible
572572
result(true)
573573
}

arcgis_map_sdk_web/assets/arcgis_js_api_custom_build/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arcgis_map_sdk_web/lib/arcgis_map_web_js.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ abstract class JsAttributes {
183183
}
184184

185185
/// https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html
186-
@JS("esri.geometry.Extent")
186+
@JS("esri.core.geometry.Extent")
187187
abstract class JsExtent {
188188
/// https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#contains
189189
external bool contains(dynamic geometry);
@@ -196,6 +196,10 @@ abstract class JsExtent {
196196
external double get height;
197197

198198
external double get width;
199+
200+
external factory JsExtent(dynamic map);
201+
202+
external JsExtent expand(double ratio);
199203
}
200204

201205
/// https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html

arcgis_map_sdk_web/lib/src/arcgis_map_sdk_web.dart

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,27 @@ class ArcgisMapWeb extends ArcgisMapPlatform {
4242
}
4343

4444
@override
45-
Future<void> init(int mapId) async {
46-
await _hasScriptLoaded.future;
47-
_map(mapId).init();
45+
Future<void> setMethodCallHandler({
46+
required int mapId,
47+
required Future<dynamic> Function(MethodCall) onCall,
48+
}) async {
49+
// No-Op
4850
}
4951

5052
@override
51-
Future<void> setMethodCallHandler({
53+
Future<void> moveCameraToPoints({
54+
required List<LatLng> points,
5255
required int mapId,
53-
required Future<dynamic> Function(MethodCall) onCall,
54-
}) async {}
56+
double? padding,
57+
}) {
58+
return _map(mapId).moveCameraToPoints(points: points, padding: padding);
59+
}
60+
61+
@override
62+
Future<void> init(int mapId) async {
63+
await _hasScriptLoaded.future;
64+
_map(mapId).init();
65+
}
5566

5667
@override
5768
Future<void> moveCamera({

arcgis_map_sdk_web/lib/src/arcgis_map_web_controller.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,17 @@ class ArcgisMapWebController {
412412
);
413413
}
414414

415+
Future<void> moveCameraToPoints({
416+
required List<LatLng> points,
417+
double? padding,
418+
}) async {
419+
await _layerController!.moveCameraToPoints(
420+
points: points,
421+
padding: padding,
422+
view: _activeView!,
423+
);
424+
}
425+
415426
Future<void> moveCamera({
416427
required LatLng point,
417428
double? zoomLevel,

arcgis_map_sdk_web/lib/src/layer_controller.dart

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:math' as math;
23

34
import 'package:arcgis_map_sdk_platform_interface/arcgis_map_sdk_platform_interface.dart';
45
import 'package:arcgis_map_sdk_web/arcgis_map_web_js.dart';
@@ -828,6 +829,50 @@ class LayerController {
828829
return zoom >= minZoom && zoom <= maxZoom;
829830
}
830831

832+
Future<void> moveCameraToPoints({
833+
required List<LatLng> points,
834+
double? padding,
835+
AnimationOptions? animationOptions,
836+
required JsView view,
837+
}) async {
838+
// Compute bounding coordinates for the list of points.
839+
double minLat = double.infinity;
840+
double minLon = double.infinity;
841+
double maxLat = -double.infinity;
842+
double maxLon = -double.infinity;
843+
844+
for (final point in points) {
845+
minLat = math.min(minLat, point.latitude);
846+
maxLat = math.max(maxLat, point.latitude);
847+
minLon = math.min(minLon, point.longitude);
848+
maxLon = math.max(maxLon, point.longitude);
849+
}
850+
851+
final extentMap = JsExtent(
852+
jsify({
853+
'xmin': minLon,
854+
'ymin': minLat,
855+
'xmax': maxLon,
856+
'ymax': maxLat,
857+
'spatialReference': {'wkid': 4326},
858+
}),
859+
);
860+
861+
final target = {
862+
'target': extentMap,
863+
};
864+
865+
final targetOptions = <String, dynamic>{};
866+
if (animationOptions != null) {
867+
targetOptions.addAll({
868+
'duration': animationOptions.duration,
869+
'easing': animationOptions.animationCurve.value,
870+
});
871+
}
872+
873+
await view.goTo(jsify(target), jsify(targetOptions)).toFuture();
874+
}
875+
831876
/// Go to the given point and zoom if wanted
832877
Future<void> moveCamera({
833878
required LatLng point,

arcgis_webpack/src/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
1313
import Basemap from "@arcgis/core/Basemap";
1414
import SceneLayer from "@arcgis/core/layers/SceneLayer";
1515
import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer";
16-
16+
import Extent from "@arcgis/core/geometry/Extent";
1717
window.esri = {
1818
'core': {
1919
'Map': Map,
@@ -24,6 +24,7 @@ window.esri = {
2424
},
2525
'geometry': {
2626
'Point': Point,
27+
'Extent': Extent,
2728
},
2829
'widgets': {
2930
'Attribution': Attribution,

example/lib/main.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -735,16 +735,12 @@ class _ExampleMapState extends State<ExampleMap> {
735735
onPressed: () => _controller?.retryLoad(),
736736
child: const Text('Reload map'),
737737
),
738-
if (!kIsWeb)
739-
ElevatedButton(
740-
onPressed: () => _makePolylineVisible(
741-
points: [
742-
_firstPinCoordinates,
743-
_secondPinCoordinates
744-
],
745-
),
746-
child: const Text('Zoom to polyline'),
738+
ElevatedButton(
739+
onPressed: () => _makePolylineVisible(
740+
points: [_firstPinCoordinates, _secondPinCoordinates],
747741
),
742+
child: const Text('Zoom to polyline'),
743+
),
748744
],
749745
),
750746
),

0 commit comments

Comments
 (0)