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 /// <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 clicked event handlers.
43 /// <since_tizen>3</since_tizen>
44 public event EventHandler Clicked;
47 /// Gets or sets 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 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 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 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 z-order for this marker.
116 /// <since_tizen>3</since_tizen>
117 /// <value>The integer value is 0 in default, and must be in range of from -100 to 100.</value>
122 return handle.ZOrder;
126 handle.ZOrder = value;
131 /// Changes 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 marker coordinates.
143 /// <since_tizen>3</since_tizen>
144 /// <param name="newPosition">New position for 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;
168 protected virtual void Dispose(bool disposing)
173 _disposedValue = true;
178 /// Releases all resources used by this object.
180 /// <since_tizen>3</since_tizen>
181 public void Dispose()
184 GC.SuppressFinalize(this);
192 /// Pin type marker map object
194 /// <since_tizen>3</since_tizen>
195 public class Pin : Marker
197 private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_pin_48.png";
200 /// Creates a Pin type marker.
202 /// <since_tizen>3</since_tizen>
203 /// <param name="coordinates">Marker coordinates</param>
204 /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
205 public Pin(Geocoordinates coordinates)
206 : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Pin)
211 /// Creates a Pin type marker.
213 /// <since_tizen>3</since_tizen>
214 /// <param name="coordinates">Marker coordinates</param>
215 /// <param name="imagePath">Image file path for Marker</param>
217 /// http://tizen.org/privilege/mediastorage is needed if the file path are relevant to media storage.
218 /// http://tizen.org/privilege/externalstorage is needed if the file path are relevant to external storage.
220 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
221 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
222 /// <exception cref="System.ArgumentException">Thrown when input coordinates or imagePath are invalid.</exception>
223 public Pin(Geocoordinates coordinates, string imagePath)
224 : base(coordinates, imagePath, Interop.ViewMarkerType.Pin)
230 /// Sticker type marker map object
232 /// <since_tizen>3</since_tizen>
233 public class Sticker : Marker
235 private const string defaultImagePath = "/usr/share/dotnet.tizen/framework/res/maps_marker_sticker_48.png";
238 /// Creates a Sticker type marker.
240 /// <since_tizen>3</since_tizen>
241 /// <param name="coordinates">Marker coordinates</param>
242 /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
243 public Sticker(Geocoordinates coordinates)
244 : base(coordinates, defaultImagePath, Interop.ViewMarkerType.Sticker)
249 /// Creates a Sticker type marker.
251 /// <since_tizen>3</since_tizen>
252 /// <param name="coordinates">Marker coordinates</param>
253 /// <param name="imagePath">Image file path for Marker</param>
255 /// http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
256 /// http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
258 /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
259 /// <exception cref="System.UnauthorizedAccessException">Thrown when application does not have some privilege to access this method.</exception>
260 /// <exception cref="System.ArgumentException">Thrown when input coordinates or imagePath are invalid.</exception>
261 public Sticker(Geocoordinates coordinates, string imagePath)
262 : base(coordinates, imagePath, Interop.ViewMarkerType.Sticker)