2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using Layout = ElmSharp.Layout;
20 using EvasObject = ElmSharp.EvasObject;
21 using System.Collections.Generic;
26 /// Map View class to show a map on the screen.
28 /// <since_tizen> 3 </since_tizen>
29 [Obsolete("Deprecated since API10. Might be removed in API12.")]
30 public class MapView : Layout, IDisposable
32 internal Interop.ViewHandle handle;
33 private MapService _service;
35 private Dictionary<IntPtr, MapObject> _handleToObjectTable = new Dictionary<IntPtr, MapObject>();
37 private Interop.ViewOnEventCallback _gestureEventCallback;
38 private Interop.ViewOnEventCallback _objectEventCallback;
39 private Interop.ViewOnEventCallback _viewReadyEventCallback;
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;
51 /// Creates a view and links it to the instance of a map service.
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)
63 handle = new Interop.ViewHandle(service.handle, this);
64 service.handle.HasOwnership = false;
65 Log.Info(string.Format("MapView is created"));
70 // We need to keep Gesture Tap event enabled for object event to work
71 handle.SetGestureEnabled(Interop.ViewGesture.Click, true);
72 SetObjectEventCallback();
76 /// Destroy the MapView object.
84 /// Adds or removes event handlers to deliver a scrolled gesture event.
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
94 SetGestureEventCallback();
95 handle.SetGestureEnabled(Interop.ViewGesture.Scroll, true);
96 _scrolledEventHandler += value;
97 Log.Info(string.Format("Scrolled event handler is added"));
101 _scrolledEventHandler -= value;
102 Log.Info(string.Format("Scrolled event handler is removed"));
103 if (_scrolledEventHandler == null)
105 handle.SetGestureEnabled(Interop.ViewGesture.Scroll, false);
106 UnsetGestureEventCallback();
112 /// Adds or removes event handlers to deliver a zoomed gesture event.
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
122 SetGestureEventCallback();
123 handle.SetGestureEnabled(Interop.ViewGesture.Zoom, true);
124 _twoFingerZoomedEventHandler += value;
125 Log.Info(string.Format("TwoFingerZoomed event handler is added"));
129 _twoFingerZoomedEventHandler -= value;
130 Log.Info(string.Format("TwoFingerZoomed event handler is removed"));
131 if (_twoFingerZoomedEventHandler == null)
133 handle.SetGestureEnabled(Interop.ViewGesture.Zoom, false);
134 UnsetGestureEventCallback();
140 /// Adds or removes event handlers to deliver a clicked gesture event.
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
150 SetGestureEventCallback();
151 //handle.SetGestureEnabled(Interop.ViewGesture.Click, true);
152 _clickedEventHandler += value;
153 Log.Info(string.Format("Clicked event handler is added"));
157 _clickedEventHandler -= value;
158 Log.Info(string.Format("Clicked event handler is removed"));
159 if (_clickedEventHandler == null)
161 //handle.SetGestureEnabled(Interop.ViewGesture.Click, false);
162 UnsetGestureEventCallback();
168 /// Adds or removes event handlers to deliver a double-clicked gesture event.
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
178 SetGestureEventCallback();
179 handle.SetGestureEnabled(Interop.ViewGesture.DoubleClick, true);
180 _doubleClickedEventHandler += value;
181 Log.Info(string.Format("DoubleClicked event handler is removed"));
185 _doubleClickedEventHandler -= value;
186 Log.Info(string.Format("DoubleClicked event handler is removed"));
187 if (_doubleClickedEventHandler == null)
189 handle.SetGestureEnabled(Interop.ViewGesture.DoubleClick, false);
190 UnsetGestureEventCallback();
196 /// Adds or removes event handlers to deliver a clicked gesture event with two-fingers.
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
206 SetGestureEventCallback();
207 handle.SetGestureEnabled(Interop.ViewGesture.TwoFingerClick, true);
208 _twoFingerClickedEventHandler += value;
209 Log.Info(string.Format("TwoFingerClicked event handler is added"));
213 _twoFingerClickedEventHandler -= value;
214 Log.Info(string.Format("TwoFingerClicked event handler is removed"));
215 if (_twoFingerClickedEventHandler == null)
217 handle.SetGestureEnabled(Interop.ViewGesture.TwoFingerClick, false);
218 UnsetGestureEventCallback();
224 /// Adds or removes event handlers to deliver a rotated gesture event.
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
234 SetGestureEventCallback();
235 handle.SetGestureEnabled(Interop.ViewGesture.Rotation, true);
236 _twoFingerRotatedEventHandler += value;
237 Log.Info(string.Format("Rotated event handler is added"));
241 _twoFingerRotatedEventHandler -= value;
242 Log.Info(string.Format("Rotated event handler is removed"));
243 if (_twoFingerRotatedEventHandler == null)
245 handle.SetGestureEnabled(Interop.ViewGesture.Rotation, false);
246 UnsetGestureEventCallback();
253 /// Adds or removes event handlers to deliver a long-pressed gesture event.
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
263 SetGestureEventCallback();
264 handle.SetGestureEnabled(Interop.ViewGesture.LongPress, true);
265 _longPressedEventHandler += value;
266 Log.Info(string.Format("LongPressed event handler is added"));
270 _longPressedEventHandler -= value;
271 Log.Info(string.Format("LongPressed event handler is removed"));
272 if (_longPressedEventHandler == null)
274 handle.SetGestureEnabled(Interop.ViewGesture.LongPress, false);
275 UnsetGestureEventCallback();
281 /// Adds or removes event handlers to deliver an event representing a view ready to be used.
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
291 SetViewReadyEventCallback();
292 _viewReadyEventHandler += value;
293 Log.Info(string.Format("ViewReady event handler is added"));
297 _viewReadyEventHandler -= value;
298 Log.Info(string.Format("ViewReady event handler is removed"));
299 UnsetGestureEventCallback();
304 /// Gets or sets the current zoom level.
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.")]
318 return handle.ZoomLevel;
322 Log.Info(string.Format("ZoomLevel is changed from {0} to {1}", handle.ZoomLevel, value));
323 handle.ZoomLevel = value;
328 /// Gets or sets the minimum zoom level.
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
342 return handle.MinimumZoomLevel;
346 Log.Info(string.Format("MinimumZoomLevel is changed from {0} to {1}", handle.MinimumZoomLevel, value));
347 handle.MinimumZoomLevel = value;
352 /// Gets or sets the maximum zoom level.
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
366 return handle.MaximumZoomLevel;
370 Log.Info(string.Format("MaximumZoomLevel is changed from {0} to {1}", handle.MaximumZoomLevel, value));
371 handle.MaximumZoomLevel = value;
376 /// Gets or sets the orientation on the map view.
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
390 return handle.Orientation;
394 Log.Info(string.Format("Orientation is changed from {0} to {1}", handle.Orientation, value));
395 handle.Orientation = value;
400 /// Gets or sets theme type of the map view.
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
413 return (MapTypes)handle.MapType;
417 Log.Info(string.Format("MapType is changed from {0} to {1}", handle.MapType, value));
418 handle.MapType = (Interop.ViewType)value;
423 /// Indicates whether the map should show the 3D buildings layer.
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
436 return handle.BuildingsEnabled;
440 Log.Info(string.Format("Showing the 3D buildings is {0}", (value ? "enabled" : "disabled")));
441 handle.BuildingsEnabled = value;
446 /// Indicates whether the map should show the traffic layer.
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
459 return handle.TrafficEnabled;
463 Log.Info(string.Format("Showing the traffic is {0}", (value ? "enabled" : "disabled")));
464 handle.TrafficEnabled = value;
469 /// Indicates whether the map should show the public transit layer.
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
482 return handle.PublicTransitEnabled;
486 Log.Info(string.Format("Showing the public transit is {0}", (value ? "enabled" : "disabled")));
487 handle.PublicTransitEnabled = value;
492 /// Indicates whether the scale-bar is enabled or not.
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
505 return handle.ScaleBarEnabled;
509 Log.Info(string.Format("Showing the scale-bar is {0}", (value ? "enabled" : "disabled")));
510 handle.ScaleBarEnabled = value;
515 /// Sets language of map view.
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
535 return handle.Language;
539 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
540 handle.Language = value;
545 /// Gets or sets geographical coordinates for map view's center.
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
559 return new Geocoordinates(handle.Center);
563 Log.Info(string.Format("Center is changed from {0} to {1}", handle.Center.ToString(), value.ToString()));
564 handle.Center = value.handle;
569 /// Gets a list of the map object added to map view.
571 /// <since_tizen> 3 </since_tizen>
572 [Obsolete("Deprecated since API10. Might be removed in API12.")]
573 public new IEnumerable<MapObject> Children
577 return _handleToObjectTable.Values;
582 /// Changes the geographical coordinates to screen coordinates.
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)
595 return handle.GeolocationToScreen(coordinates.handle);
599 /// Changes the screen coordinates to geographical coordinates.
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)
612 return new Geocoordinates(handle.ScreenToGeolocation(screenCoordinates));
616 /// Adds a map object to map view.
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)
628 Log.Info(string.Format("Add a object"));
629 var objectHandle = child.GetHandle();
630 if (!_handleToObjectTable.ContainsKey(objectHandle))
632 _handleToObjectTable[objectHandle] = child;
633 handle.AddObject(objectHandle);
635 // MapView take ownership of added map objects
636 objectHandle.HasOwnership = false;
641 /// Removes a map object from the map view.
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)
654 Log.Info(string.Format("Remove a object"));
655 var objectHandle = child.GetHandle();
656 if (_handleToObjectTable.Remove(objectHandle))
658 handle.RemoveObject(child.GetHandle());
660 // The object handle will be released automatically by the View, once RemoveObject call is successful
661 child.InvalidateMapObject();
666 /// Removes all map objects from the map view.
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()
676 Log.Info(string.Format("Remove all of objects"));
677 foreach (var child in _handleToObjectTable.Values)
679 child.InvalidateMapObject();
681 _handleToObjectTable.Clear();
682 handle.RemoveAllObjects();
686 /// Captures a snapshot of the map view.
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)
700 var err = Interop.ViewSnapshot.ViewCaptureSnapshot(handle, (Interop.ViewSnapshotFormatType)type, quality, path);
701 err.ThrowIfFailed("Failed to create snapshot for the view");
704 private void SetGestureEventCallback()
706 if (_gestureEventCallback == null)
708 _gestureEventCallback = (type, eventData, userData) =>
710 if (type != Interop.ViewEventType.Gesture) return;
711 var eventArg = new MapGestureEventArgs(eventData);
712 switch (eventArg.GestureType)
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;
723 handle.SetEventCb(Interop.ViewEventType.Gesture, _gestureEventCallback, IntPtr.Zero);
724 Log.Info(string.Format("Gesture event callback is set"));
728 private void UnsetGestureEventCallback()
730 if (_scrolledEventHandler != null || _twoFingerZoomedEventHandler != null
731 || _clickedEventHandler != null || _doubleClickedEventHandler != null
732 || _twoFingerClickedEventHandler != null || _twoFingerRotatedEventHandler != null
733 || _longPressedEventHandler != null)
738 handle.UnsetEventCb(Interop.ViewEventType.Gesture);
739 _gestureEventCallback = null;
740 Log.Info(string.Format("Gesture event callback is unset"));
743 private void SetObjectEventCallback()
745 if (_objectEventCallback == null)
747 _objectEventCallback = (type, eventData, userData) =>
749 if (type != Interop.ViewEventType.Object) return;
750 var eventArg = new Interop.ObjectEventDataHandle(eventData);
751 switch (eventArg.GestureType)
753 case Interop.ViewGesture.Click:
755 var mapObject = _handleToObjectTable[eventArg.ViewObject];
756 mapObject?.HandleClickedEvent();
761 handle.SetEventCb(Interop.ViewEventType.Object, _objectEventCallback, IntPtr.Zero);
762 Log.Info(string.Format("Object event callback is set"));
766 private void SetViewReadyEventCallback()
768 if (_viewReadyEventCallback == null)
770 _viewReadyEventCallback = (type, eventData, userData) =>
772 _viewReadyEventHandler?.Invoke(this, EventArgs.Empty);
774 handle.SetEventCb(Interop.ViewEventType.Ready, _viewReadyEventCallback, IntPtr.Zero);
775 Log.Info(string.Format("ViewReady event callback is set"));
779 private void UnsetViewReadyEventCallback()
781 if (_viewReadyEventHandler == null)
783 handle.UnsetEventCb(Interop.ViewEventType.Ready);
784 _viewReadyEventCallback = null;
785 Log.Info(string.Format("ViewReady event callback is unset"));
789 #region IDisposable Support
790 private bool _disposedValue = false;
793 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
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)
803 _handleToObjectTable?.Clear();
806 _service.handle.HasOwnership = true;
807 _disposedValue = true;
812 /// Releases all the resources used by this object.
814 /// <since_tizen> 3 </since_tizen>
815 [Obsolete("Deprecated since API10. Might be removed in API12.")]
816 public void Dispose()
819 GC.SuppressFinalize(this);