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.
18 using EvasObject = ElmSharp.EvasObject;
23 /// Overlay map object
25 public class Overlay : MapObject
27 private EvasObject _containedObject;
30 /// Creates normal overlay map object
32 /// <param name="coordinates"></param>
33 /// <param name="objectToContain"></param>
34 public Overlay(Geocoordinates coordinates, EvasObject objectToContain) : this(coordinates, objectToContain, Interop.ViewOverlayType.Normal)
38 internal Overlay(Interop.ViewObjectHandle nativeHandle) : base(nativeHandle)
42 internal Overlay(Geocoordinates coordinates, EvasObject objectToContain, Interop.ViewOverlayType type) : base(CreateNativeHandle(coordinates, objectToContain, type))
44 var err = Interop.ErrorCode.InvalidParameter;
45 if (coordinates == null || objectToContain == null)
47 err.ThrowIfFailed("given coordinates or parent evas object is null");
49 _containedObject = objectToContain;
53 /// Geographical coordinates for overlay
55 public Geocoordinates Coordinates
60 Interop.ViewObject.OverlayGetCoordinates(handle, out nativeHandle);
61 return new Geocoordinates(nativeHandle);
65 // Overlay takes ownership of the native handle.
67 var err = Interop.Coordinates.Clone(value.handle, out nativeHandle);
68 err.WarnIfFailed("Failed to clone native handle for coordinates");
70 Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(nativeHandle);
71 err = Interop.ViewObject.OverlaySetCoordinates(handle, clonedHandle);
72 if (err.WarnIfFailed("Failed to set coordinates to overlay"))
74 clonedHandle.ReleaseOwnership();
80 /// Minimum zoom level for overlay
82 public int MinimumZoomLevel
87 Interop.ViewObject.OverlayGetMinZoomLevel(handle, out value);
92 Interop.ViewObject.OverlaySetMinZoomLevel(handle, value);
97 /// Maximum zoom lever for overlay
99 public int MaximumZoomLevel
104 Interop.ViewObject.OverlayGetMaxZoomLevel(handle, out value);
109 Interop.ViewObject.OverlaySetMaxZoomLevel(handle, value);
113 private static Interop.ViewObjectHandle CreateNativeHandle(Geocoordinates coordinates, EvasObject objectToContain, Interop.ViewOverlayType type)
115 if (coordinates == null || objectToContain == null) return new Interop.ViewObjectHandle(IntPtr.Zero);
118 var err = Interop.Coordinates.Clone(coordinates.handle, out nativeHandle);
119 err.ThrowIfFailed("Failed to clone native handle for coordinates");
121 Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(nativeHandle);
122 err = Interop.ViewObject.CreateOverlay(clonedHandle, objectToContain, type, out nativeHandle);
123 err.ThrowIfFailed("Failed to create native handle for Overlay");
125 clonedHandle.ReleaseOwnership();
126 return new Interop.ViewObjectHandle(nativeHandle);
131 /// Bubble overlay map object
133 public class BubbleOverlay : Overlay
135 public BubbleOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Bubble)
141 /// Box Overlay map object
143 public class BoxOverlay : Overlay
146 /// Creates Box overlay
148 public BoxOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Box)