1#import <Foundation/Foundation.h>
2#import <NavigineSDK/NavigineSDK.h>
22@implementation LocationWindowInteractionExample
33 NSLog(
@"=== LocationWindowInteraction Example ===");
35 [
self demonstrateGestureProperties];
36 [
self demonstratePickProperties];
37 [
self demonstratePickMethods];
38 [
self demonstrateInputListeners];
39 [
self demonstratePickListeners];
43- (void)demonstrateGestureProperties {
44 NSLog(
@"--- Gesture Properties ---");
46 if (_locationWindow == nil) {
47 NSLog(
@"LocationWindow not available yet");
53 _locationWindow.stickToBorder = YES;
54 NSLog(
@"Set stick to border to true");
59 _locationWindow.rotateGestureEnabled = YES;
60 NSLog(
@"Set rotate gesture enabled to true");
65 _locationWindow.tiltGesturesEnabled = YES;
66 NSLog(
@"Set tilt gestures enabled to true");
71 _locationWindow.scrollGesturesEnabled = YES;
72 NSLog(
@"Set scroll gestures enabled to true");
77 _locationWindow.zoomGesturesEnabled = YES;
78 NSLog(
@"Set zoom gestures enabled to true");
82 NSArray *gestureTests = @[
83 @[@YES, @YES, @YES, @YES, @YES],
84 @[@NO, @YES, @YES, @YES, @NO],
85 @[@YES, @NO, @YES, @NO, @YES],
86 @[@NO, @NO, @NO, @NO, @NO],
89 for (
int i = 0; i < gestureTests.count; i++) {
90 NSArray *test = gestureTests[i];
91 BOOL rotate = [test[0] boolValue];
92 BOOL tilt = [test[1] boolValue];
93 BOOL scroll = [test[2] boolValue];
94 BOOL zoom = [test[3] boolValue];
95 BOOL stick = [test[4] boolValue];
97 _locationWindow.rotateGestureEnabled = rotate;
98 _locationWindow.tiltGesturesEnabled = tilt;
99 _locationWindow.scrollGesturesEnabled = scroll;
100 _locationWindow.zoomGesturesEnabled = zoom;
101 _locationWindow.stickToBorder = stick;
102 NSLog(
@"Gesture test %d: Rotate=%s, Tilt=%s, Scroll=%s, Zoom=%s, Stick=%s",
103 i, rotate ?
"true" :
"false", tilt ?
"true" :
"false",
104 scroll ?
"true" :
"false", zoom ?
"true" :
"false", stick ?
"true" :
"false");
108- (void)demonstratePickProperties {
109 NSLog(
@"--- Pick Properties ---");
111 if (_locationWindow == nil) {
112 NSLog(
@"LocationWindow not available yet");
118 _locationWindow.pickRadius = 10.0;
119 NSLog(
@"Set pick radius to 10.0 pixels");
123 NSArray *pickRadiusTests = @[@5.0, @10.0, @20.0, @50.0, @100.0];
125 for (
int i = 0; i < pickRadiusTests.count; i++) {
126 double radius = [pickRadiusTests[i] doubleValue];
127 _locationWindow.pickRadius = radius;
128 NSLog(
@"Pick radius test %d: %.1f pixels", i, radius);
132- (void)demonstratePickMethods {
133 NSLog(
@"--- Pick Methods ---");
135 if (_locationWindow == nil) {
136 NSLog(
@"LocationWindow not available yet");
142 NCPoint *screenPoint = [[NCPoint alloc] initWithX:100.0 y:200.0];
143 [_locationWindow pickMapObjectAt:screenPoint];
144 NSLog(
@"Picked map object at screen position (%.1f, %.1f)", screenPoint.x, screenPoint.y);
149 NCPoint *featurePoint = [[NCPoint alloc] initWithX:150.0 y:250.0];
150 [_locationWindow pickMapFeatureAt:featurePoint];
151 NSLog(
@"Picked map feature at screen position (%.1f, %.1f)", featurePoint.x, featurePoint.y);
155 NSArray *pickTests = @[
156 [[NCPoint alloc] initWithX:50.0 y:50.0],
157 [[NCPoint alloc] initWithX:200.0 y:300.0],
158 [[NCPoint alloc] initWithX:400.0 y:100.0],
159 [[NCPoint alloc] initWithX:300.0 y:400.0],
162 for (
int i = 0; i < pickTests.count; i++) {
163 NCPoint *point = pickTests[i];
164 [_locationWindow pickMapObjectAt:point];
165 [_locationWindow pickMapFeatureAt:point];
166 NSLog(
@"Pick test %d: Object and feature at (%.1f, %.1f)", i, point.x, point.y);
170- (void)demonstrateInputListeners {
171 NSLog(
@"--- Input Listeners ---");
173 if (_locationWindow == nil) {
174 NSLog(
@"LocationWindow not available yet");
181 [_locationWindow addInputListener:_inputListener];
182 NSLog(
@"Added input listener");
187 [_locationWindow removeInputListener:_inputListener];
188 _inputListener = nil;
189 NSLog(
@"Removed input listener");
193 NSArray *listeners = @[
199 for (
int i = 0; i < listeners.count; i++) {
200 [_locationWindow addInputListener:listeners[i]];
201 NSLog(
@"Added input listener %d", i);
204 for (
int i = 0; i < listeners.count; i++) {
205 [_locationWindow removeInputListener:listeners[i]];
206 NSLog(
@"Removed input listener %d", i);
210- (void)demonstratePickListeners {
211 NSLog(
@"--- Pick Listeners ---");
213 if (_locationWindow == nil) {
214 NSLog(
@"LocationWindow not available yet");
221 [_locationWindow addPickListener:_pickListener];
222 NSLog(
@"Added pick listener");
226 NSArray *listeners = @[
232 for (
int i = 0; i < listeners.count; i++) {
233 [_locationWindow addPickListener:listeners[i]];
234 NSLog(
@"Added pick listener %d", i);
237 for (
int i = 0; i < listeners.count; i++) {
239 [_locationWindow removePickListener:listeners[i]];
240 NSLog(
@"Removed pick listener %d", i);
246 if (_inputListener != nil) {
247 [_locationWindow removeInputListener:_inputListener];
248 _inputListener = nil;
250 if (_pickListener != nil) {
251 [_locationWindow removePickListener:_pickListener];
254 NSLog(
@"LocationWindowInteraction example cleanup completed");
260@interface InputListenerImpl : NSObject <NCInputListener>
263@implementation InputListenerImpl
266- (void)onViewTapWithScreenPoint:(NCPoint *)screenPoint {
267 NSLog(
@"View tapped at screen position (%.1f, %.1f)", screenPoint.x, screenPoint.y);
272- (void)onViewDoubleTapWithScreenPoint:(NCPoint *)screenPoint {
273 NSLog(
@"View double tapped at screen position (%.1f, %.1f)", screenPoint.x, screenPoint.y);
278- (void)onViewLongTapWithScreenPoint:(NCPoint *)screenPoint {
279 NSLog(
@"View long tapped at screen position (%.1f, %.1f)", screenPoint.x, screenPoint.y);
286@interface PickListenerImpl : NSObject <NCPickListener>
289@implementation PickListenerImpl
292- (void)onMapObjectPickCompleteWithMapObjectPickResult:(NCMapObjectPickResult *)mapObjectPickResult screenPosition:(NCPoint *)screenPosition {
293 if (mapObjectPickResult != nil) {
295 NCLocationPoint *point = mapObjectPickResult.point;
296 NSLog(
@"Map object picked at screen position (%.1f, %.1f)", screenPosition.x, screenPosition.y);
297 NSLog(
@" Object location: (%.1f, %.1f)", point.x, point.y);
301 NCMapObject *mapObject = mapObjectPickResult.mapObject;
302 NSLog(
@" Object type: %@", NSStringFromClass([mapObject
class]));
305 NSLog(
@"No map object found at screen position (%.1f, %.1f)", screenPosition.x, screenPosition.y);
311- (void)onMapFeaturePickCompleteWithMapFeaturePickResult:(NSDictionary<NSString *, NSString *> *)mapFeaturePickResult screenPosition:(NCPoint *)screenPosition {
312 if (mapFeaturePickResult != nil) {
313 NSLog(
@"Map feature picked at screen position (%.1f, %.1f)", screenPosition.x, screenPosition.y);
314 NSLog(
@" Feature properties: %@", mapFeaturePickResult);
316 NSLog(
@"No map feature found at screen position (%.1f, %.1f)", screenPosition.x, screenPosition.y);
324int main(
int argc,
const char * argv[]) {