This directory contains comprehensive examples demonstrating the usage of LocationWindowCommon components across all supported platforms.
Overview
LocationWindowCommon provides interfaces for working with location windows, views, camera operations, and map objects. It includes:
- LocationView: Flutter widget for displaying location views
- LocationWindow: Main interface for interacting with location views
- Camera Operations: Fly to, move to, and camera management
- Map Objects: Circle, icon, polygon, polyline, and dotted polyline objects
- Coordinate Conversion: Screen to meters and meters to screen conversion
- Picking Operations: Map object and feature selection
- Listener Management: Pick, input, and camera listeners
- Debug Operations: Debug flag management
- Advanced Features: Filtering and animation types
Key Components
LocationView
- Constructor: Creates a location view with callback and text direction
- onViewCreated: Callback function for when the view is created
- textDirection: Text direction property
LocationWindow
- setSublocationId: Switch between sublocations (floors)
- screenPositionToMeters: Convert screen coordinates to meters
- metersToScreenPosition: Convert meters to screen coordinates
- selectMapFeature: Select map feature by ID
- deselectMapFeature: Deselect map feature by ID
- deselectAllMapFeatures: Deselect all map features
- selectedMapFeatures: Get list of selected features
- zoomFactor: Get/set zoom level
- minZoomFactor: Get/set minimum zoom level
- maxZoomFactor: Get/set maximum zoom level
Map Objects
- CircleMapObject: Circular map objects
- IconMapObject: Icon-based map objects
- PolygonMapObject: Polygon map objects
- PolylineMapObject: Polyline map objects
- DottedPolylineMapObject: Dotted polyline map objects
Camera Operations
- flyTo: Animated camera movement
- moveTo: Smooth camera movement with animation types
- camera: Get/set camera position and zoom
Listeners
- PickListener: Handle map object and feature picking
- InputListener: Handle tap, long tap, and double tap events
- CameraListener: Handle camera movement events
Platform-Specific Files
Dart/Flutter
Java
Kotlin
Objective-C
Swift
Key Documentation Tags
LocationView
[dart_LocationView_constructor]
- Dart LocationView constructor
[java_LocationView_constructor]
- Java LocationView constructor
[kotlin_LocationView_constructor]
- Kotlin LocationView constructor
[objc_LocationView_constructor]
- Objective-C LocationView constructor
[swift_LocationView_constructor]
- Swift LocationView constructor
LocationWindow Core Methods
[dart_LocationWindow_setSublocationId]
- Set sublocation ID
[dart_LocationWindow_screenPositionToMeters]
- Screen to meters conversion
[dart_LocationWindow_metersToScreenPosition]
- Meters to screen conversion
[dart_LocationWindow_selectMapFeature]
- Select map feature
[dart_LocationWindow_deselectMapFeature]
- Deselect map feature
[dart_LocationWindow_deselectAllMapFeatures]
- Deselect all features
[dart_LocationWindow_getSelectedMapFeatures]
- Get selected features
[dart_LocationWindow_getZoomFactor]
- Get zoom factor
[dart_LocationWindow_setZoomFactor]
- Set zoom factor
[dart_LocationWindow_getMinZoomFactor]
- Get minimum zoom
[dart_LocationWindow_setMinZoomFactor]
- Set minimum zoom
[dart_LocationWindow_getMaxZoomFactor]
- Get maximum zoom
[dart_LocationWindow_setMaxZoomFactor]
- Set maximum zoom
Map Objects
[dart_LocationWindow_addCircleMapObject]
- Add circle map object
[dart_LocationWindow_removeCircleMapObject]
- Remove circle map object
[dart_LocationWindow_addIconMapObject]
- Add icon map object
[dart_LocationWindow_removeIconMapObject]
- Remove icon map object
[dart_LocationWindow_addPolygonMapObject]
- Add polygon map object
[dart_LocationWindow_removePolygonMapObject]
- Remove polygon map object
[dart_LocationWindow_addPolylineMapObject]
- Add polyline map object
[dart_LocationWindow_removePolylineMapObject]
- Remove polyline map object
[dart_LocationWindow_addDottedPolylineMapObject]
- Add dotted polyline map object
[dart_LocationWindow_removeDottedPolylineMapObject]
- Remove dotted polyline map object
[dart_LocationWindow_removeAllMapObjects]
- Remove all map objects
Camera Operations
[dart_LocationWindow_flyTo]
- Fly to camera position
[dart_LocationWindow_moveTo]
- Move to camera position with animation
Picking Operations
[dart_LocationWindow_pickMapObjectAt]
- Pick map object at position
[dart_LocationWindow_pickMapFeatureAt]
- Pick map feature at position
Listener Operations
[dart_LocationWindow_addPickListener]
- Add pick listener
[dart_LocationWindow_removePickListener]
- Remove pick listener
[dart_LocationWindow_addInputListener]
- Add input listener
[dart_LocationWindow_removeInputListener]
- Remove input listener
[dart_LocationWindow_addCameraListener]
- Add camera listener
[dart_LocationWindow_removeCameraListener]
- Remove camera listener
Debug Operations
[dart_LocationWindow_setDebugFlag]
- Set debug flag
[dart_LocationWindow_getDebugFlag]
- Get debug flag
Advanced Features
[dart_LocationWindow_applyFilter]
- Apply filter to map layer
Common Usage Patterns
1. Basic LocationWindow Setup
GlobalKey(),
(LocationWindow window) {
locationWindow = window;
},
TextDirection.ltr,
);
2. Coordinate Conversion
Point screenPoint = Point(100.0, 200.0);
Point metersPoint = locationWindow.screenPositionToMeters(screenPoint);
Point metersPoint2 = Point(50.0, 75.0);
Point screenPoint2 = locationWindow.metersToScreenPosition(metersPoint2, true);
3. Map Feature Selection
String featureId = "room_101";
bool selected = locationWindow.selectMapFeature(featureId);
List<String> selectedFeatures = locationWindow.selectedMapFeatures;
bool deselected = locationWindow.deselectMapFeature(featureId);
locationWindow.deselectAllMapFeatures();
4. Zoom Management
double currentZoom = locationWindow.zoomFactor;
locationWindow.zoomFactor = 150.0;
locationWindow.minZoomFactor = 50.0;
locationWindow.maxZoomFactor = 300.0;
5. Camera Operations
Camera flyCamera = Camera(x: 200.0, y: 200.0, zoom: 2.0);
locationWindow.flyTo(flyCamera, 1000, () {
print("Animation completed");
});
Camera moveCamera = Camera(x: 150.0, y: 150.0, zoom: 1.8);
locationWindow.moveTo(moveCamera, 800, AnimationType.easeInOut, () {
print("Move completed");
});
6. Map Object Management
CircleMapObject circle = locationWindow.addCircleMapObject();
IconMapObject icon = locationWindow.addIconMapObject();
PolygonMapObject polygon = locationWindow.addPolygonMapObject();
bool removed = locationWindow.removeCircleMapObject(circle);
locationWindow.removeAllMapObjects();
7. Listener Management
PickListener pickListener = TestPickListener();
InputListener inputListener = TestInputListener();
CameraListener cameraListener = TestCameraListener();
locationWindow.addPickListener(pickListener);
locationWindow.addInputListener(inputListener);
locationWindow.addCameraListener(cameraListener);
locationWindow.removePickListener(pickListener);
locationWindow.removeInputListener(inputListener);
locationWindow.removeCameraListener(cameraListener);
Running Examples
Dart/Flutter
cd dart
dart location_window_common_example.dart
Java
cd java
javac LocationWindowCommonExample.java
java LocationWindowCommonExample
Kotlin
cd kotlin
kotlinc LocationWindowCommonExample.kt -include-runtime -d example.jar
java -jar example.jar
Objective-C
cd objc
clang -framework Foundation LocationWindowCommonExample.m -o example
./example
Swift
cd swift
swift LocationWindowCommonExample.swift
Notes
- All examples demonstrate the same functionality across platforms
- Platform-specific syntax and idioms are used appropriately
- Error handling and null safety are implemented per platform conventions
- Examples include comprehensive testing of all methods and properties
- Documentation tags are consistent across all platforms
- Examples are designed to be educational and production-ready
Advanced Features
Filtering
Apply filters to map layers for dynamic content management:
locationWindow.applyFilter("type:room", "venues");
locationWindow.applyFilter("floor:1", "buildings");
Debug Flags
Enable debug features for development:
LocationWindow.setDebugFlag(DebugFlag.showGrid, true);
LocationWindow.setDebugFlag(DebugFlag.showBeacons, true);
bool enabled = LocationWindow.getDebugFlag(DebugFlag.showGrid);
Animation Types
Use different animation types for camera movements:
List<AnimationType> types = [
AnimationType.linear,
AnimationType.easeIn,
AnimationType.easeOut,
AnimationType.easeInOut
];
Performance Considerations
- Coordinate conversions are optimized for real-time use
- Map object management includes proper cleanup
- Listener management prevents memory leaks
- Camera operations use efficient animation algorithms
- Debug flags can impact performance in production
Error Handling
- All examples include proper null checks
- Platform-specific error handling patterns are used
- Graceful degradation for unavailable features
- Comprehensive logging for debugging