Skip to content

web-fixes #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
ec61e1b
catch exceptions while parsing and fix poliline on mobile
JulianBissekkou Nov 26, 2023
8bcefcd
add missing return
JulianBissekkou Nov 27, 2023
f1187f3
initial draft on iOS
JulianBissekkou Nov 26, 2023
94cc4a9
add symbol methods to controller
JulianBissekkou Nov 27, 2023
e66d60f
parse symbol
JulianBissekkou Nov 27, 2023
a5c6a29
implement useCourseSymbolOnMovement
JulianBissekkou Nov 27, 2023
c0a6e9b
implement new type of location display data source
JulianBissekkou Nov 27, 2023
d10fe1c
implement feature
sbergmair Nov 27, 2023
5808386
implement feature
sbergmair Nov 27, 2023
de8bb70
add example on button click
sbergmair Nov 27, 2023
f6f2fd5
add support for local asset android
sbergmair Nov 28, 2023
694d29d
add support for local asset android
sbergmair Nov 28, 2023
e2b224c
fix logic
sbergmair Nov 28, 2023
afb3f70
implement iOS
sbergmair Nov 28, 2023
91d8f1c
reformat
sbergmair Nov 28, 2023
2313fb2
review
sbergmair Nov 28, 2023
9674db1
Merge branch 'move_camera_and_zoom_to_provided_positions' into add_lo…
sbergmair Nov 28, 2023
80c13fe
update README.md and add button for example only on mobile
sbergmair Nov 28, 2023
5d8f9e5
Merge branch 'move_camera_and_zoom_to_provided_positions' into add_lo…
sbergmair Nov 28, 2023
df29f97
finish iOS location indicator impl
JulianBissekkou Nov 28, 2023
b820ef7
Merge branch 'zoom_camera_and_add_local_asset_support' into all_featu…
sbergmair Nov 29, 2023
65ac0e5
export
sbergmair Nov 29, 2023
e9d653f
Merge branch 'controller_reload_mapstatus_callback' into all_features…
sbergmair Nov 29, 2023
1c1da38
Merge branch 'controller_reload_mapstatus_callback' into all_features…
sbergmair Nov 29, 2023
eca8c59
implement android
JulianBissekkou Nov 29, 2023
7d164d9
Merge remote-tracking branch 'upstream/53-support-basic-current-locat…
sbergmair Nov 29, 2023
9fefbbf
merge indicator
sbergmair Nov 29, 2023
b75883a
fix android
sbergmair Nov 29, 2023
89fab34
try to fix wrong initial scale
sbergmair Nov 29, 2023
0ee9e3e
implement licenseKey and make apiKey optional
JulianBissekkou Nov 29, 2023
5ca9ec6
print statement
sbergmair Nov 29, 2023
3db2250
Merge remote-tracking branch 'upstream/62-add-option-to-set-license-k…
sbergmair Nov 29, 2023
1f42221
try to fix zoom
sbergmair Nov 29, 2023
cdd1562
fix zoom gets not initialized correctly
sbergmair Nov 30, 2023
9f2d4aa
remove print
sbergmair Nov 30, 2023
d872d47
fix android error parsing symbol and iOS zoom
sbergmair Nov 30, 2023
36d8a3a
fix bug for manual location source on android
JulianBissekkou Nov 30, 2023
a1aacd9
Merge remote-tracking branch 'upstream/53-support-basic-current-locat…
sbergmair Nov 30, 2023
a5cafed
revert changes
sbergmair Nov 30, 2023
4f16097
typo
sbergmair Nov 30, 2023
a8459fc
fix NaN android getMapScale
sbergmair Nov 30, 2023
4fd2dde
fix
sbergmair Nov 30, 2023
cce9a4f
correct round
sbergmair Nov 30, 2023
617c89b
remove web sdk
JulianBissekkou Dec 6, 2023
9b11dc0
Merge branch 'main' into all_features_iteration_4-5
sbergmair Feb 26, 2024
2770701
format
sbergmair Feb 26, 2024
1860923
fix merge
sbergmair Feb 26, 2024
5e87aa4
fix ios build
JulianBissekkou Feb 27, 2024
927dc6c
remove duplicate declaration
sbergmair Feb 27, 2024
77f82af
Merge remote-tracking branch 'origin/all_features_iteration_4-5' into…
sbergmair Feb 27, 2024
3e6dc57
Merge branch 'main' into all_features_iteration_4-5
sbergmair Apr 22, 2024
3836074
remove newline
sbergmair Apr 22, 2024
de35692
Add isAttributionTextVisible to hide map attribution
JeanTapped May 24, 2024
92fc24b
Add isAttributionTextVisible for iOS
JeanTapped May 27, 2024
ae8f01a
Add dependency_overrides
JeanTapped May 27, 2024
e941111
implement changing attribution text
JulianBissekkou May 30, 2024
89df531
Merge branch 'hide_map_attribution' into all_features_iteration_4-5
JulianBissekkou May 30, 2024
5050ba4
implement image-export
JulianBissekkou Jul 29, 2024
0dad33b
add layer status observation
JulianBissekkou Aug 12, 2024
77b4add
remove map status observeration
JulianBissekkou Aug 12, 2024
fb2efba
implement image export on android
JulianBissekkou Aug 12, 2024
58f038b
update readme
JulianBissekkou Aug 12, 2024
1c5b993
update docs
JulianBissekkou Aug 12, 2024
fd90f3d
Merge branch 'image-export' into all_features_iteration_4-5
JulianBissekkou Aug 12, 2024
f73dcb4
Merge branch 'refs/heads/main' into all_features_iteration_4-5
sbergmair Aug 22, 2024
aba1f5d
Merge branch 'main' into all_features_iteration_4-5
JulianBissekkou Aug 22, 2024
443417a
fix duplicate code
JulianBissekkou Aug 22, 2024
a50622b
specify android namespace
JulianBissekkou Oct 15, 2024
9f5f2c4
Merge branch 'specify-android-namespace' into all_features_iteration_4-5
JulianBissekkou Oct 15, 2024
ba8c1ac
Merge remote-tracking branch 'origin/main' into all_features_iteratio…
JulianBissekkou Feb 4, 2025
77acd84
Merge branch 'main' into all_features_iteration_4-5
JulianBissekkou Feb 4, 2025
12a1a48
cleanup
JulianBissekkou Feb 4, 2025
64349db
override setMethodCallHandler
JulianBissekkou Mar 3, 2025
bd9d954
remove workaround that disbales web
JulianBissekkou Mar 3, 2025
72fa8b4
Add moveCameraToPoints method for web platform
JulianBissekkou Mar 3, 2025
9d8130b
Update documentation
JulianBissekkou Apr 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions arcgis_map_sdk_ios/ios/Classes/ArcgisMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
mapView = AGSMapView.init(frame: frame)

