Loading...
Searching...
No Matches
LocationWindowCamera Directory Reference

Directories

 dart
 
 java
 
 kotlin
 
 objc
 
 swift
 

Detailed Description

Examples of using LocationWindowCamera for managing map camera in Navigine SDK.

Description

LocationWindowCamera provides API for managing map camera, including:

Main Functions

1. getCamera / setCamera

Getting and setting current camera position.

// Get current camera
Camera currentCamera = locationWindow.camera;
// Set new camera position
Point newPoint = Point(100.0, 200.0);
Camera newCamera = Camera(newPoint, 50.0, 0.0);
locationWindow.camera = newCamera;

2. addCameraListener / removeCameraListener

Adding and removing camera event listeners.

// Add listener
CameraListener listener = CameraListenerImpl();
locationWindow.addCameraListener(listener);
// Remove listener
locationWindow.removeCameraListener(listener);

3. flyTo

Smooth camera movement with automatic animation.

Point targetPoint = Point(150.0, 250.0);
Camera targetCamera = Camera(targetPoint, 75.0, 45.0);
CameraCallback callback = CameraCallbackImpl();
locationWindow.flyTo(targetCamera, 2000, callback); // 2 seconds

4. moveTo

Camera movement with specified animation type.

Point targetPoint = Point(200.0, 300.0);
Camera targetCamera = Camera(targetPoint, 100.0, 90.0);
CameraCallback callback = CameraCallbackImpl();
// With different animation types
locationWindow.moveTo(targetCamera, 1500, AnimationType.LINEAR, callback);
locationWindow.moveTo(targetCamera, 1500, AnimationType.CUBIC, callback);
locationWindow.moveTo(targetCamera, 1500, AnimationType.SINE, callback);
locationWindow.moveTo(targetCamera, 0, AnimationType.NONE, callback); // Without animation

Classes and Structures

Camera

Class describing camera position:

CameraListener

Interface for receiving camera position change events:

CameraCallback

Interface for receiving movement completion notifications:

AnimationType

Animation types:

CameraUpdateReason

Camera update reasons:

Camera Properties

Zoom Management

// Get/set current zoom
double zoom = locationWindow.zoomFactor;
locationWindow.zoomFactor = 200.0;
// Zoom limits
double minZoom = locationWindow.minZoomFactor;
double maxZoom = locationWindow.maxZoomFactor;
locationWindow.minZoomFactor = 10.0;
locationWindow.maxZoomFactor = 1000.0;

Usage Examples

Basic Camera Management

// Initialize
// Get current position
// Smooth movement
// Movement with animation
// Zoom management
// Cleanup
example.cleanup();

Creating Camera for Different Scenarios

// Camera for building overview
Camera overviewCamera = Camera(Point(0.0, 0.0), 10.0, 0.0);
// Camera for room detail view
Camera detailCamera = Camera(Point(50.0, 75.0), 500.0, 0.0);
// Camera at angle for 3D effect
Camera angledCamera = Camera(Point(100.0, 150.0), 100.0, 30.0);

Camera Utilities

// Create camera for centered point
Camera camera = CameraUtils.createCenteredCamera(100.0, 200.0, 50.0);
// Create camera with rotation
Camera rotatedCamera = CameraUtils.createRotatedCamera(100.0, 200.0, 50.0, 45.0);
// Create camera for showing area
Camera areaCamera = CameraUtils.createAreaCamera(100.0, 200.0, 50.0, 30.0);
// Create camera for showing path
List<Point> path = [Point(0, 0), Point(10, 10), Point(20, 0)];
Camera pathCamera = CameraUtils.createPathCamera(path);

Platforms

Examples are available for the following platforms:

Implementation Features

Dart/Flutter

Java

Kotlin

Objective-C

Swift

Usage Recommendations

  1. Always remove listeners when finished to prevent memory leaks
  2. Use appropriate animation types for different scenarios:
    • LINEAR for fast movements
    • CUBIC for smooth transitions
    • SINE for very smooth animations
  3. Set reasonable zoom limits for better user experience
  4. Use callbacks for synchronization with other operations
  5. Validate camera before using

Error Handling

All API methods may throw exceptions with incorrect parameters or system issues. It's recommended to wrap calls in try-catch blocks:

try {
locationWindow.flyTo(targetCamera, 2000, callback);
} catch (e) {
print('Error moving camera: $e');
}

Special Comment Blocks

The examples include special comment blocks for easy code extraction:

Dart/Flutter

Java

Kotlin

Objective-C

Swift