Skip to content

Commit e77476f

Browse files
authored
Merge pull request #72 from fluttercommunity/add-featurelayer-example
Create FeatureLayer example
2 parents d9242d4 + 64db533 commit e77476f

File tree

5 files changed

+98
-19
lines changed

5 files changed

+98
-19
lines changed

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ SPEC CHECKSUMS:
3636

3737
PODFILE CHECKSUM: cc1f88378b4bfcf93a6ce00d2c587857c6008d3b
3838

39-
COCOAPODS: 1.12.1
39+
COCOAPODS: 1.15.2

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
97C146E61CF9000F007C117D /* Project object */ = {
158158
isa = PBXProject;
159159
attributes = {
160-
LastUpgradeCheck = 1430;
160+
LastUpgradeCheck = 1300;
161161
ORGANIZATIONNAME = "";
162162
TargetAttributes = {
163163
97C146ED1CF9000F007C117D = {

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 = "1430"
3+
LastUpgradeVersion = "1300"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

example/lib/main.dart

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ class _ExampleMapState extends State<ExampleMap> {
4242
final LatLng _firstPinCoordinates = const LatLng(52.9, 13.2);
4343
static const String _pinId2 = '456';
4444
final LatLng _secondPinCoordinates = const LatLng(51, 11);
45+
static const String _pinFeatureId = '789';
46+
final LatLng _pinFeatureCoordinates = const LatLng(50.945, 6.965);
4547
static const String _pinLayerId = 'PinLayer';
48+
static const String _featureLayerId = 'FeatureLayer';
4649
static const String _polygon1 = 'polygon1';
4750
static const String _polygon2 = 'polygon2';
4851
static const String _polyLayerId = 'PolygonLayer';
@@ -61,6 +64,7 @@ class _ExampleMapState extends State<ExampleMap> {
6164
bool _subscribedToBounds = false;
6265
bool _isFirstPinInView = false;
6366
bool _isSecondPinInView = false;
67+
bool _isFeatureInView = false;
6468
bool _subscribedToCenterPosition = false;
6569
bool _subscribedToGraphicsInView = false;
6670
bool _subscribedToZoom = false;
@@ -124,6 +128,10 @@ class _ExampleMapState extends State<ExampleMap> {
124128
elevationMode: ElevationMode.onTheGround,
125129
);
126130

131+
await _createFeatureLayer(
132+
layerId: _featureLayerId,
133+
);
134+
127135
// Create GraphicsLayer with Lines
128136
await _createGraphicLayer(
129137
layerId: _lineLayerId,
@@ -327,6 +335,24 @@ class _ExampleMapState extends State<ExampleMap> {
327335
_controller?.removeGraphic(layerId: layerId, objectId: objectId);
328336
}
329337

338+
Future<FeatureLayer?> _createFeatureLayer({
339+
required String layerId,
340+
}) async {
341+
final layer = await _controller?.addFeatureLayer(
342+
layerId: layerId,
343+
options: FeatureLayerOptions(
344+
fields: <Field>[
345+
Field(name: 'oid', type: 'oid'),
346+
Field(name: 'id', type: 'string'),
347+
Field(name: 'family', type: 'string'),
348+
Field(name: 'name', type: 'string'),
349+
],
350+
symbol: _markerSymbol,
351+
),
352+
);
353+
return layer;
354+
}
355+
330356
void _makePolylineVisible({required List<LatLng> points}) {
331357
_controller?.moveCameraToPoints(
332358
points: points,
@@ -572,6 +598,35 @@ class _ExampleMapState extends State<ExampleMap> {
572598
? const Text('Remove second Pin')
573599
: const Text('Add second Pin'),
574600
),
601+
ElevatedButton(
602+
onPressed: () {
603+
if (_isFeatureInView) {
604+
_removeGraphic(
605+
layerId: _featureLayerId,
606+
objectId: _pinFeatureId,
607+
);
608+
setState(() {
609+
_isFeatureInView = false;
610+
});
611+
} else {
612+
_addPin(
613+
layerId: _featureLayerId,
614+
objectId: _pinFeatureId,
615+
location: _pinFeatureCoordinates,
616+
);
617+
_controller?.moveCamera(
618+
point: _pinFeatureCoordinates,
619+
zoomLevel: 15,
620+
);
621+
setState(() {
622+
_isFeatureInView = true;
623+
});
624+
}
625+
},
626+
child: _isFeatureInView
627+
? const Text('Remove FeatureLayer Pin')
628+
: const Text('Add FeatureLayer Pin'),
629+
),
575630
ElevatedButton(
576631
onPressed: () {
577632
if (_subscribedToZoom) {

example/pubspec.lock

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,30 @@ packages:
194194
url: "https://pub.dev"
195195
source: hosted
196196
version: "0.9.0"
197+
leak_tracker:
198+
dependency: transitive
199+
description:
200+
name: leak_tracker
201+
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
202+
url: "https://pub.dev"
203+
source: hosted
204+
version: "10.0.4"
205+
leak_tracker_flutter_testing:
206+
dependency: transitive
207+
description:
208+
name: leak_tracker_flutter_testing
209+
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
210+
url: "https://pub.dev"
211+
source: hosted
212+
version: "3.0.3"
213+
leak_tracker_testing:
214+
dependency: transitive
215+
description:
216+
name: leak_tracker_testing
217+
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
218+
url: "https://pub.dev"
219+
source: hosted
220+
version: "3.0.1"
197221
lint:
198222
dependency: "direct dev"
199223
description:
@@ -206,34 +230,34 @@ packages:
206230
dependency: transitive
207231
description:
208232
name: matcher
209-
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
233+
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
210234
url: "https://pub.dev"
211235
source: hosted
212-
version: "0.12.16"
236+
version: "0.12.16+1"
213237
material_color_utilities:
214238
dependency: transitive
215239
description:
216240
name: material_color_utilities
217-
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
241+
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
218242
url: "https://pub.dev"
219243
source: hosted
220-
version: "0.5.0"
244+
version: "0.8.0"
221245
meta:
222246
dependency: transitive
223247
description:
224248
name: meta
225-
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
249+
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
226250
url: "https://pub.dev"
227251
source: hosted
228-
version: "1.10.0"
252+
version: "1.12.0"
229253
path:
230254
dependency: transitive
231255
description:
232256
name: path
233-
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
257+
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
234258
url: "https://pub.dev"
235259
source: hosted
236-
version: "1.8.3"
260+
version: "1.9.0"
237261
plugin_platform_interface:
238262
dependency: transitive
239263
description:
@@ -299,10 +323,10 @@ packages:
299323
dependency: transitive
300324
description:
301325
name: test_api
302-
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
326+
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
303327
url: "https://pub.dev"
304328
source: hosted
305-
version: "0.6.1"
329+
version: "0.7.0"
306330
typed_data:
307331
dependency: transitive
308332
description:
@@ -327,14 +351,14 @@ packages:
327351
url: "https://pub.dev"
328352
source: hosted
329353
version: "2.1.4"
330-
web:
354+
vm_service:
331355
dependency: transitive
332356
description:
333-
name: web
334-
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
357+
name: vm_service
358+
sha256: a75f83f14ad81d5fe4b3319710b90dec37da0e22612326b696c9e1b8f34bbf48
335359
url: "https://pub.dev"
336360
source: hosted
337-
version: "0.3.0"
361+
version: "14.2.0"
338362
sdks:
339-
dart: ">=3.2.0-194.0.dev <4.0.0"
340-
flutter: ">=3.10.0"
363+
dart: ">=3.3.0 <4.0.0"
364+
flutter: ">=3.18.0-18.0.pre.54"

0 commit comments

Comments
 (0)