super.init()

if let isAttributionTextVisible = mapOptions.isAttributionTextVisible {
mapView.isAttributionTextVisible = isAttributionTextVisible
}
Expand Down Expand Up @@ -180,12 +180,12 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
return
}

guard let lodFactor = args["lodFactor"] as? Int else {
result(FlutterError(code: "missing_data", message: "lodFactor not provided", details: nil))
return
}

let currentZoomLevel = convertScaleToZoomLevel(mapView.mapScale)
let totalZoomLevel = currentZoomLevel + lodFactor
if (totalZoomLevel > convertScaleToZoomLevel(map.maxScale)) {
Expand All @@ -207,12 +207,12 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
return
}

guard let lodFactor = args["lodFactor"] as? Int else {
result(FlutterError(code: "missing_data", message: "lodFactor not provided", details: nil))
return
}

let currentZoomLevel = convertScaleToZoomLevel(mapView.mapScale)
let totalZoomLevel = currentZoomLevel - lodFactor
if (totalZoomLevel < convertScaleToZoomLevel(map.minScale)) {
Expand All @@ -223,13 +223,13 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
result(success)
}
}

private func onRotate(_ call: FlutterMethodCall, _ result:@escaping FlutterResult) {
guard let angleDouble = call.arguments as? Double else {
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
return
}

mapView.setViewpointRotation(angleDouble) { success in
result(success)
}
Expand All @@ -240,7 +240,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
return
}

