Skip to content

Commit ae2a758

Browse files
Hide map attribution (#73)
* Add isAttributionTextVisible to hide map attribution * Add isAttributionTextVisible for iOS * Add dependency_overrides * implement changing attribution text --------- Co-authored-by: Julian Bissekkou <[email protected]>
1 parent e77476f commit ae2a758

File tree

18 files changed

+137
-32
lines changed

18 files changed

+137
-32
lines changed

arcgis_map_sdk/lib/src/arcgis_location_display.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ArcgisLocationDisplay {
3232

3333
ArcgisLocationDisplay({int? mapId}) : _mapId = mapId;
3434

35+
// ignore: use_setters_to_change_properties
3536
void attachToMap(int mapId) => _mapId = mapId;
3637

3738
void deattachFromMap() => _mapId = null;

arcgis_map_sdk/lib/src/arcgis_map_controller.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,9 @@ class ArcgisMapController {
320320
},
321321
);
322322
}
323+
324+
Future<void> updateIsAttributionTextVisible(bool isAttributionTextVisible) {
325+
return ArcgisMapPlatform.instance
326+
.updateIsAttributionTextVisible(mapId, isAttributionTextVisible);
327+
}
323328
}

arcgis_map_sdk/lib/src/arcgis_map_sdk.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class ArcgisMap extends StatefulWidget {
4040
this.yMax = 66,
4141
this.onMapCreated,
4242
this.vectorTileLayerUrls,
43+
this.isAttributionTextVisible,
4344
super.key,
4445
}) : assert(
4546
basemap != null ||
@@ -70,6 +71,7 @@ class ArcgisMap extends StatefulWidget {
7071
final double xMax;
7172
final double yMin;
7273
final double yMax;
74+
final bool? isAttributionTextVisible;
7375

7476
/// Adds vector tile layers to the map. You can add more than one.
7577
/// When the [vectorTileLayerUrls] is not empty, the [basemap] field
@@ -110,6 +112,7 @@ class _ArcgisMapState extends State<ArcgisMap> {
110112
yMin: widget.yMin,
111113
yMax: widget.yMax,
112114
vectorTilesUrls: widget.vectorTileLayerUrls,
115+
isAttributionTextVisible: widget.isAttributionTextVisible,
113116
);
114117

115118
Future<void> onPlatformViewCreated(int id) async {
@@ -138,6 +141,12 @@ class _ArcgisMapState extends State<ArcgisMap> {
138141
if ((widget.basemap != null) && oldWidget.basemap != widget.basemap) {
139142
controller.toggleBaseMap(baseMap: widget.basemap!);
140143
}
144+
if (widget.isAttributionTextVisible != null &&
145+
widget.isAttributionTextVisible != oldWidget.isAttributionTextVisible) {
146+
controller.updateIsAttributionTextVisible(
147+
widget.isAttributionTextVisible!,
148+
);
149+
}
141150
_arcgisMapOptions = ArcgisMapOptions(
142151
apiKey: widget.apiKey,
143152
licenseKey: widget.licenseKey,
@@ -161,6 +170,7 @@ class _ArcgisMapState extends State<ArcgisMap> {
161170
yMax: widget.yMax,
162171
vectorTilesUrls: widget.vectorTileLayerUrls,
163172
defaultUiList: widget.defaultUiList,
173+
isAttributionTextVisible: widget.isAttributionTextVisible,
164174
);
165175
}
166176

arcgis_map_sdk_android/android/src/main/kotlin/dev/fluttercommunity/arcgis_map_sdk_android/ArcgisMapView.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ internal class ArcgisMapView(
7979

8080
mapView = view.findViewById(R.id.mapView)
8181

82-
map.apply {
82+
mapOptions.isAttributionTextVisible?.let { mapView.isAttributionTextVisible = it }
8383

84+
map.apply {
8485
basemap = if (mapOptions.basemap != null) {
8586
Basemap(mapOptions.basemap)
8687
} else {
@@ -182,11 +183,27 @@ internal class ArcgisMapView(
182183
result
183184
)
184185

186+
"update_is_attribution_text_visible" -> onUpdateIsAttributionTextVisible(
187+
call,
188+
result
189+
)
190+
185191
else -> result.notImplemented()
186192
}
187193
}
188194
}
189195

196+
private fun onUpdateIsAttributionTextVisible(call: MethodCall, result: MethodChannel.Result) {
197+
val isVisible = call.arguments as? Boolean
198+
if (isVisible == null) {
199+
result.error("invalid_argument", "isAttributionTextVisible must be a boolean", null)
200+
return
201+
}
202+
203+
mapView.isAttributionTextVisible = isVisible
204+
result.success(true)
205+
}
206+
190207
private fun onStartLocationDisplayDataSource(result: MethodChannel.Result) {
191208
result.finishWithFuture { mapView.locationDisplay.locationDataSource.startAsync() }
192209
}

arcgis_map_sdk_android/android/src/main/kotlin/dev/fluttercommunity/arcgis_map_sdk_android/model/ArcgisMapOptions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ data class ArcgisMapOptions(
2020
val xMax: Double,
2121
val yMin: Double,
2222
val yMax: Double,
23+
val isAttributionTextVisible: Boolean?,
2324
)

arcgis_map_sdk_ios/ios/Classes/ArcgisMapView.swift

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

7777
super.init()
78+
79+
if let isAttributionTextVisible = mapOptions.isAttributionTextVisible {
80+
mapView.isAttributionTextVisible = isAttributionTextVisible
81+
}
7882

7983
if mapOptions.basemap != nil {
8084
map.basemap = AGSBasemap(style: parseBaseMapStyle(mapOptions.basemap!))
@@ -153,6 +157,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
153157
case "location_display_set_use_course_symbol_on_move" : onSetLocationDisplayUseCourseSymbolOnMove(call, result)
154158
case "location_display_update_display_source_position_manually" : onUpdateLocationDisplaySourcePositionManually(call, result)
155159
case "location_display_set_data_source_type" : onSetLocationDisplayDataSourceType(call, result)
160+
case "update_is_attribution_text_visible": onUpdateIsAttributionTextVisible(call, result)
156161
default:
157162
result(FlutterError(code: "Unimplemented", message: "No method matching the name \(call.method)", details: nil))
158163
}
@@ -501,6 +506,16 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
501506
result(FlutterError(code: "invalid_data", message: "Unknown data source type \(String(describing: type))", details: nil))
502507
}
503508
}
509+
510+
private func onUpdateIsAttributionTextVisible(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
511+
guard let isVisible = call.arguments as? Bool else {
512+
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
513+
return
514+
}
515+
516+
mapView.isAttributionTextVisible = isVisible
517+
result(true)
518+
}
504519

505520
private func operationWithSymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult, handler: (AGSSymbol) -> Void) {
506521
do {

arcgis_map_sdk_ios/ios/Classes/Models/ArcgisMapOptions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ struct ArcgisMapOptions: Codable {
2323
let xMax: Int
2424
let yMin: Int
2525
let yMax: Int
26+
let isAttributionTextVisible: Bool?
2627
}

arcgis_map_sdk_method_channel/lib/src/method_channel_arcgis_map_plugin.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,15 @@ class MethodChannelArcgisMapPlugin extends ArcgisMapPlatform {
304304
type,
305305
);
306306
}
307+
308+
@override
309+
Future<void> updateIsAttributionTextVisible(
310+
int mapId,
311+
bool isAttributionTextVisible,
312+
) {
313+
return _methodChannelBuilder(mapId).invokeMethod(
314+
"update_is_attribution_text_visible",
315+
isAttributionTextVisible,
316+
);
317+
}
307318
}

arcgis_map_sdk_method_channel/lib/src/model_extension.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ extension ArcgisMapOptionsJsonExtension on ArcgisMapOptions {
4747
'xMax': xMax,
4848
'yMin': yMin,
4949
'yMax': yMax,
50+
'isAttributionTextVisible': isAttributionTextVisible,
5051
};
5152
}
5253
}

