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.
25 public class Marker : MapObject, IDisposable
27 internal Interop.MarkerHandle handle;
29 internal Marker(Geocoordinates coordinates, string imagePath, Interop.ViewMarkerType type)
31 var err = Interop.ErrorCode.InvalidParameter;
32 if (coordinates == null || imagePath == null)
34 err.ThrowIfFailed("given coordinates or imagePath is null");
36 handle = new Interop.MarkerHandle(coordinates.handle, imagePath, type);
40 /// Gets or sets clicked event handlers.
42 public event EventHandler Clicked;
45 /// Gets or sets marker's visibility.
47 public override bool IsVisible
51 return handle.IsVisible;
55 handle.IsVisible = value;
60 /// Gets or sets geographical coordinates for this marker.
62 public Geocoordinates Coordinates
66 return new Geocoordinates(handle.Coordinates);
70 handle.Coordinates = value.handle;
72 // Marker takes ownership of the native handle.
73 value.handle.HasOwnership = false;
78 /// Gets or sets a string representing image file path for this marker.
80 public string ImagePath
84 return handle.ImageFile;
88 handle.ImageFile = value;
93 /// Gets or sets screen size for this marker.
95 public Size MarkerSize
99 return handle.MarkerSize;
103 handle.MarkerSize = value;
108 /// Gets or sets z-order for this marker.
110 /// <value>The integer value is 0 in default, and must be in range of from -100 to 100.</value>
115 return handle.ZOrder;
119 handle.ZOrder = value;
124 /// Changes marker size.
126 /// <param name="newSize">New size</param>
127 public void Resize(Size newSize)
129 MarkerSize = newSize;
133 /// Changes marker coordinates.
135 /// <param name="newPosition">New position for marker</param>
136 public void Move(Geocoordinates newPosition)
138 Coordinates = newPosition;
141 internal override void HandleClickedEvent()
143 Clicked?.Invoke(this, EventArgs.Empty);
146 internal override void InvalidateMapObject()
151 internal override Interop.ViewObjectHandle GetHandle()
156 #region IDisposable Support
157 private bool _disposedValue = false;
159 protected virtual void Dispose(bool disposing)
164 _disposedValue = true;
169 /// Releases all resources used by this object.
171 public void Dispose()
174 GC.SuppressFinalize(this);
182 /// Pin type marker map object
184 public class Pin : Marker
186 private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_pin_48.png";
189 /// Creates a Pin type marker.
191 /// <param name="coordinates">Marker coordinates</param>
192 /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
193 public Pin(Geocoordinates coordinates)
194 : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Pin)
199 /// Creates a Pin type marker.
201 /// <param name="coordinates">Marker coordinates</param>
202 /// <param name="imagePath">Image file path for Marker</param>
204 /// http://tizen.org/privilege/mediastorage is needed if the file path are relevant to media storage.
205 /// http://tizen.org/privilege/externalstorage is needed if the file path are relevant to external storage.
207 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
208 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
209 /// <exception cref="System.ArgumentException">Thrown when input coordinates or imagePath are invalid.</exception>
210 public Pin(Geocoordinates coordinates, string imagePath)
211 : base(coordinates, imagePath, Interop.ViewMarkerType.Pin)
217 /// Sticker type marker map object
219 public class Sticker : Marker
221 private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_sticker_48.png";
224 /// Creates a Sticker type marker.
226 /// <param name="coordinates">Marker coordinates</param>
227 /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
228 public Sticker(Geocoordinates coordinates)
229 : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Sticker)
234 /// Creates a Sticker type marker.
236 /// <param name="coordinates">Marker coordinates</param>
237 /// <param name="imagePath">Image file path for Marker</param>
239 /// http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
240 /// http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
242 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
243 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
244 /// <exception cref="System.ArgumentException">Thrown when input coordinates or imagePath are invalid.</exception>
245 public Sticker(Geocoordinates coordinates, string imagePath)
246 : base(coordinates, imagePath, Interop.ViewMarkerType.Sticker)