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 /// Destroy the Marker object.
49 /// Gets or sets the clicked event handlers.
51 /// <since_tizen> 3 </since_tizen>
52 public event EventHandler Clicked;
55 /// Gets or sets the marker's visibility.
57 /// <since_tizen> 3 </since_tizen>
58 public override bool IsVisible
62 return handle.IsVisible;
66 handle.IsVisible = value;
71 /// Gets or sets the geographical coordinates for this marker.
73 /// <since_tizen> 3 </since_tizen>
74 public Geocoordinates Coordinates
78 return new Geocoordinates(handle.Coordinates);
82 handle.Coordinates = value.handle;
84 // Marker takes ownership of the native handle.
85 value.handle.HasOwnership = false;
90 /// Gets or sets a string representing the image file path for this marker.
92 /// <since_tizen> 3 </since_tizen>
93 public string ImagePath
97 return handle.ImageFile;
101 handle.ImageFile = value;
106 /// Gets or sets the screen size for this marker.
108 /// <since_tizen> 3 </since_tizen>
109 public Size MarkerSize
113 return handle.MarkerSize;
117 handle.MarkerSize = value;
122 /// Gets or sets the z-order for this marker.
124 /// <since_tizen> 3 </since_tizen>
125 /// <value>The integer value is 0 by default, and must be in the range of -100 to 100.</value>
130 return handle.ZOrder;
134 handle.ZOrder = value;
139 /// Changes the marker size.
141 /// <since_tizen> 3 </since_tizen>
142 /// <param name="newSize">New size.</param>
143 public void Resize(Size newSize)
145 MarkerSize = newSize;
149 /// Changes the marker coordinates.
151 /// <since_tizen> 3 </since_tizen>
152 /// <param name="newPosition">New position for the marker.</param>
153 public void Move(Geocoordinates newPosition)
155 Coordinates = newPosition;
158 internal override void HandleClickedEvent()
160 Clicked?.Invoke(this, EventArgs.Empty);
163 internal override void InvalidateMapObject()
168 internal override Interop.ViewObjectHandle GetHandle()
173 #region IDisposable Support
174 private bool _disposedValue = false;
177 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
179 /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
180 protected virtual void Dispose(bool disposing)
185 _disposedValue = true;
190 /// Releases all the resources used by this object.
192 /// <since_tizen> 3 </since_tizen>
193 public void Dispose()
196 GC.SuppressFinalize(this);
204 /// Pin type the marker map object.
206 /// <since_tizen> 3 </since_tizen>
207 public class Pin : Marker
209 private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_pin_48.png";
212 /// Creates a pin type marker.
214 /// <since_tizen> 3 </since_tizen>
215 /// <param name="coordinates">Marker coordinates.</param>
216 /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
217 public Pin(Geocoordinates coordinates)
218 : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Pin)
223 /// Creates a pin type marker.
225 /// <since_tizen> 3 </since_tizen>
226 /// <param name="coordinates">Marker coordinates.</param>
227 /// <param name="imagePath">Image file path for the Marker.</param>
229 /// http://tizen.org/privilege/mediastorage is needed if the file path is relevant to media storage.
230 /// http://tizen.org/privilege/externalstorage is needed if the file path is relevant to external storage.
232 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
233 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
234 /// <exception cref="System.ArgumentException">Thrown when the input coordinates or imagePath is invalid.</exception>
235 public Pin(Geocoordinates coordinates, string imagePath)
236 : base(coordinates, imagePath, Interop.ViewMarkerType.Pin)
242 /// Sticker type marker map object.
244 /// <since_tizen> 3 </since_tizen>
245 public class Sticker : Marker
247 private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_sticker_48.png";
250 /// Creates a sticker type marker.
252 /// <since_tizen> 3 </since_tizen>
253 /// <param name="coordinates">Marker coordinates.</param>
254 /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
255 public Sticker(Geocoordinates coordinates)
256 : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Sticker)
261 /// Creates a sticker type marker.
263 /// <since_tizen> 3 </since_tizen>
264 /// <param name="coordinates">Marker coordinates.</param>
265 /// <param name="imagePath">Image file path for Marker.</param>
267 /// http://tizen.org/privilege/mediastorage is needed if the input or output path are relevant to media storage.
268 /// http://tizen.org/privilege/externalstorage is needed if the input or output path are relevant to external storage.
270 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
271 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
272 /// <exception cref="System.ArgumentException">Thrown when the input coordinates or imagePath is invalid.</exception>
273 public Sticker(Geocoordinates coordinates, string imagePath)
274 : base(coordinates, imagePath, Interop.ViewMarkerType.Sticker)