arcgis_map_sdk_platform_interface/lib/src/arcgis_map_sdk_platform_interface.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,13 @@ class ArcgisMapPlatform extends PlatformInterface {
277277
'setLocationDisplay() has not been implemented.',
278278
);
279279
}
280+
281+
Future<void> updateIsAttributionTextVisible(
282+
int mapId,
283+
bool isAttributionTextVisible,
284+
) {
285+
throw UnimplementedError(
286+
'updateIsAttributionTextVisible() has not been implemented.',
287+
);
288+
}
280289
}

arcgis_map_sdk_platform_interface/lib/src/types/arcgis_map_options.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import 'package:arcgis_map_sdk_platform_interface/arcgis_map_sdk_platform_interf
66
///
77
/// [xMin], [xMax], [yMin] and [yMax] are the coordinates of an extent envelope that constrains the panning in the map.
88
///
9-
/// Warning!! If [hideAttribution] is set to true,
10-
/// an attribution must still be provided, according to following layout and design guidelines from Esri
9+
/// [isAttributionTextVisible] will hide the map attribution (e.g. the logo). Review the guidelines before disabling the attribution:
1110
/// https://developers.arcgis.com/documentation/mapping-apis-and-services/deployment/basemap-attribution/#layout-and-design-guidelines
1211
class ArcgisMapOptions {
1312
final String? apiKey;
@@ -33,6 +32,7 @@ class ArcgisMapOptions {
3332
final List<String>? vectorTilesUrls;
3433
final List<DefaultWidget> defaultUiList;
3534
final bool isPopupEnabled;
35+
final bool? isAttributionTextVisible;
3636

3737
const ArcgisMapOptions({
3838
required this.apiKey,
@@ -58,11 +58,12 @@ class ArcgisMapOptions {
5858
this.ground,
5959
this.vectorTilesUrls,
6060
this.isPopupEnabled = false,
61+
this.isAttributionTextVisible,
6162
});
6263

6364
@override
6465
String toString() {
65-
return 'ArcgisMapOptions{apiKey: $apiKey, licenseKey: $licenseKey, mapStyle: $mapStyle, initialCenter: $initialCenter, showLabelsBeneathGraphics: $showLabelsBeneathGraphics, isInteractive: $isInteractive, zoom: $zoom, tilt: $tilt, initialHeight: $initialHeight, heading: $heading, padding: $padding, rotationEnabled: $rotationEnabled, minZoom: $minZoom, maxZoom: $maxZoom, xMin: $xMin, xMax: $xMax, yMin: $yMin, yMax: $yMax, basemap: $basemap, ground: $ground, vectorTilesUrls: $vectorTilesUrls, defaultUiList: $defaultUiList, isPopupEnabled: $isPopupEnabled}';
66+
return 'ArcgisMapOptions{apiKey: $apiKey, licenseKey: $licenseKey, mapStyle: $mapStyle, initialCenter: $initialCenter, showLabelsBeneathGraphics: $showLabelsBeneathGraphics, isInteractive: $isInteractive, zoom: $zoom, tilt: $tilt, initialHeight: $initialHeight, heading: $heading, padding: $padding, rotationEnabled: $rotationEnabled, minZoom: $minZoom, maxZoom: $maxZoom, xMin: $xMin, xMax: $xMax, yMin: $yMin, yMax: $yMax, basemap: $basemap, ground: $ground, vectorTilesUrls: $vectorTilesUrls, defaultUiList: $defaultUiList, isPopupEnabled: $isPopupEnabled, isAttributionTextVisible: $isAttributionTextVisible}';
6667
}
6768
}
6869

example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>11.0</string>
24+
<string>12.0</string>
2525
</dict>
2626
</plist>

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SPEC CHECKSUMS:
3131
ArcGIS-Runtime-SDK-iOS: 6ab51d28f8831ac73c00d34998cff3a555fe304f
3232
ArcGIS-Runtime-Toolkit-iOS: e30bb45bd0bd0152bcb1ec73f9b99022a5c7d02d
3333
arcgis_map_sdk_ios: ee1d8dee42e0c11c95cd26afa2a8cb0e7a69cb23
34-
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
34+
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
3535
geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401
3636

3737
PODFILE CHECKSUM: cc1f88378b4bfcf93a6ce00d2c587857c6008d3b

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
97C146E61CF9000F007C117D /* Project object */ = {
158158
isa = PBXProject;
159159
attributes = {
160-
LastUpgradeCheck = 1300;
160+
LastUpgradeCheck = 1510;
161161
ORGANIZATIONNAME = "";
162162
TargetAttributes = {
163163
97C146ED1CF9000F007C117D = {
@@ -344,7 +344,7 @@
344344
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
345345
GCC_WARN_UNUSED_FUNCTION = YES;
346346
GCC_WARN_UNUSED_VARIABLE = YES;
347-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
347+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
348348
MTL_ENABLE_DEBUG_INFO = NO;
349349
SDKROOT = iphoneos;
350350
SUPPORTED_PLATFORMS = iphoneos;
@@ -422,7 +422,7 @@
422422
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
423423
GCC_WARN_UNUSED_FUNCTION = YES;
424424
GCC_WARN_UNUSED_VARIABLE = YES;
425-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
425+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
426426
MTL_ENABLE_DEBUG_INFO = YES;
427427
ONLY_ACTIVE_ARCH = YES;
428428
SDKROOT = iphoneos;
@@ -471,7 +471,7 @@
471471
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
472472
GCC_WARN_UNUSED_FUNCTION = YES;
473473
GCC_WARN_UNUSED_VARIABLE = YES;
474-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
474+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
475475
MTL_ENABLE_DEBUG_INFO = NO;
476476
SDKROOT = iphoneos;
477477
SUPPORTED_PLATFORMS = iphoneos;

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

example/lib/vector_layer_example_page.dart

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,37 @@ class VectorLayerExamplePage extends StatefulWidget {
1010
}
1111

1212
class _VectorLayerExamplePageState extends State<VectorLayerExamplePage> {
13+
bool _isAttributionTextVisible = true;
14+
1315
@override
1416
Widget build(BuildContext context) {
1517
return Scaffold(
1618
appBar: AppBar(),
17-
body: ArcgisMap(
18-
apiKey: arcGisApiKey,
19-
initialCenter: const LatLng(51.16, 10.45),
20-
zoom: 13,
21-
vectorTileLayerUrls: const [
22-
"https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer",
19+
body: Stack(
20+
alignment: Alignment.bottomLeft,
21+
children: [
22+
ArcgisMap(
23+
apiKey: arcGisApiKey,
24+
initialCenter: const LatLng(51.16, 10.45),
25+
zoom: 13,
26+
vectorTileLayerUrls: const [
27+
"https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer",
28+
],
29+
mapStyle: MapStyle.twoD,
30+
isAttributionTextVisible: _isAttributionTextVisible,
31+
),
32+
Padding(
33+
padding: const EdgeInsets.all(16),
34+
child: ElevatedButton(
35+
onPressed: () {
36+
setState(() {
37+
_isAttributionTextVisible = !_isAttributionTextVisible;
38+
});
39+
},
40+
child: Text("Toggle isAttributionTextVisible"),
41+
),
42+
),
2343
],
24-
mapStyle: MapStyle.twoD,
2544
),
2645
);
2746
}

example/pubspec.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,26 +198,26 @@ packages:
198198
dependency: transitive
199199
description:
200200
name: leak_tracker
201-
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
201+
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
202202
url: "https://pub.dev"
203203
source: hosted
204-
version: "10.0.4"
204+
version: "10.0.0"
205205
leak_tracker_flutter_testing:
206206
dependency: transitive
207207
description:
208208
name: leak_tracker_flutter_testing
209-
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
209+
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
210210
url: "https://pub.dev"
211211
source: hosted
212-
version: "3.0.3"
212+
version: "2.0.1"
213213
leak_tracker_testing:
214214
dependency: transitive
215215
description:
216216
name: leak_tracker_testing
217-
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
217+
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
218218
url: "https://pub.dev"
219219
source: hosted
220-
version: "3.0.1"
220+
version: "2.0.1"
221221
lint:
222222
dependency: "direct dev"
223223
description:
@@ -246,10 +246,10 @@ packages:
246246
dependency: transitive
247247
description:
248248
name: meta
249-
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
249+
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
250250
url: "https://pub.dev"
251251
source: hosted
252-
version: "1.12.0"
252+
version: "1.11.0"
253253
path:
254254
dependency: transitive
255255
description:
@@ -323,10 +323,10 @@ packages:
323323
dependency: transitive
324324
description:
325325
name: test_api
326-
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
326+
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
327327
url: "https://pub.dev"
328328
source: hosted
329-
version: "0.7.0"
329+
version: "0.6.1"
330330
typed_data:
331331
dependency: transitive
332332
description:
@@ -355,10 +355,10 @@ packages:
355355
dependency: transitive
356356
description:
357357
name: vm_service
358-
sha256: a75f83f14ad81d5fe4b3319710b90dec37da0e22612326b696c9e1b8f34bbf48
358+
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
359359
url: "https://pub.dev"
360360
source: hosted
361-
version: "14.2.0"
361+
version: "13.0.0"
362362
sdks:
363-
dart: ">=3.3.0 <4.0.0"
364-
flutter: ">=3.18.0-18.0.pre.54"
363+
dart: ">=3.2.0-0 <4.0.0"
364+
flutter: ">=3.10.0"

0 commit comments

Comments
 (0)