Skip to content

Commit c23ea23

Browse files
authored
Add map image layer sample (#96)
* Created a new sample * added trailing commas * Adopted changes
1 parent 05f6672 commit c23ea23

File tree

6 files changed

+134
-1
lines changed

6 files changed

+134
-1
lines changed

assets/generated_samples_list.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,28 @@
6767
"title": "Add feature layers",
6868
"key": "add_feature_layers"
6969
},
70+
"add_map_image_layer": {
71+
"category": "Maps",
72+
"description": "Display a layer from an ArcGIS map image layer service.",
73+
"ignore": false,
74+
"images": [],
75+
"keywords": [
76+
"display",
77+
"image",
78+
"layer",
79+
"map",
80+
"ArcGISMapImageLayer"
81+
],
82+
"redirect_from": [],
83+
"relevant_apis": [
84+
"ArcGISMapImageLayer"
85+
],
86+
"snippets": [
87+
"add_map_image_layer_sample.dart"
88+
],
89+
"title": "Add map image layer",
90+
"key": "add_map_image_layer"
91+
},
7092
"add_tiled_layer": {
7193
"category": "Layers",
7294
"description": "Load an ArcGIS tiled layer from a URL.",

lib/models/samples_widget_list.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:arcgis_maps_sdk_flutter_samples/samples/add_feature_collection_layer_from_table/add_feature_collection_layer_from_table_sample.dart';
22
import 'package:arcgis_maps_sdk_flutter_samples/samples/add_feature_layers/add_feature_layers_sample.dart';
3+
import 'package:arcgis_maps_sdk_flutter_samples/samples/add_map_image_layer/add_map_image_layer_sample.dart';
34
import 'package:arcgis_maps_sdk_flutter_samples/samples/add_tiled_layer/add_tiled_layer_sample.dart';
45
import 'package:arcgis_maps_sdk_flutter_samples/samples/add_tiled_layer_as_basemap/add_tiled_layer_as_basemap_sample.dart';
56
import 'package:arcgis_maps_sdk_flutter_samples/samples/add_vector_tiled_layer/add_vector_tiled_layer_sample.dart';
@@ -46,6 +47,7 @@ const sampleWidgets = <String, Widget>{
4647
'add_feature_collection_layer_from_table':
4748
AddFeatureCollectionLayerFromTableSample(),
4849
'add_feature_layers': AddFeatureLayersSample(),
50+
'add_map_image_layer': AddMapImageLayerSample(),
4951
'add_tiled_layer': AddTiledLayerSample(),
5052
'add_tiled_layer_as_basemap': AddTiledLayerAsBasemapSample(),
5153
'add_vector_tiled_layer': AddVectorTiledLayerSample(),
@@ -85,7 +87,7 @@ const sampleWidgets = <String, Widget>{
8587
'show_magnifier': ShowMagnifierSample(),
8688
'show_portal_user_info': ShowPortalUserInfoSample(),
8789
'show_service_area': ShowServiceAreaSample(),
90+
'show_legend': ShowLegendSample(),
8891
'style_point_with_simple_marker_symbol':
8992
StylePointWithSimpleMarkerSymbolSample(),
90-
'show_legend': ShowLegendSample(),
9193
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Add map image layer
2+
3+
Display a layer from an ArcGIS map image layer service.
4+
5+
![Image of add map image layer](add_map_image_layer.png)
6+
7+
## Use case
8+
9+
Map image layers are also referred to as dynamic map services. These services generate images dynamically on the server and send the resulting image to the requesting client. This is useful when rendering complex cartography or large amounts of data in a connected environment, as the client simply displays the image that the server returns. This can result in more accurate and faster-performing layers.
10+
11+
## How to use the sample
12+
13+
Run the sample and view the map image layer. As you navigate the map, the layer issues image requests for the new map extent. The resulting images are rendered on the screen.
14+
15+
## How it works
16+
17+
1. Create an instance of `ArcGISMap`.
18+
2. Create an `ArcGISMapImageLayer` with the URL to a map image service.
19+
3. Add it to the map's operational layers collection.
20+
21+
## Relevant API
22+
23+
* ArcGISMapImageLayer
24+
25+
## Tags
26+
27+
display, image, layer, map
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"category": "Maps",
3+
"description": "Display a layer from an ArcGIS map image layer service.",
4+
"ignore": false,
5+
"images": [
6+
"add_map_image_layer.png"
7+
],
8+
"keywords": [
9+
"display",
10+
"image",
11+
"layer",
12+
"map",
13+
"ArcGISMapImageLayer"
14+
],
15+
"redirect_from": [],
16+
"relevant_apis": [
17+
"ArcGISMapImageLayer"
18+
],
19+
"snippets": [
20+
"add_map_image_layer_sample.dart"
21+
],
22+
"title": "Add map image layer"
23+
}
339 KB
Loading
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// Copyright 2024 Esri
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import 'package:arcgis_maps/arcgis_maps.dart';
18+
import 'package:arcgis_maps_sdk_flutter_samples/utils/sample_state_support.dart';
19+
import 'package:flutter/material.dart';
20+
21+
class AddMapImageLayerSample extends StatefulWidget {
22+
const AddMapImageLayerSample({super.key});
23+
24+
@override
25+
State<AddMapImageLayerSample> createState() => _AddMapImageLayerSampleState();
26+
}
27+
28+
class _AddMapImageLayerSampleState extends State<AddMapImageLayerSample>
29+
with SampleStateSupport {
30+
// Create a map view controller.
31+
final _mapViewController = ArcGISMapView.createController();
32+
33+
@override
34+
Widget build(BuildContext context) {
35+
return Scaffold(
36+
// Add a map view to the widget tree and set a controller.
37+
body: ArcGISMapView(
38+
controllerProvider: () => _mapViewController,
39+
onMapViewReady: onMapViewReady,
40+
),
41+
);
42+
}
43+
44+
void onMapViewReady() async {
45+
// Create a map with a map image layer.
46+
final map = ArcGISMap();
47+
// Create a map image layer with a uri.
48+
final mapImageLayer = ArcGISMapImageLayer.withUri(
49+
Uri.parse(
50+
'https://sampleserver5.arcgisonline.com/arcgis/rest/services/Elevation/WorldElevations/MapServer'),
51+
);
52+
// Add the map image layer to the map.
53+
map.operationalLayers.add(mapImageLayer);
54+
// Load the map image layer.
55+
await mapImageLayer.load();
56+
// Set the map on the map view controller.
57+
_mapViewController.arcGISMap = map;
58+
}
59+
}

0 commit comments

Comments
 (0)