/// <summary> /// Draws a line string between the given place marks or points /// </summary> /// <param name="ge">The plug-in instance</param> /// <param name="start">The first placemark or point</param> /// <param name="end">The second placemark or point</param> /// <param name="id">Optional ID of the line string placemark. Default is empty</param> /// <param name="tessellate">Optionally sets tessellation for the line string. Default is true</param> /// <param name="addFeature">Optionally adds the line string directly to the plug-in. Default is true</param> /// <param name="width">Optional line string width, default is 1</param> /// <param name="color">Optional KmlColor, default is white/opaque</param> /// <returns>A line string placemark (or null)</returns> public static dynamic CreateLineString( dynamic ge, dynamic start, dynamic end, string id = "", bool tessellate = true, bool addFeature = true, int width = 1, KmlColor color = new KmlColor()) { if (!GEHelpers.IsGE(ge)) { throw new ArgumentException("ge is not of the type GEPlugin"); } if (GEHelpers.IsApiType(start, ApiType.KmlPlacemark)) { start = start.getGeometry(); } if (GEHelpers.IsApiType(end, ApiType.KmlPlacemark)) { end = end.getGeometry(); } dynamic placemark = null; try { placemark = CreatePlacemark(ge); dynamic lineString = ge.createLineString(id); lineString.setTessellate(Convert.ToUInt16(tessellate)); lineString.getCoordinates().pushLatLngAlt(start.getLatitude(), start.getLongitude(), start.getAltitude()); lineString.getCoordinates().pushLatLngAlt(end.getLatitude(), end.getLongitude(), end.getAltitude()); if (placemark.getStyleSelector() == null) { placemark.setStyleSelector(ge.createStyle(string.Empty)); } dynamic lineStyle = placemark.getStyleSelector().getLineStyle(); lineStyle.setWidth(width); lineStyle.getColor().set(color.ToString()); placemark.setGeometry(lineString); if (addFeature) { GEHelpers.AddFeaturesToPlugin(ge, placemark); } } catch (RuntimeBinderException rbex) { Debug.WriteLine("CreateLineString: " + rbex.Message, "KmlHelpers"); } return(placemark); }
/// <summary> /// Draws a line string between the given coordinates /// </summary> /// <param name="ge">The plug-in instance</param> /// <param name="coordinates">List of points</param> /// <param name="id">Optional ID of the line string placemark. Default is empty</param> /// <param name="tessellate">Optionally sets tessellation for the line string. Default is true</param> /// <param name="addFeature">Optionally adds the line string directly to the plug-in. Default is true</param> /// <param name="width">Optional line string-width, default is 1</param> /// <param name="color">Optional KmlColor, default is white/opaque</param> /// <returns>A line string placemark (or null)</returns> public static dynamic CreateLineString( dynamic ge, IList <Coordinate> coordinates, string id = "", bool tessellate = true, bool addFeature = true, int width = 1, KmlColor color = new KmlColor()) { if (!GEHelpers.IsGE(ge)) { throw new ArgumentException("ge is not of the type GEPlugin"); } dynamic placemark = null; try { placemark = CreatePlacemark(ge, addFeature: addFeature); dynamic lineString = ge.createLineString(id); lineString.setTessellate(Convert.ToUInt16(tessellate)); foreach (Coordinate c in coordinates) { lineString.getCoordinates().pushLatLngAlt(c.Latitude, c.Longitude, c.Altitude); } if (placemark.getStyleSelector() == null) { placemark.setStyleSelector(ge.createStyle(string.Empty)); } dynamic lineStyle = placemark.getStyleSelector().getLineStyle(); lineStyle.setWidth(width); lineStyle.getColor().set(color.ToString()); placemark.setGeometry(lineString); } catch (RuntimeBinderException rbex) { Debug.WriteLine("CreateLineString: " + rbex, "KmlHelpers"); } return(placemark); }