Loading...
Searching...
No Matches
location_manager_example.dart
Go to the documentation of this file.
1import 'package:navigine_sdk/navigine_sdk.dart';
2
7class LocationManagerExample implements LocationListener {
8 NavigineSdk? _sdk;
9 LocationManager? _locationManager;
10 Location? _currentLocation;
11
12 LocationManagerExample() {
13 _initializeSdk();
14 }
15
19 void _initializeSdk() {
20 try {
21 // [dart_NavigineSdk_getInstance]
22 // Get SDK instance
23 _sdk = NavigineSdk.getInstance();
24 // [dart_NavigineSdk_getInstance]
25
26 // [dart_NavigineSdk_setUserHash]
27 // Set user hash
28 _sdk?.setUserHash('USER-HASH-HERE');
29 // [dart_NavigineSdk_setUserHash]
30
31 // [dart_NavigineSdk_setServer]
32 // Set server URL (optional)
33 _sdk?.setServer('https://custom.navigine.com');
34 // [dart_NavigineSdk_setServer]
35
36 // [dart_NavigineSdk_getLocationManager]
37 // Get LocationManager for working with locations
38 _locationManager = _sdk?.getLocationManager();
39 // [dart_NavigineSdk_getLocationManager]
40
41 if (_locationManager != null) {
42 print('LocationManager successfully initialized');
43 }
44 } catch (e) {
45 print('Error initializing SDK: $e');
46 }
47 }
48
52 void demonstrateLocationManagerMethods() {
53 if (_locationManager == null) {
54 print('LocationManager not initialized');
55 return;
56 }
57
58 // [dart_LocationManager_addLocationListener]
59 // Add location listener
60 _locationManager!.addLocationListener(this);
61 // [dart_LocationManager_addLocationListener]
62
63 // [dart_LocationManager_setLocationId]
64 // Set location ID to load
65 _locationManager!.setLocationId(12345);
66 // [dart_LocationManager_setLocationId]
67
68 // [dart_LocationManager_getLocationId]
69 // Get current location ID
70 int currentLocationId = _locationManager!.getLocationId();
71 print('Current location ID: $currentLocationId');
72 // [dart_LocationManager_getLocationId]
73
74 // [dart_LocationManager_setLocationUpdateInterval]
75 // Set location update interval (in seconds)
76 _locationManager!.setLocationUpdateInterval(600); // 10 minutes
77 // [dart_LocationManager_setLocationUpdateInterval]
78
79 // [dart_LocationManager_commitChanges]
80 // Commit changes
81 _locationManager!.commitChanges();
82 // [dart_LocationManager_commitChanges]
83
84 // [dart_LocationManager_revertChanges]
85 // Revert changes (if needed)
86 // _locationManager!.revertChanges();
87 // [dart_LocationManager_revertChanges]
88 }
89
93 void demonstrateLocationUsage(Location location) {
94 // [dart_Location_getId]
95 // Get location ID
96 int locationId = location.getId();
97 print('Location ID: $locationId');
98 // [dart_Location_getId]
99
100 // [dart_Location_getVersion]
101 // Get location version
102 int version = location.getVersion();
103 print('Location version: $version');
104 // [dart_Location_getVersion]
105
106 // [dart_Location_getName]
107 // Get location name
108 String? name = location.getName();
109 print('Location name: $name');
110 // [dart_Location_getName]
111
112 // [dart_Location_getDescript]
113 // Get location description
114 String? description = location.getDescript();
115 print('Location description: $description');
116 // [dart_Location_getDescript]
117
118 // [dart_Location_getModified]
119 // Check if location is modified
120 bool isModified = location.getModified();
121 print('Location modified: $isModified');
122 // [dart_Location_getModified]
123
124 // [dart_Location_getGraphTags]
125 // Get available graph tags
126 List<String> graphTags = location.getGraphTags();
127 print('Available graph tags: $graphTags');
128 // [dart_Location_getGraphTags]
129
130 // [dart_Location_getElevationGraph]
131 // Get elevation graph by tag
132 if (graphTags.isNotEmpty) {
133 ElevationGraph? elevationGraph = location.getElevationGraph(graphTags.first);
134 if (elevationGraph != null) {
135 demonstrateElevationGraphUsage(elevationGraph);
136 }
137 }
138 // [dart_Location_getElevationGraph]
139
140 // [dart_Location_getCategories]
141 // Get all categories
142 List<Category> categories = location.getCategories();
143 print('Number of categories: ${categories.length}');
144 // [dart_Location_getCategories]
145
146 // [dart_Location_getCategoryById]
147 // Get category by ID
148 if (categories.isNotEmpty) {
149 Category? category = location.getCategoryById(categories.first.getId());
150 if (category != null) {
151 demonstrateCategoryUsage(category);
152 }
153 }
154 // [dart_Location_getCategoryById]
155
156 // [dart_Location_getSublocations]
157 // Get all sublocations
158 List<Sublocation> sublocations = location.getSublocations();
159 print('Number of sublocations: ${sublocations.length}');
160 // [dart_Location_getSublocations]
161
162 // [dart_Location_getSublocationById]
163 // Get sublocation by ID
164 if (sublocations.isNotEmpty) {
165 Sublocation? sublocation = location.getSublocationById(sublocations.first.getId());
166 if (sublocation != null) {
167 demonstrateSublocationUsage(sublocation);
168 }
169 }
170 // [dart_Location_getSublocationById]
171 }
172
176 void demonstrateCategoryUsage(Category category) {
177 // [dart_Category_getId]
178 // Get category ID
179 int categoryId = category.getId();
180 print('Category ID: $categoryId');
181 // [dart_Category_getId]
182
183 // [dart_Category_getName]
184 // Get category name
185 String? categoryName = category.getName();
186 print('Category name: $categoryName');
187 // [dart_Category_getName]
188
189 // [dart_Category_getImageUrl]
190 // Get category image URL
191 String? imageUrl = category.getImageUrl();
192 if (imageUrl != null) {
193 print('Category image URL: $imageUrl');
194 }
195 // [dart_Category_getImageUrl]
196 }
197
201 void demonstrateSublocationUsage(Sublocation sublocation) {
202 // [dart_Sublocation_getId]
203 // Get sublocation ID
204 int sublocationId = sublocation.getId();
205 print('Sublocation ID: $sublocationId');
206 // [dart_Sublocation_getId]
207
208 // [dart_Sublocation_getName]
209 // Get sublocation name
210 String? sublocationName = sublocation.getName();
211 print('Sublocation name: $sublocationName');
212 // [dart_Sublocation_getName]
213
214 // [dart_Sublocation_getDescript]
215 // Get sublocation description
216 String? sublocationDescription = sublocation.getDescript();
217 print('Sublocation description: $sublocationDescription');
218 // [dart_Sublocation_getDescript]
219
220 // [dart_Sublocation_getCategoryId]
221 // Get category ID
222 int categoryId = sublocation.getCategoryId();
223 print('Sublocation category ID: $categoryId');
224 // [dart_Sublocation_getCategoryId]
225
226 // [dart_Sublocation_getLocation]
227 // Get location ID
228 int locationId = sublocation.getLocation();
229 print('Sublocation location ID: $locationId');
230 // [dart_Sublocation_getLocation]
231
232 // [dart_Sublocation_getWidth]
233 // Get sublocation width in meters
234 double width = sublocation.getWidth();
235 print('Sublocation width: $width meters');
236 // [dart_Sublocation_getWidth]
237
238 // [dart_Sublocation_getHeight]
239 // Get sublocation height in meters
240 double height = sublocation.getHeight();
241 print('Sublocation height: $height meters');
242 // [dart_Sublocation_getHeight]
243
244 // [dart_Sublocation_getAltitude]
245 // Get sublocation altitude in meters
246 double? altitude = sublocation.getAltitude();
247 if (altitude != null) {
248 print('Sublocation altitude: $altitude meters');
249 }
250 // [dart_Sublocation_getAltitude]
251
252 // [dart_Sublocation_getAzimuth]
253 // Get sublocation azimuth in degrees
254 double azimuth = sublocation.getAzimuth();
255 print('Sublocation azimuth: $azimuth degrees');
256 // [dart_Sublocation_getAzimuth]
257
258 // [dart_Sublocation_getOriginPoint]
259 // Get sublocation origin point in WGS84 coordinates
260 GlobalPoint originPoint = sublocation.getOriginPoint();
261 print('Sublocation origin point: ${originPoint.getLat()}, ${originPoint.getLon()}');
262 // [dart_Sublocation_getOriginPoint]
263
264 // [dart_Sublocation_getLevelId]
265 // Get sublocation level ID
266 String levelId = sublocation.getLevelId();
267 print('Sublocation level ID: $levelId');
268 // [dart_Sublocation_getLevelId]
269
270 // [dart_Sublocation_getExternalId]
271 // Get sublocation external ID
272 String externalId = sublocation.getExternalId();
273 print('Sublocation external ID: $externalId');
274 // [dart_Sublocation_getExternalId]
275
276 // [dart_Sublocation_getReferencePoints]
277 // Get reference points
278 List<ReferencePoint> referencePoints = sublocation.getReferencePoints();
279 print('Number of reference points: ${referencePoints.length}');
280 // [dart_Sublocation_getReferencePoints]
281
282 // [dart_Sublocation_getVenues]
283 // Get venues
284 List<Venue> venues = sublocation.getVenues();
285 print('Number of venues: ${venues.length}');
286 // [dart_Sublocation_getVenues]
287
288 // [dart_Sublocation_getZones]
289 // Get zones
290 List<Zone> zones = sublocation.getZones();
291 print('Number of zones: ${zones.length}');
292 // [dart_Sublocation_getZones]
293
294 // [dart_Sublocation_getBeacons]
295 // Get beacons
296 List<Beacon> beacons = sublocation.getBeacons();
297 print('Number of beacons: ${beacons.length}');
298 // [dart_Sublocation_getBeacons]
299
300 // [dart_Sublocation_getWifis]
301 // Get WiFi access points
302 List<Wifi> wifis = sublocation.getWifis();
303 print('Number of WiFi access points: ${wifis.length}');
304 // [dart_Sublocation_getWifis]
305
306 // [dart_Sublocation_getEddystones]
307 // Get Eddystone beacons
308 List<Eddystone> eddystones = sublocation.getEddystones();
309 print('Number of Eddystone beacons: ${eddystones.length}');
310 // [dart_Sublocation_getEddystones]
311
312 // [dart_Sublocation_getGraph]
313 // Get graph
314 Graph? graph = sublocation.getGraph();
315 if (graph != null) {
316 demonstrateGraphUsage(graph);
317 }
318 // [dart_Sublocation_getGraph]
319
320 // [dart_Sublocation_getGraph_withTag]
321 // Get graph by tag
322 Graph? graphByTag = sublocation.getGraph("main");
323 if (graphByTag != null) {
324 print('Found graph with tag "main"');
325 demonstrateGraphUsage(graphByTag);
326 }
327 // [dart_Sublocation_getGraph_withTag]
328
329 // [dart_Sublocation_getVenueById]
330 // Get venue by ID
331 if (venues.isNotEmpty) {
332 Venue? venueById = sublocation.getVenueById(venues.first.getId());
333 if (venueById != null) {
334 print('Found venue by ID: ${venueById.getId()}');
335 demonstrateVenueUsage(venueById);
336 }
337 }
338 // [dart_Sublocation_getVenueById]
339
340 // [dart_Sublocation_getZoneById]
341 // Get zone by ID
342 if (zones.isNotEmpty) {
343 Zone? zoneById = sublocation.getZoneById(zones.first.getId());
344 if (zoneById != null) {
345 print('Found zone by ID: ${zoneById.getId()}');
346 demonstrateZoneUsage(zoneById);
347 }
348 }
349 // [dart_Sublocation_getZoneById]
350
351 // [dart_Sublocation_globalToLocal]
352 // Convert global coordinates to local coordinates
353 GlobalPoint globalPoint = GlobalPoint(55.7558, 37.6176); // Moscow coordinates
354 LocationPoint localPoint = sublocation.globalToLocal(globalPoint);
355 print('Global point ${globalPoint.getLat()}, ${globalPoint.getLon()} converted to local: ${localPoint.getX()}, ${localPoint.getY()}');
356 // [dart_Sublocation_globalToLocal]
357
358 // [dart_Sublocation_localToGlobal]
359 // Convert local coordinates to global coordinates
360 LocationPoint localPoint2 = LocationPoint(100.0, 200.0);
361 GlobalPoint globalPoint2 = sublocation.localToGlobal(localPoint2);
362 print('Local point ${localPoint2.getX()}, ${localPoint2.getY()} converted to global: ${globalPoint2.getLat()}, ${globalPoint2.getLon()}');
363 // [dart_Sublocation_localToGlobal]
364
365 // [dart_Sublocation_getImage]
366 // Get sublocation image
367 ImageWrapper? image = sublocation.getImage(1024); // max texture size 1024
368 if (image != null) {
369 print('Sublocation image obtained with max texture size 1024');
370 }
371 // [dart_Sublocation_getImage]
372 }
373
377 void demonstrateVenueUsage(Venue venue) {
378 // [dart_Venue_getId]
379 // Get venue ID
380 int venueId = venue.getId();
381 print('Venue ID: $venueId');
382 // [dart_Venue_getId]
383
384 // [dart_Venue_getLocationId]
385 // Get venue location ID
386 int locationId = venue.getLocationId();
387 print('Venue location ID: $locationId');
388 // [dart_Venue_getLocationId]
389
390 // [dart_Venue_getSublocationId]
391 // Get venue sublocation ID
392 int sublocationId = venue.getSublocationId();
393 print('Venue sublocation ID: $sublocationId');
394 // [dart_Venue_getSublocationId]
395
396 // [dart_Venue_getName]
397 // Get venue name
398 String? venueName = venue.getName();
399 print('Venue name: $venueName');
400 // [dart_Venue_getName]
401
402 // [dart_Venue_getPhone]
403 // Get venue phone
404 String? phone = venue.getPhone();
405 print('Venue phone: $phone');
406 // [dart_Venue_getPhone]
407
408 // [dart_Venue_getDescript]
409 // Get venue description
410 String? venueDescription = venue.getDescript();
411 print('Venue description: $venueDescription');
412 // [dart_Venue_getDescript]
413
414 // [dart_Venue_getAlias]
415 // Get venue alias
416 String? alias = venue.getAlias();
417 print('Venue alias: $alias');
418 // [dart_Venue_getAlias]
419
420 // [dart_Venue_getCategoryId]
421 // Get category ID
422 int categoryId = venue.getCategoryId();
423 print('Venue category ID: $categoryId');
424 // [dart_Venue_getCategoryId]
425
426 // [dart_Venue_getImageUrl]
427 // Get venue image URL
428 String? imageUrl = venue.getImageUrl();
429 if (imageUrl != null) {
430 print('Venue image URL: $imageUrl');
431 }
432 // [dart_Venue_getImageUrl]
433
434 // [dart_Venue_getPoint]
435 // Get venue point
436 Point? point = venue.getPoint();
437 if (point != null) {
438 demonstratePointUsage(point);
439 }
440 // [dart_Venue_getPoint]
441 }
442
446 void demonstrateZoneUsage(Zone zone) {
447 // [dart_Zone_getId]
448 // Get zone ID
449 int zoneId = zone.getId();
450 print('Zone ID: $zoneId');
451 // [dart_Zone_getId]
452
453 // [dart_Zone_getLocationId]
454 // Get zone location ID
455 int locationId = zone.getLocationId();
456 print('Zone location ID: $locationId');
457 // [dart_Zone_getLocationId]
458
459 // [dart_Zone_getSublocationId]
460 // Get zone sublocation ID
461 int sublocationId = zone.getSublocationId();
462 print('Zone sublocation ID: $sublocationId');
463 // [dart_Zone_getSublocationId]
464
465 // [dart_Zone_getName]
466 // Get zone name
467 String? zoneName = zone.getName();
468 print('Zone name: $zoneName');
469 // [dart_Zone_getName]
470
471 // [dart_Zone_getDescript]
472 // Get zone description
473 String? zoneDescription = zone.getDescript();
474 print('Zone description: $zoneDescription');
475 // [dart_Zone_getDescript]
476
477 // [dart_Zone_getCategoryId]
478 // Get category ID
479 int categoryId = zone.getCategoryId();
480 print('Zone category ID: $categoryId');
481 // [dart_Zone_getCategoryId]
482
483 // [dart_Zone_getAlias]
484 // Get zone alias
485 String? alias = zone.getAlias();
486 print('Zone alias: $alias');
487 // [dart_Zone_getAlias]
488
489 // [dart_Zone_getColor]
490 // Get zone color
491 String? color = zone.getColor();
492 print('Zone color: $color');
493 // [dart_Zone_getColor]
494
495 // [dart_Zone_getPolygon]
496 // Get zone polygon
497 List<Point> polygon = zone.getPolygon();
498 print('Zone polygon points: ${polygon.length}');
499 // [dart_Zone_getPolygon]
500 }
501
505 void demonstrateBeaconUsage(Beacon beacon) {
506 // [dart_Beacon_getPoint]
507 // Get beacon point
508 Point? point = beacon.getPoint();
509 if (point != null) {
510 demonstratePointUsage(point);
511 }
512 // [dart_Beacon_getPoint]
513
514 // [dart_Beacon_getLocationId]
515 // Get beacon location ID
516 int locationId = beacon.getLocationId();
517 print('Beacon location ID: $locationId');
518 // [dart_Beacon_getLocationId]
519
520 // [dart_Beacon_getSublocationId]
521 // Get beacon sublocation ID
522 int sublocationId = beacon.getSublocationId();
523 print('Beacon sublocation ID: $sublocationId');
524 // [dart_Beacon_getSublocationId]
525
526 // [dart_Beacon_getName]
527 // Get beacon name
528 String? beaconName = beacon.getName();
529 print('Beacon name: $beaconName');
530 // [dart_Beacon_getName]
531
532 // [dart_Beacon_getMajor]
533 // Get beacon major
534 int major = beacon.getMajor();
535 print('Beacon major: $major');
536 // [dart_Beacon_getMajor]
537
538 // [dart_Beacon_getMinor]
539 // Get beacon minor
540 int minor = beacon.getMinor();
541 print('Beacon minor: $minor');
542 // [dart_Beacon_getMinor]
543
544 // [dart_Beacon_getUuid]
545 // Get beacon UUID
546 String? uuid = beacon.getUuid();
547 print('Beacon UUID: $uuid');
548 // [dart_Beacon_getUuid]
549
550 // [dart_Beacon_getPower]
551 // Get beacon power
552 int? power = beacon.getPower();
553 if (power != null) {
554 print('Beacon power: $power');
555 }
556 // [dart_Beacon_getPower]
557
558 // [dart_Beacon_getStatus]
559 // Get beacon status
560 TransmitterStatus status = beacon.getStatus();
561 print('Beacon status: $status');
562 // [dart_Beacon_getStatus]
563 }
564
568 void demonstrateWifiUsage(Wifi wifi) {
569 // [dart_Wifi_getPoint]
570 // Get WiFi point
571 Point? point = wifi.getPoint();
572 if (point != null) {
573 demonstratePointUsage(point);
574 }
575 // [dart_Wifi_getPoint]
576
577 // [dart_Wifi_getLocationId]
578 // Get WiFi location ID
579 int locationId = wifi.getLocationId();
580 print('WiFi location ID: $locationId');
581 // [dart_Wifi_getLocationId]
582
583 // [dart_Wifi_getSublocationId]
584 // Get WiFi sublocation ID
585 int sublocationId = wifi.getSublocationId();
586 print('WiFi sublocation ID: $sublocationId');
587 // [dart_Wifi_getSublocationId]
588
589 // [dart_Wifi_getName]
590 // Get WiFi name
591 String? wifiName = wifi.getName();
592 print('WiFi name: $wifiName');
593 // [dart_Wifi_getName]
594
595 // [dart_Wifi_getMac]
596 // Get WiFi MAC address
597 String? mac = wifi.getMac();
598 print('WiFi MAC: $mac');
599 // [dart_Wifi_getMac]
600
601 // [dart_Wifi_getStatus]
602 // Get WiFi status
603 TransmitterStatus status = wifi.getStatus();
604 print('WiFi status: $status');
605 // [dart_Wifi_getStatus]
606 }
607
611 void demonstrateEddystoneUsage(Eddystone eddystone) {
612 // [dart_Eddystone_getPoint]
613 // Get Eddystone point
614 Point? point = eddystone.getPoint();
615 if (point != null) {
616 demonstratePointUsage(point);
617 }
618 // [dart_Eddystone_getPoint]
619
620 // [dart_Eddystone_getLocationId]
621 // Get Eddystone location ID
622 int locationId = eddystone.getLocationId();
623 print('Eddystone location ID: $locationId');
624 // [dart_Eddystone_getLocationId]
625
626 // [dart_Eddystone_getSublocationId]
627 // Get Eddystone sublocation ID
628 int sublocationId = eddystone.getSublocationId();
629 print('Eddystone sublocation ID: $sublocationId');
630 // [dart_Eddystone_getSublocationId]
631
632 // [dart_Eddystone_getName]
633 // Get Eddystone name
634 String? eddystoneName = eddystone.getName();
635 print('Eddystone name: $eddystoneName');
636 // [dart_Eddystone_getName]
637
638 // [dart_Eddystone_getNamespaceId]
639 // Get Eddystone namespace ID
640 String? namespaceId = eddystone.getNamespaceId();
641 print('Eddystone namespace ID: $namespaceId');
642 // [dart_Eddystone_getNamespaceId]
643
644 // [dart_Eddystone_getInstanceId]
645 // Get Eddystone instance ID
646 String? instanceId = eddystone.getInstanceId();
647 print('Eddystone instance ID: $instanceId');
648 // [dart_Eddystone_getInstanceId]
649
650 // [dart_Eddystone_getPower]
651 // Get Eddystone power
652 int? power = eddystone.getPower();
653 if (power != null) {
654 print('Eddystone power: $power');
655 }
656 // [dart_Eddystone_getPower]
657
658 // [dart_Eddystone_getStatus]
659 // Get Eddystone status
660 TransmitterStatus status = eddystone.getStatus();
661 print('Eddystone status: $status');
662 // [dart_Eddystone_getStatus]
663 }
664
668 void demonstratePointUsage(Point point) {
669 // [dart_Point_getX]
670 // Get X coordinate
671 double x = point.getX();
672 print('Point X: $x');
673 // [dart_Point_getX]
674
675 // [dart_Point_getY]
676 // Get Y coordinate
677 double y = point.getY();
678 print('Point Y: $y');
679 // [dart_Point_getY]
680 }
681
685 void demonstrateGraphUsage(Graph graph) {
686 // [dart_Graph_getVertices]
687 // Get graph vertices
688 List<GraphVertex> vertices = graph.getVertices();
689 print('Number of graph vertices: ${vertices.length}');
690 // [dart_Graph_getVertices]
691
692 // [dart_Graph_getEdges]
693 // Get graph edges
694 List<GraphEdge> edges = graph.getEdges();
695 print('Number of graph edges: ${edges.length}');
696 // [dart_Graph_getEdges]
697 }
698
702 void demonstrateGraphVertexUsage(GraphVertex vertex) {
703 // [dart_GraphVertex_getId]
704 // Get vertex ID
705 int vertexId = vertex.getId();
706 print('Vertex ID: $vertexId');
707 // [dart_GraphVertex_getId]
708
709 // [dart_GraphVertex_getPoint]
710 // Get vertex point
711 Point? point = vertex.getPoint();
712 if (point != null) {
713 demonstratePointUsage(point);
714 }
715 // [dart_GraphVertex_getPoint]
716
717 // [dart_GraphVertex_getName]
718 // Get vertex name
719 String? name = vertex.getName();
720 print('Vertex name: $name');
721 // [dart_GraphVertex_getName]
722
723 // [dart_GraphVertex_getIsExternal]
724 // Get vertex external flag
725 bool isExternal = vertex.getIsExternal();
726 print('Vertex is external: $isExternal');
727 // [dart_GraphVertex_getIsExternal]
728
729 // [dart_GraphVertex_getIsElevation]
730 // Get vertex elevation flag
731 bool isElevation = vertex.getIsElevation();
732 print('Vertex is elevation: $isElevation');
733 // [dart_GraphVertex_getIsElevation]
734 }
735
739 void demonstrateGraphEdgeUsage(GraphEdge edge) {
740 // [dart_GraphEdge_getWeight]
741 // Get edge weight
742 double weight = edge.getWeight();
743 print('Edge weight: $weight');
744 // [dart_GraphEdge_getWeight]
745
746 // [dart_GraphEdge_getDst]
747 // Get destination vertex ID
748 int dst = edge.getDst();
749 print('Edge destination ID: $dst');
750 // [dart_GraphEdge_getDst]
751
752 // [dart_GraphEdge_getSrc]
753 // Get source vertex ID
754 int src = edge.getSrc();
755 print('Edge source ID: $src');
756 // [dart_GraphEdge_getSrc]
757
758 // [dart_GraphEdge_getWeightCoef]
759 // Get edge weight coefficient
760 int weightCoef = edge.getWeightCoef();
761 print('Edge weight coefficient: $weightCoef');
762 // [dart_GraphEdge_getWeightCoef]
763 }
764
768 void demonstrateElevationGraphUsage(ElevationGraph elevationGraph) {
769 // [dart_ElevationGraph_getEdges]
770 // Get elevation graph edges
771 List<GraphEdge> edges = elevationGraph.getEdges();
772 print('Number of elevation graph edges: ${edges.length}');
773
774 // Demonstrate each edge
775 for (int i = 0; i < edges.length; i++) {
776 GraphEdge edge = edges[i];
777 print('Elevation graph edge ${i + 1}:');
778 demonstrateGraphEdgeUsage(edge);
779 }
780 // [dart_ElevationGraph_getEdges]
781 }
782
786 void demonstrateTransmitterStatus() {
787 // [dart_TransmitterStatus_values]
788 // Get all transmitter status values
789 print('Available transmitter statuses:');
790 print(' - TransmitterStatus.active: ${TransmitterStatus.active}');
791 print(' - TransmitterStatus.inactive: ${TransmitterStatus.inactive}');
792 // [dart_TransmitterStatus_values]
793 }
794
798 void cleanup() {
799 if (_locationManager != null) {
800 // [dart_LocationManager_removeLocationListener]
801 // Remove location listener
802 _locationManager!.removeLocationListener(this);
803 // [dart_LocationManager_removeLocationListener]
804 }
805 }
806
810 Future<void> runExample() async {
811 print('=== LocationManager Example ===');
812
813 demonstrateLocationManagerMethods();
814 demonstrateTransmitterStatus();
815
816 // Wait a bit for location to load
817 await Future.delayed(Duration(seconds: 2));
818
819 cleanup();
820 print('=== Example completed ===');
821 }
822
823 // LocationListener implementation
824 @override
825 // [dart_LocationListener_onLocationLoaded]
826 void onLocationLoaded(Location? location) {
827 print('Location loaded successfully');
828 _currentLocation = location;
829 if (location != null) {
830 demonstrateLocationUsage(location);
831 }
832 }
833 // [dart_LocationListener_onLocationLoaded]
834
835 @override
836 // [dart_LocationListener_onLocationUploaded]
837 void onLocationUploaded(int locationId) {
838 print('Location uploaded: $locationId');
839 }
840 // [dart_LocationListener_onLocationUploaded]
841
842 @override
843 // [dart_LocationListener_onLocationFailed]
844 void onLocationFailed(int locationId, Object error) {
845 print('Failed to load location $locationId: $error');
846 }
847 // [dart_LocationListener_onLocationFailed]
848}
849
854
855 static Future<void> initializeInFlutter() async {
856 print('=== LocationManager Initialization in Flutter ===');
857
858 final example = LocationManagerExample();
859 await example.runExample();
860
861 print('Initialization completed');
862 }
863}
864
868void main() async {
869 final example = LocationManagerExample();
870 await example.runExample();
871}