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.
23 /// The marker map object.
25 /// <since_tizen> 3 </since_tizen>
26 public class Marker : MapObject, IDisposable
28 internal Interop.MarkerHandle handle;
30 internal Marker(Geocoordinates coordinates, string imagePath, Interop.ViewMarkerType type)
32 var err = Interop.ErrorCode.InvalidParameter;
33 if (coordinates == null || imagePath == null)
35 err.ThrowIfFailed("given coordinates or imagePath is null");
37 handle = new Interop.MarkerHandle(coordinates.handle, imagePath, type);
41 /// Gets or sets the clicked event handlers.
43 /// <since_tizen> 3 </since_tizen>
44 public event EventHandler Clicked;
47 /// Gets or sets the marker's visibility.
49 /// <since_tizen> 3 </since_tizen>
50 public override bool IsVisible
54 return handle.IsVisible;
58 handle.IsVisible = value;
63 /// Gets or sets the geographical coordinates for this marker.
65 /// <since_tizen> 3 </since_tizen>
66 public Geocoordinates Coordinates
70 return new Geocoordinates(handle.Coordinates);
74 handle.Coordinates = value.handle;
76 // Marker takes ownership of the native handle.
77 value.handle.HasOwnership = false;
82 /// Gets or sets a string representing the image file path for this marker.
84 /// <since_tizen> 3 </since_tizen>
85 public string ImagePath
89 return handle.ImageFile;
93 handle.ImageFile = value;
98 /// Gets or sets the screen size for this marker.
100 /// <since_tizen> 3 </since_tizen>
101 public Size MarkerSize
105 return handle.MarkerSize;
109 handle.MarkerSize = value;
114 /// Gets or sets the z-order for this marker.
116 /// <since_tizen> 3 </since_tizen>
117 /// <value>The integer value is 0 by default, and must be in the range of -100 to 100.</value>
122 return handle.ZOrder;
126 handle.ZOrder = value;
131 /// Changes the marker size.
133 /// <since_tizen> 3 </since_tizen>
134 /// <param name="newSize">New size.</param>
135 public void Resize(Size newSize)
137 MarkerSize = newSize;
141 /// Changes the marker coordinates.
143 /// <since_tizen> 3 </since_tizen>
144 /// <param name="newPosition">New position for the marker.</param>
145 public void Move(Geocoordinates newPosition)
147 Coordinates = newPosition;
150 internal override void HandleClickedEvent()
152 Clicked?.Invoke(this, EventArgs.Empty);
155 internal override void InvalidateMapObject()
160 internal override Interop.ViewObjectHandle GetHandle()
165 #region IDisposable Support
166 private bool _disposedValue = false;
169 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
171 /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
172 protected virtual void Dispose(bool disposing)
177 _disposedValue = true;
182 /// Releases all the resources used by this object.
184 /// <since_tizen> 3 </since_tizen>
185 public void Dispose()
188 GC.SuppressFinalize(this);
196 /// Pin type the marker map object.
198 /// <since_tizen> 3 </since_tizen>
199 public class Pin : Marker
201 private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_pin_48.png";
204 /// Creates a pin type marker.
206 /// <since_tizen> 3 </since_tizen>
207 /// <param name="coordinates">Marker coordinates.</param>
208 /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
209 public Pin(Geocoordinates coordinates)
210 : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Pin)
215 /// Creates a pin type marker.
217 /// <since_tizen> 3 </since_tizen>
218 /// <param name="coordinates">Marker coordinates.</param>
219 /// <param name="imagePath">Image file path for the Marker.</param>
221 /// http://tizen.org/privilege/mediastorage is needed if the file path is relevant to media storage.
222 /// http://tizen.org/privilege/externalstorage is needed if the file path is relevant to external storage.
224 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
225 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
226 /// <exception cref="System.ArgumentException">Thrown when the input coordinates or imagePath is invalid.</exception>
227 public Pin(Geocoordinates coordinates, string imagePath)
228 : base(coordinates, imagePath, Interop.ViewMarkerType.Pin)
234 /// Sticker type marker map object.
236 /// <since_tizen> 3 </since_tizen>
237 public class Sticker : Marker
239 private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_sticker_48.png";
242 /// Creates a sticker type marker.
244 /// <since_tizen> 3 </since_tizen>
245 /// <param name="coordinates">Marker coordinates.</param>
246 /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
247 public Sticker(Geocoordinates coordinates)
248 : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Sticker)
253 /// Creates a sticker type marker.
255 /// <since_tizen> 3 </since_tizen>
256 /// <param name="coordinates">Marker coordinates.</param>
257 /// <param name="imagePath">Image file path for Marker.</param>
259 /// http://tizen.org/privilege/mediastorage is needed if the input or output path are relevant to media storage.
260 /// http://tizen.org/privilege/externalstorage is needed if the input or output path are relevant to external storage.
262 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
263 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
264 /// <exception cref="System.ArgumentException">Thrown when the input coordinates or imagePath is invalid.</exception>
265 public Sticker(Geocoordinates coordinates, string imagePath)
266 : base(coordinates, imagePath, Interop.ViewMarkerType.Sticker)