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