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