Skip to content

Commit 41bc095

Browse files
committed
Added GoogleMapPolylineOptions
1 parent 22b31d4 commit 41bc095

File tree

6 files changed

+384
-1
lines changed

6 files changed

+384
-1
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Majorsoft.Blazor.Components.Maps.Google
8+
{
9+
/// <summary>
10+
/// PolylineOptions object used to define the properties that can be set on a Polyline.
11+
/// https://developers.google.com/maps/documentation/javascript/reference/polygon#Polyline
12+
/// </summary>
13+
public class GoogleMapPolylineOptions
14+
{
15+
public Guid Id { get; }
16+
17+
/// <summary>
18+
/// Indicates whether this Polyline handles mouse events. Defaults to true.
19+
/// </summary>
20+
public bool Clickable { get; set; }
21+
22+
/// <summary>
23+
/// If set to true, the user can drag this shape over the map. The geodesic property defines the mode of dragging. Defaults to false.
24+
/// </summary>
25+
public bool Draggable { get; set; }
26+
27+
/// <summary>
28+
/// If set to true, the user can edit this shape by dragging the control points shown at the vertices and on each segment. Defaults to false.
29+
/// </summary>
30+
public bool Editable { get; set; }
31+
32+
/// <summary>
33+
/// When true, edges of the polygon are interpreted as geodesic and will follow the curvature of the Earth. When false, edges of the polygon are rendered as
34+
/// straight lines in screen space. Note that the shape of a geodesic polygon may appear to change when dragged, as the dimensions are maintained relative to
35+
/// the surface of the earth. Defaults to false.
36+
/// </summary>
37+
public bool Geodesic { get; set; }
38+
39+
/// <summary>
40+
/// The icons to be rendered along the polyline.
41+
/// </summary>
42+
public GoogleMapIconSequence[] Icons { get; set; }
43+
44+
/// <summary>
45+
/// The ordered sequence of coordinates of the Polyline.
46+
/// </summary>
47+
public GoogleMapLatLng Path { get; set; }
48+
49+
/// <summary>
50+
/// The stroke color. All CSS3 colors are supported except for extended named colors.
51+
/// </summary>
52+
public string StrokeColor { get; set; }
53+
54+
/// <summary>
55+
/// The stroke opacity between 0.0 and 1.0.
56+
/// </summary>
57+
public double StrokeOpacity { get; set; }
58+
59+
/// <summary>
60+
/// The stroke width in pixels.
61+
/// </summary>
62+
public double StrokeWeight { get; set; }
63+
64+
/// <summary>
65+
/// Whether this polyline is visible on the map. Defaults to true.
66+
/// </summary>
67+
public bool Visible { get; set; }
68+
69+
/// <summary>
70+
/// The zIndex compared to other polys.
71+
/// </summary>
72+
public int ZIndex { get; set; }
73+
74+
public GoogleMapPolylineOptions()
75+
{
76+
Id = Guid.NewGuid();
77+
}
78+
}
79+
80+
/// <summary>
81+
/// Describes how icons are to be rendered on a line.
82+
/// </summary>
83+
public class GoogleMapIconSequence
84+
{
85+
/// <summary>
86+
/// If true, each icon in the sequence has the same fixed rotation regardless of the angle of the edge on which it lies. Defaults to false,
87+
/// in which case each icon in the sequence is rotated to align with its edge.
88+
/// </summary>
89+
public bool FixedRotation { get; set; }
90+
91+
/// <summary>
92+
/// The icon to render on the line.
93+
/// </summary>
94+
public GoogleMapIconSequenceSymbol Icon { get; set; }
95+
96+
/// <summary>
97+
/// The distance from the start of the line at which an icon is to be rendered. This distance may be expressed as a percentage of line's length
98+
/// (e.g. '50%') or in pixels (e.g. '50px'). Defaults to '100%'.
99+
/// </summary>
100+
public string Offset { get; set; }
101+
102+
/// <summary>
103+
/// The distance between consecutive icons on the line. This distance may be expressed as a percentage of the line's length (e.g. '50%') or in pixels
104+
/// (e.g. '50px'). To disable repeating of the icon, specify '0'. Defaults to '0'.
105+
/// </summary>
106+
public string Repeat { get; set; }
107+
}
108+
109+
/// <summary>
110+
/// Describes a symbol, which consists of a vector path with styling. A symbol can be used as the icon of a marker, or placed on a polyline.
111+
/// </summary>
112+
public class GoogleMapIconSequenceSymbol
113+
{
114+
/// <summary>
115+
/// The symbol's path, which is a built-in symbol path, or a custom path expressed using SVG path notation. Required.
116+
/// </summary>
117+
public string Path { get; set; }
118+
119+
/// <summary>
120+
/// The position at which to anchor an image in correspondence to the location of the marker on the map.
121+
/// By default, the anchor is located along the center point of the bottom of the image.
122+
/// </summary>
123+
public Point? Anchor { get; set; }
124+
125+
/// <summary>
126+
/// The symbol's fill color. All CSS3 colors are supported except for extended named colors. For symbol markers, this defaults to 'black'.
127+
/// For symbols on polylines, this defaults to the stroke color of the corresponding polyline.
128+
/// </summary>
129+
public string FillColor { get; set; }
130+
131+
/// <summary>
132+
/// The symbol's fill opacity. Defaults to 0.
133+
/// </summary>
134+
public double FillOpacity { get; set; }
135+
136+
/// <summary>
137+
/// The origin of the label relative to the top-left corner of the icon image, if a label is supplied by the marker.
138+
/// By default, the origin is located in the center point of the image.
139+
/// </summary>
140+
public Point? LabelOrigin { get; set; }
141+
142+
/// <summary>
143+
/// The angle by which to rotate the symbol, expressed clockwise in degrees. Defaults to 0. A symbol in an IconSequence where fixedRotation is false
144+
/// is rotated relative to the angle of the edge on which it lies.
145+
/// </summary>
146+
public double Rotation { get; set; }
147+
148+
/// <summary>
149+
/// The amount by which the symbol is scaled in size. For symbol markers, this defaults to 1; after scaling, the symbol may be of any size. For symbols on a polyline,
150+
/// this defaults to the stroke weight of the polyline; after scaling, the symbol must lie inside a square 22 pixels in size centered at the symbol's anchor.
151+
/// </summary>
152+
public double Scale { get; set; }
153+
154+
/// <summary>
155+
/// The symbol's stroke color. All CSS3 colors are supported except for extended named colors. For symbol markers, this defaults to 'black'.
156+
/// For symbols on a polyline, this defaults to the stroke color of the polyline.
157+
/// </summary>
158+
public string StrokeColor { get; set; }
159+
160+
/// <summary>
161+
/// The symbol's stroke opacity. For symbol markers, this defaults to 1. For symbols on a polyline, this defaults to the stroke opacity of the polyline.
162+
/// </summary>
163+
public double StrokeOpacity { get; set; }
164+
165+
/// <summary>
166+
/// The symbol's stroke weight. Defaults to the scale of the symbol.
167+
/// </summary>
168+
public double StrokeWeight { get; set; }
169+
170+
/// <summary>
171+
/// Default constructor.
172+
/// </summary>
173+
/// <param name="path">The symbol's path</param>
174+
public GoogleMapIconSequenceSymbol(string path)
175+
{
176+
if (string.IsNullOrWhiteSpace(path))
177+
{
178+
throw new ArgumentException($"'{nameof(path)}' cannot be null or whitespace", nameof(path));
179+
}
180+
181+
Path = path;
182+
}
183+
}
184+
}