do {
let padding: ViewPadding = try JsonUtil.objectOfJson(args)

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

let scale: Double

if let zoomLevel = zoomLevel {
scale = convertZoomLevelToMapScale(zoomLevel)
} else {
Expand Down Expand Up @@ -322,26 +322,26 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
return
}


let existingIds = defaultGraphicsOverlay.graphics.compactMap { object in
let graphic = object as! AGSGraphic
return graphic.attributes["id"] as? String
}

let hasExistingGraphics = newGraphics.contains(where: { object in
let graphic = object
guard let id = graphic.attributes["id"] as? String else {
return false
}

return existingIds.contains(id)
})

if(hasExistingGraphics) {
result(false)
return
}

// addObjects causes an internal exceptions this is why we add
// them in this for loop instead.
// ArcGis is the best <3.
Expand All @@ -356,7 +356,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
result(FlutterError(code: "missing_data", message: "graphicId not provided", details: nil))
return
}

let newGraphics = defaultGraphicsOverlay.graphics.filter({ element in
let graphic = element as! AGSGraphic
let id = graphic.attributes["id"] as? String
Expand All @@ -365,7 +365,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {

defaultGraphicsOverlay.graphics.removeAllObjects()
defaultGraphicsOverlay.graphics.addObjects(from: newGraphics)

result(true)
}

Expand All @@ -374,9 +374,9 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
result(FlutterError(code: "missing_data", message: "baseMapString not provided", details: nil))
return
}

map.basemap = AGSBasemap(style: parseBaseMapStyle(baseMapString))

result(true)
}

Expand All @@ -394,12 +394,12 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
return
}

guard let enabled = args["enabled"] as? Bool else {
result(FlutterError(code: "missing_data", message: "enabled arguments", details: nil))
return
}

setMapInteractive(enabled)
result(true)
}
Expand Down Expand Up @@ -514,7 +514,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
mapView.locationDisplay.autoPanMode = autoPanMode
result(true)
}

private func onGetAutoPanMode(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
// autoPanMode.rawValue is any of [0; 3]:
// https://developers.arcgis.com/ios/api-reference/_a_g_s_location_display_8h.html
Expand All @@ -524,17 +524,17 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
}
return result(stringName)
}

private func onSetWanderExtentFactor(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
guard let factor = call.arguments as? Double else {
result(FlutterError(code: "missing_data", message: "Invalid argument, expected an WanderExtentFactor as Double.", details: nil))
return
}

mapView.locationDisplay.wanderExtentFactor = Float(factor)
result(true)
}

private func onGetWanderExtentFactor(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
return result(mapView.locationDisplay.wanderExtentFactor)
}
Expand All @@ -561,13 +561,13 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
result(FlutterError(code: "invalid_data", message: "Unknown data source type \(String(describing: type))", details: nil))
}
}

private func onUpdateIsAttributionTextVisible(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
guard let isVisible = call.arguments as? Bool else {
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
return
}

mapView.isAttributionTextVisible = isVisible
result(true)
}
Expand Down

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion arcgis_map_sdk_web/lib/arcgis_map_web_js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ abstract class JsAttributes {
}

