Modify documentation of APIs
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / MapView.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using ElmSharp;
19 using Layout = ElmSharp.Layout;
20 using EvasObject = ElmSharp.EvasObject;
21 using System.Collections.Generic;
22
23 namespace Tizen.Maps
24 {
25     /// <summary>
26     /// Map View class to show a map on the screen.
27     /// </summary>
28     public class MapView : Layout, IDisposable
29     {
30         internal Interop.ViewHandle handle;
31         private MapService _service;
32
33         private Dictionary<IntPtr, MapObject> _handleToObjectTable = new Dictionary<IntPtr, MapObject>();
34
35         private Interop.ViewOnEventCallback _gestureEventCallback;
36         private Interop.ViewOnEventCallback _objectEventCallback;
37         private Interop.ViewOnEventCallback _viewReadyEventCallback;
38
39         private event EventHandler<MapGestureEventArgs> _scrolledEventHandler;
40         private event EventHandler<MapGestureEventArgs> _zoomedEventHandler;
41         private event EventHandler<MapGestureEventArgs> _tappedEventHandler;
42         private event EventHandler<MapGestureEventArgs> _doubleTappedEventHandler;
43         private event EventHandler<MapGestureEventArgs> _twoFingerTappedEventHandler;
44         private event EventHandler<MapGestureEventArgs> _rotatedEventHandler;
45         private event EventHandler<MapGestureEventArgs> _longPressedEventHandler;
46         private event EventHandler _viewReadyEventHandler;
47
48         /// <summary>
49         /// Creates the view and link it to the instance of map service.
50         /// </summary>
51         /// <param name="parent">An instance of <see cref="EvasObject"/> object which map view will be drawn</param>
52         /// <param name="service">An instance of <see cref="MapService"/> object</param>
53         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
54         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
55         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
56         /// <exception cref="System.ArgumentException">Thrown when parameters are invalid</exception>
57         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service</exception>
58         public MapView(EvasObject parent, MapService service) : base(parent)
59         {
60             handle = new Interop.ViewHandle(service.handle, this);
61             Log.Info(string.Format("MapView is created"));
62
63             _service = service;
64             this.Resize(1, 1);
65
66             // We need to keep Gesture Tap event enabled for object event to work
67             handle.SetGestureEnabled(Interop.ViewGesture.Tap, true);
68             SetObjectEventCallback();
69         }
70
71         /// <summary>
72         /// Adds or removes event handlers to deliver scrolled gesture event.
73         /// </summary>
74         /// <value>Event handlers to get scrolled gesture event</value>
75         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
76         public event EventHandler<MapGestureEventArgs> Scrolled
77         {
78             add
79             {
80                 SetGestureEventCallback();
81                 handle.SetGestureEnabled(Interop.ViewGesture.Scroll, true);
82                 _scrolledEventHandler += value;
83                 Log.Info(string.Format("Scrolled event handler is added"));
84             }
85             remove
86             {
87                 _scrolledEventHandler -= value;
88                 Log.Info(string.Format("Scrolled event handler is removed"));
89                 if (_scrolledEventHandler == null)
90                 {
91                     handle.SetGestureEnabled(Interop.ViewGesture.Scroll, false);
92                     UnsetGestureEventCallback();
93                 }
94             }
95         }
96
97         /// <summary>
98         /// Adds or removes event handlers to deliver zoomed gesture event.
99         /// </summary>
100         /// <value>Event handlers to get zoomed gesture event</value>
101         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
102         public event EventHandler<MapGestureEventArgs> ZoomChanged
103         {
104             add
105             {
106                 SetGestureEventCallback();
107                 handle.SetGestureEnabled(Interop.ViewGesture.Zoom, true);
108                 _zoomedEventHandler += value;
109                 Log.Info(string.Format("ZoomChanged event handler is added"));
110             }
111             remove
112             {
113                 _zoomedEventHandler -= value;
114                 Log.Info(string.Format("ZoomChanged event handler is removed"));
115                 if (_zoomedEventHandler == null)
116                 {
117                     handle.SetGestureEnabled(Interop.ViewGesture.Zoom, false);
118                     UnsetGestureEventCallback();
119                 }
120             }
121         }
122
123         /// <summary>
124         /// Adds or removes event handlers to deliver clicked gesture event.
125         /// </summary>
126         /// <value>Event handlers to get clicked gesture event</value>
127         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
128         public event EventHandler<MapGestureEventArgs> Clicked
129         {
130             add
131             {
132                 SetGestureEventCallback();
133                 //handle.SetGestureEnabled(Interop.ViewGesture.Tap, true);
134                 _tappedEventHandler += value;
135                 Log.Info(string.Format("Clicked event handler is added"));
136             }
137             remove
138             {
139                 _tappedEventHandler -= value;
140                 Log.Info(string.Format("Clicked event handler is removed"));
141                 if (_tappedEventHandler == null)
142                 {
143                     //handle.SetGestureEnabled(Interop.ViewGesture.Tap, false);
144                     UnsetGestureEventCallback();
145                 }
146             }
147         }
148
149         /// <summary>
150         /// Adds or removes event handlers to deliver double-clicked gesture event.
151         /// </summary>
152         /// <value>Event handlers to get double-clicked gesture event</value>
153         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
154         public event EventHandler<MapGestureEventArgs> DoubleClicked
155         {
156             add
157             {
158                 SetGestureEventCallback();
159                 handle.SetGestureEnabled(Interop.ViewGesture.DoubleTap, true);
160                 _doubleTappedEventHandler += value;
161                 Log.Info(string.Format("DoubleClicked event handler is removed"));
162             }
163             remove
164             {
165                 _doubleTappedEventHandler -= value;
166                 Log.Info(string.Format("DoubleClicked event handler is removed"));
167                 if (_doubleTappedEventHandler == null)
168                 {
169                     handle.SetGestureEnabled(Interop.ViewGesture.DoubleTap, false);
170                     UnsetGestureEventCallback();
171                 }
172             }
173         }
174
175         /// <summary>
176         /// Adds or removes event handlers to deliver clicked gesture event with two-fingers.
177         /// </summary>
178         /// <value>Event handlers to get clicked gesture event</value>
179         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
180         public event EventHandler<MapGestureEventArgs> TwoFingerPressed
181         {
182             add
183             {
184                 SetGestureEventCallback();
185                 handle.SetGestureEnabled(Interop.ViewGesture.TwoFingerTap, true);
186                 _twoFingerTappedEventHandler += value;
187                 Log.Info(string.Format("TwoFingerPressed event handler is added"));
188             }
189             remove
190             {
191                 _twoFingerTappedEventHandler -= value;
192                 Log.Info(string.Format("TwoFingerPressed event handler is removed"));
193                 if (_twoFingerTappedEventHandler == null)
194                 {
195                     handle.SetGestureEnabled(Interop.ViewGesture.TwoFingerTap, false);
196                     UnsetGestureEventCallback();
197                 }
198             }
199         }
200
201         /// <summary>
202         /// Adds or removes event handlers to deliver rotated gesture event.
203         /// </summary>
204         /// <value>Event handlers to get rotated gesture event</value>
205         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
206         public event EventHandler<MapGestureEventArgs> Rotated
207         {
208             add
209             {
210                 SetGestureEventCallback();
211                 handle.SetGestureEnabled(Interop.ViewGesture.Rotate, true);
212                 _rotatedEventHandler += value;
213                 Log.Info(string.Format("Rotated event handler is added"));
214             }
215             remove
216             {
217                 _rotatedEventHandler -= value;
218                 Log.Info(string.Format("Rotated event handler is removed"));
219                 if (_rotatedEventHandler == null)
220                 {
221                     handle.SetGestureEnabled(Interop.ViewGesture.Rotate, false);
222                     UnsetGestureEventCallback();
223                 }
224             }
225         }
226
227
228         /// <summary>
229         /// Adds or removes event handlers to deliver long-pressed gesture event.
230         /// </summary>
231         /// <value>Event handlers to get long-pressed gesture event</value>
232         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
233         public event EventHandler<MapGestureEventArgs> LongPressed
234         {
235             add
236             {
237                 SetGestureEventCallback();
238                 handle.SetGestureEnabled(Interop.ViewGesture.LongPress, true);
239                 _longPressedEventHandler += value;
240                 Log.Info(string.Format("LongPressed event handler is added"));
241             }
242             remove
243             {
244                 _longPressedEventHandler -= value;
245                 Log.Info(string.Format("LongPressed event handler is removed"));
246                 if (_longPressedEventHandler == null)
247                 {
248                     handle.SetGestureEnabled(Interop.ViewGesture.LongPress, false);
249                     UnsetGestureEventCallback();
250                 }
251             }
252         }
253
254         /// <summary>
255         /// Adds or removes event handlers to deliver a event representing the view is ready to be used.
256         /// </summary>
257         /// <value>Event handlers to get view ready event</value>
258         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
259         public event EventHandler ViewReady
260         {
261             add
262             {
263                 SetViewReadyEventCallback();
264                 _viewReadyEventHandler += value;
265                 Log.Info(string.Format("ViewReady event handler is added"));
266             }
267             remove
268             {
269                 _viewReadyEventHandler -= value;
270                 Log.Info(string.Format("ViewReady event handler is removed"));
271                 UnsetGestureEventCallback();
272             }
273         }
274
275         /// <summary>
276         /// Gets or sets current zoom level.
277         /// </summary>
278         /// <value>It is an integer value that representing current zoom level.</value>
279         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
280         /// <privilege>http://tizen.org/privilege/internet</privilege>
281         /// <privilege>http://tizen.org/privilege/network.get</privilege>
282         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
283         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
284         public int ZoomLevel
285         {
286             get
287             {
288                 return handle.ZoomLevel;
289             }
290             set
291             {
292                 Log.Info(string.Format("ZoomLevel is changed from {0} to {1}", handle.ZoomLevel, value));
293                 handle.ZoomLevel = value;
294             }
295         }
296
297         /// <summary>
298         /// Gets or sets minimum zoom level.
299         /// </summary>
300         /// <value>It is an integer value that limits minimal zoom level within range of current map plug-in supported.</value>
301         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
302         /// <privilege>http://tizen.org/privilege/internet</privilege>
303         /// <privilege>http://tizen.org/privilege/network.get</privilege>
304         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
305         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
306         public int MinimumZoomLevel
307         {
308             get
309             {
310                 return handle.MinimumZoomLevel;
311             }
312             set
313             {
314                 Log.Info(string.Format("MinimumZoomLevel is changed from {0} to {1}", handle.MinimumZoomLevel, value));
315                 handle.MinimumZoomLevel = value;
316             }
317         }
318
319         /// <summary>
320         /// Gets or sets maximum zoom level.
321         /// </summary>
322         /// <value>It is an integer value that limits maximum zoom level within range of current map plug-in supported.</value>
323         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
324         /// <privilege>http://tizen.org/privilege/internet</privilege>
325         /// <privilege>http://tizen.org/privilege/network.get</privilege>
326         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
327         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
328         public int MaximumZoomLevel
329         {
330             get
331             {
332                 return handle.MaximumZoomLevel;
333             }
334             set
335             {
336                 Log.Info(string.Format("MaximumZoomLevel is changed from {0} to {1}", handle.MaximumZoomLevel, value));
337                 handle.MaximumZoomLevel = value;
338             }
339         }
340
341         /// <summary>
342         /// Gets or sets orientation on the map view.
343         /// </summary>
344         /// <value>It is an integer value from 0 to 360 that indicates orientation of the map view</value>
345         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
346         /// <privilege>http://tizen.org/privilege/internet</privilege>
347         /// <privilege>http://tizen.org/privilege/network.get</privilege>
348         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
349         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
350         public double Orientation
351         {
352             get
353             {
354                 return handle.Orientation;
355             }
356             set
357             {
358                 Log.Info(string.Format("Orientation is changed from {0} to {1}", handle.Orientation, value));
359                 handle.Orientation = value;
360             }
361         }
362
363         /// <summary>
364         /// Gets or sets theme type of the map view.
365         /// </summary>
366         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
367         /// <privilege>http://tizen.org/privilege/internet</privilege>
368         /// <privilege>http://tizen.org/privilege/network.get</privilege>
369         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
370         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
371         public MapTypes MapType
372         {
373             get
374             {
375                 return (MapTypes)handle.MapType;
376             }
377             set
378             {
379                 Log.Info(string.Format("MapType is changed from {0} to {1}", handle.MapType, value));
380                 handle.MapType = (Interop.ViewType)value;
381             }
382         }
383
384         /// <summary>
385         /// Indicates whether the map should show the 3D buildings layer.
386         /// </summary>
387         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
388         /// <privilege>http://tizen.org/privilege/internet</privilege>
389         /// <privilege>http://tizen.org/privilege/network.get</privilege>
390         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
391         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
392         public bool BuildingsEnabled
393         {
394             get
395             {
396                 return handle.BuildingsEnabled;
397             }
398             set
399             {
400                 Log.Info(string.Format("Showing the 3D buildings is {0}", (value ? "enabled" : "disabled")));
401                 handle.BuildingsEnabled = value;
402             }
403         }
404
405         /// <summary>
406         /// Indicates whether the map should show the traffic layer.
407         /// </summary>
408         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
409         /// <privilege>http://tizen.org/privilege/internet</privilege>
410         /// <privilege>http://tizen.org/privilege/network.get</privilege>
411         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
412         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
413         public bool TrafficEnabled
414         {
415             get
416             {
417                 return handle.TrafficEnabled;
418             }
419             set
420             {
421                 Log.Info(string.Format("Showing the traffic is {0}", (value ? "enabled" : "disabled")));
422                 handle.TrafficEnabled = value;
423             }
424         }
425
426         /// <summary>
427         /// Indicates whether the map should show the public transit layer.
428         /// </summary>
429         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
430         /// <privilege>http://tizen.org/privilege/internet</privilege>
431         /// <privilege>http://tizen.org/privilege/network.get</privilege>
432         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
433         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
434         public bool PublicTransitEnabled
435         {
436             get
437             {
438                 return handle.PublicTransitEnabled;
439             }
440             set
441             {
442                 Log.Info(string.Format("Showing the public transit is {0}", (value ? "enabled" : "disabled")));
443                 handle.PublicTransitEnabled = value;
444             }
445         }
446
447         /// <summary>
448         /// Indicates whether the scale-bar is enabled or not.
449         /// </summary>
450         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
451         /// <privilege>http://tizen.org/privilege/internet</privilege>
452         /// <privilege>http://tizen.org/privilege/network.get</privilege>
453         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
454         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
455         public bool ScalebarEnabled
456         {
457             get
458             {
459                 return handle.ScalebarEnabled;
460             }
461             set
462             {
463                 Log.Info(string.Format("Showing the scale-bar is {0}", (value ? "enabled" : "disabled")));
464                 handle.ScalebarEnabled = value;
465             }
466         }
467
468         /// <summary>
469         /// Sets language of map view.
470         /// </summary>
471         /// <value>The display language in the map.
472         /// A language is specified as an ISO 3166 alpha-2 two letter country-code
473         /// followed by ISO 639-1 for the two-letter language code.
474         /// Each language tag is composed of one or more "subtags" separated by hyphens (-).
475         /// Each subtag is composed of basic Latin letters or digits only.
476         /// For example, "ko-KR" for Korean, "en-US" for American English.</value>
477         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
478         /// <privilege>http://tizen.org/privilege/internet</privilege>
479         /// <privilege>http://tizen.org/privilege/network.get</privilege>
480         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
481         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
482         /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
483         public string Language
484         {
485             get
486             {
487                 return handle.Language;
488             }
489             set
490             {
491                 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
492                 handle.Language = value;
493             }
494         }
495
496         /// <summary>
497         /// Gets or sets geographical coordinates for map view's center.
498         /// </summary>
499         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
500         /// <privilege>http://tizen.org/privilege/internet</privilege>
501         /// <privilege>http://tizen.org/privilege/network.get</privilege>
502         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
503         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
504         /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
505         public Geocoordinates Center
506         {
507             get
508             {
509                 return new Geocoordinates(handle.Center);
510             }
511             set
512             {
513                 Log.Info(string.Format("Center is changed from {0} to {1}", handle.Center, value.handle));
514                 handle.Center = value.handle;
515             }
516         }
517
518         /// <summary>
519         /// Gets a list of map object added to map view.
520         /// </summary>
521         public IEnumerable<MapObject> Children
522         {
523             get
524             {
525                 return _handleToObjectTable.Values;
526             }
527         }
528
529         /// <summary>
530         /// Changes geographical coordinates to screen coordinates.
531         /// </summary>
532         /// <param name="coordinates">Geographical coordinates</param>
533         /// <returns>Returns an instance of screen coordinates on the current screen</returns>
534         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
535         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
536         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
537         /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
538         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
539         public Point GeolocationToScreen(Geocoordinates coordinates)
540         {
541             return handle.GeolocationToScreen(coordinates.handle);
542         }
543
544         /// <summary>
545         /// Changes screen coordinates to geographical coordinates.
546         /// </summary>
547         /// <param name="screenCoordinates">Screen coordinates</param>
548         /// <returns>Returns an instance of geographical coordinates object.</returns>
549         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
550         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
551         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
552         /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
553         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
554         public Geocoordinates ScreenToGeolocation(Point screenCoordinates)
555         {
556             return new Geocoordinates(handle.ScreenToGeolocation(screenCoordinates));
557         }
558
559         /// <summary>
560         /// Adds a map object to map view.
561         /// </summary>
562         /// <param name="child">An instance of map object to be added</param>
563         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
564         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
565         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
566         /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
567         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
568         public void Add(MapObject child)
569         {
570             Log.Info(string.Format("Add a object"));
571             var objectHandle = child.GetHandle();
572             if (!_handleToObjectTable.ContainsKey(objectHandle))
573             {
574                 _handleToObjectTable[objectHandle] = child;
575                 handle.AddObject(objectHandle);
576
577                 // MapView take ownership of added map objects
578                 objectHandle.HasOwnership = false;
579             }
580         }
581
582         /// <summary>
583         /// Removes a map object from map view.
584         /// </summary>
585         /// <param name="child">An instance of map object to be removed</param>
586         /// <remarks>Once removed, the child object will be become invalid</remarks>
587         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
588         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
589         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
590         /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
591         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
592         public void Remove(MapObject child)
593         {
594             Log.Info(string.Format("Remove a object"));
595             var objectHandle = child.GetHandle();
596             if (_handleToObjectTable.Remove(objectHandle))
597             {
598                 handle.RemoveObject(child.GetHandle());
599
600                 // The object handle will be released automatically by the View, once RemoveObject call is successful
601                 child.InvalidateMapObject();
602             }
603         }
604
605         /// <summary>
606         /// Removes all map objects from map view.
607         /// </summary>
608         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
609         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
610         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
611         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
612         public void RemoveAll()
613         {
614             Log.Info(string.Format("Remove all of objects"));
615             foreach (var child in _handleToObjectTable.Values)
616             {
617                 child.InvalidateMapObject();
618             }
619             _handleToObjectTable.Clear();
620             handle.RemoveAllObjects();
621         }
622
623         /// <summary>
624         /// Captures a snapshot of map view
625         /// </summary>
626         /// <param name="type">Type of file format</param>
627         /// <param name="quality">A integer value which representing quality for encoding, from 1 to 100</param>
628         /// <param name="path">A string which representing The file path for snapshot</param>
629         /// <privilege>http://tizen.org/privilege/mapservice</privilege>
630         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
631         /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
632         /// <exception cref="System.ArgumentException">Thrown when the value is invalid.</exception>
633         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory, connect to service.</exception>
634         public void CaptureSnapshot(SnapshotType type, int quality, string path)
635         {
636             var err = Interop.ViewSnapshot.ViewCaptureSnapshot(handle, (Interop.ViewSnapshotFormatType)type, quality, path);
637             err.ThrowIfFailed("Failed to create snapshot for the view");
638         }
639
640         private void SetGestureEventCallback()
641         {
642             if (_gestureEventCallback == null)
643             {
644                 _gestureEventCallback = (type, eventData, userData) =>
645                 {
646                     if (type != Interop.ViewEventType.Gesture) return;
647                     var eventArg = new MapGestureEventArgs(eventData);
648                     switch (eventArg.GestureType)
649                     {
650                         case GestureType.Scroll: _scrolledEventHandler?.Invoke(this, eventArg); break;
651                         case GestureType.Zoom: _zoomedEventHandler?.Invoke(this, eventArg); break;
652                         case GestureType.Tap: _tappedEventHandler?.Invoke(this, eventArg); break;
653                         case GestureType.DoubleTap: _doubleTappedEventHandler?.Invoke(this, eventArg); break;
654                         case GestureType.TwoFingerTap: _twoFingerTappedEventHandler?.Invoke(this, eventArg); break;
655                         case GestureType.Rotate: _rotatedEventHandler?.Invoke(this, eventArg); break;
656                         case GestureType.LongPress: _longPressedEventHandler?.Invoke(this, eventArg); break;
657                     }
658                 };
659                 handle.SetEventCb(Interop.ViewEventType.Gesture, _gestureEventCallback, IntPtr.Zero);
660                 Log.Info(string.Format("Gesture event callback is set"));
661             }
662         }
663
664         private void UnsetGestureEventCallback()
665         {
666             if (_scrolledEventHandler != null || _zoomedEventHandler != null
667                 || _tappedEventHandler != null || _doubleTappedEventHandler != null
668                 || _twoFingerTappedEventHandler != null || _rotatedEventHandler != null
669                 || _longPressedEventHandler != null)
670             {
671                 return;
672             }
673
674             handle.UnsetEventCb(Interop.ViewEventType.Gesture);
675             _gestureEventCallback = null;
676             Log.Info(string.Format("Gesture event callback is unset"));
677         }
678
679         private void SetObjectEventCallback()
680         {
681             if (_objectEventCallback == null)
682             {
683                 _objectEventCallback = (type, eventData, userData) =>
684                 {
685                     if (type != Interop.ViewEventType.Object) return;
686                     var eventArg = new Interop.ObjectEventDataHandle(eventData);
687                     switch (eventArg.GestureType)
688                     {
689                         case Interop.ViewGesture.Tap:
690                             {
691                                 var mapObject = _handleToObjectTable[eventArg.ViewObject];
692                                 mapObject?.HandleClickedEvent();
693                                 break;
694                             }
695                     }
696                 };
697                 handle.SetEventCb(Interop.ViewEventType.Object, _objectEventCallback, IntPtr.Zero);
698                 Log.Info(string.Format("Object event callback is set"));
699             }
700         }
701
702         private void SetViewReadyEventCallback()
703         {
704             if (_viewReadyEventCallback == null)
705             {
706                 _viewReadyEventCallback = (type, eventData, userData) =>
707                 {
708                     _viewReadyEventHandler?.Invoke(this, EventArgs.Empty);
709                 };
710                 handle.SetEventCb(Interop.ViewEventType.Ready, _viewReadyEventCallback, IntPtr.Zero);
711                 Log.Info(string.Format("ViewReady event callback is set"));
712             }
713         }
714
715         private void UnsetViewReadyEventCallback()
716         {
717             if (_viewReadyEventHandler == null)
718             {
719                 handle.UnsetEventCb(Interop.ViewEventType.Ready);
720                 _viewReadyEventCallback = null;
721                 Log.Info(string.Format("ViewReady event callback is unset"));
722             }
723         }
724
725         #region IDisposable Support
726         private bool _disposedValue = false;
727
728         protected virtual void Dispose(bool disposing)
729         {
730             if (!_disposedValue)
731             {
732                 if (disposing)
733                 {
734                     _service.Dispose();
735                 }
736                 handle.Dispose();
737                 _disposedValue = true;
738             }
739         }
740
741         /// <summary>
742         /// Releases all resources used by this object.
743         /// </summary>
744         public void Dispose()
745         {
746             Dispose(true);
747             GC.SuppressFinalize(this);
748         }
749         #endregion
750     }
751 }