src/Majorsoft.Blazor.Components.Maps/Google/GoogleMapService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ public async ValueTask<IJSObjectReference> GetDivAsync()
255255
return await _mapsJs.InvokeAsync<IJSObjectReference>("getDiv", MapContainerId);
256256
}
257257

258+
public async Task AddPolyline(params GoogleMapPolylineOptions[] googleMapPolylineOptions)
259+
{
260+
await CheckJsObjectAsync();
261+
await _mapsJs.InvokeAsync<IJSObjectReference>("polylineSetMap", MapContainerId, googleMapPolylineOptions);
262+
}
263+
258264

259265
private async Task CheckJsObjectAsync()
260266
{

src/Majorsoft.Blazor.Components.Maps/Google/IGoogleMapService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,12 @@ Task InitMapAsync(string apiKey,
195195
/// </summary>
196196
/// <returns>Async task</returns>
197197
ValueTask<IJSObjectReference> GetDivAsync();
198+
199+
/// <summary>
200+
///
201+
/// </summary>
202+
/// <param name="googleMapPolylineOptions"></param>
203+
/// <returns></returns>
204+
Task AddPolyline(params GoogleMapPolylineOptions[] googleMapPolylineOptions);
198205
}
199206
}

src/Majorsoft.Blazor.Components.Maps/Majorsoft.Blazor.Components.Maps.xml

Lines changed: 165 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)