/// https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html
@JS("esri.geometry.Extent")
@JS("esri.core.geometry.Extent")
abstract class JsExtent {
/// https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#contains
external bool contains(dynamic geometry);
Expand All @@ -198,6 +198,10 @@ abstract class JsExtent {
external double get height;

external double get width;

external factory JsExtent(dynamic map);

external JsExtent expand(double ratio);
}

/// https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html
Expand Down
17 changes: 17 additions & 0 deletions arcgis_map_sdk_web/lib/src/arcgis_map_sdk_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ class ArcgisMapWeb extends ArcgisMapPlatform {
return controller;
}

@override
Future<void> setMethodCallHandler({
required int mapId,
required Future<dynamic> Function(MethodCall) onCall,
}) async {
// No-Op
}

@override
Future<void> moveCameraToPoints({
required List<LatLng> points,
required int mapId,
double? padding,
}) {
return _map(mapId).moveCameraToPoints(points: points, padding: padding);
}

@override
Future<void> init(int mapId) async {
await _hasScriptLoaded.future;
Expand Down
11 changes: 11 additions & 0 deletions arcgis_map_sdk_web/lib/src/arcgis_map_web_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,17 @@ class ArcgisMapWebController {
);
}

Future<void> moveCameraToPoints({
required List<LatLng> points,
double? padding,
}) async {
await _layerController!.moveCameraToPoints(
points: points,
padding: padding,
view: _activeView!,
);
}

Future<void> moveCamera({
required LatLng point,
double? zoomLevel,
Expand Down
45 changes: 45 additions & 0 deletions arcgis_map_sdk_web/lib/src/layer_controller.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:html' hide VoidCallback;
import 'dart:js_util';
import 'dart:math' as math;

import 'package:arcgis_map_sdk_platform_interface/arcgis_map_sdk_platform_interface.dart';
import 'package:arcgis_map_sdk_web/arcgis_map_web_js.dart';
Expand Down Expand Up @@ -828,6 +829,50 @@ class LayerController {
return zoom >= minZoom && zoom <= maxZoom;
}

Future<void> moveCameraToPoints({
required List<LatLng> points,
double? padding,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume padding won’t be supported on the web?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

AnimationOptions? animationOptions,
required JsView view,
}) async {
// Compute bounding coordinates for the list of points.
double minLat = double.infinity;
double minLon = double.infinity;
double maxLat = -double.infinity;
double maxLon = -double.infinity;

for (final point in points) {
minLat = math.min(minLat, point.latitude);
maxLat = math.max(maxLat, point.latitude);
minLon = math.min(minLon, point.longitude);
maxLon = math.max(maxLon, point.longitude);
}

final extentMap = JsExtent(
jsify({
'xmin': minLon,
'ymin': minLat,
'xmax': maxLon,
'ymax': maxLat,
'spatialReference': {'wkid': 4326},
}),
).expand(1.5);

final target = {
'target': extentMap,
};

final targetOptions = <String, dynamic>{};
if (animationOptions != null) {
targetOptions.addAll({
'duration': animationOptions.duration,
'easing': animationOptions.animationCurve.value,
});
}

await view.goTo(jsify(target), jsify(targetOptions)).toFuture();
}

/// Go to the given point and zoom if wanted
Future<void> moveCamera({
required LatLng point,
Expand Down
3 changes: 2 additions & 1 deletion arcgis_webpack/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
import Basemap from "@arcgis/core/Basemap";
import SceneLayer from "@arcgis/core/layers/SceneLayer";
import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer";

import Extent from "@arcgis/core/geometry/Extent";
window.esri = {
'core': {
'Map': Map,
Expand All @@ -24,6 +24,7 @@ window.esri = {
},
'geometry': {
'Point': Point,
'Extent': Extent,
},
'widgets': {
'Attribution': Attribution,
Expand Down
14 changes: 5 additions & 9 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -735,16 +735,12 @@ class _ExampleMapState extends State<ExampleMap> {
onPressed: () => _controller?.retryLoad(),
child: const Text('Reload map'),
),
if (!kIsWeb)
ElevatedButton(
onPressed: () => _makePolylineVisible(
points: [
_firstPinCoordinates,
_secondPinCoordinates
],
),
child: const Text('Zoom to polyline'),
ElevatedButton(
onPressed: () => _makePolylineVisible(
points: [_firstPinCoordinates, _secondPinCoordinates],
),
child: const Text('Zoom to polyline'),
),
],
),
),
Expand Down
Loading