Exemple #1
0
 public Task PanTo(string id, LatLngLiteral latLng)
 {
     return(_jsRuntime.JsonNetInvokeAsync <bool>(
                "googleMapJsFunctions.panTo",
                id,
                latLng));
 }
Exemple #2
0
 public Task SetCenter(string id, LatLngLiteral latLng)
 {
     return(_jsRuntime.JsonNetInvokeAsync <bool>(
                "googleMapJsFunctions.setCenter",
                id,
                latLng));
 }
 /// <summary>
 /// Change the center of the map.
 /// </summary>
 /// <param name="TheCenter">Location of center</param>
 /// <returns>A Task to wait on.</returns>
 public async Task CenterMap(LatLngLiteral TheCenter)
 {
     Options.Center = TheCenter;
     if (InteropObject != null)
     {
         await InteropObject.SetCenter(TheCenter);
     }
 }
 public Task SetCenter(LatLngLiteral latLng)
 {
     return(JsRuntime.InvokeWithDefinedGuidAndMethodAsync <object>(
                "googleMapJsFunctions.invoke",
                DivId,
                "setCenter",
                latLng));
 }
Exemple #5
0
    public static LatLngLiteral Compute2DPolygonCentroid(List <LatLngLiteral> vertices)
    {
        LatLngLiteral centroid = new LatLngLiteral()
        {
            Lat = 0.0, Lng = 0.0
        };
        double signedArea = 0.0;
        double x0         = 0.0; // Current vertex X
        double y0         = 0.0; // Current vertex Y
        double x1         = 0.0; // Next vertex X
        double y1         = 0.0; // Next vertex Y
        double a          = 0.0; // Partial signed area

        //If no vertices, then return empty
        if (vertices.Count == 0)
        {
            return(centroid);
        }

        // For all vertices except last
        int i = 0;

        for (i = 0; i < vertices.Count - 1; ++i)
        {
            x0            = vertices[i].Lat;
            y0            = vertices[i].Lng;
            x1            = vertices[i + 1].Lat;
            y1            = vertices[i + 1].Lng;
            a             = x0 * y1 - x1 * y0;
            signedArea   += a;
            centroid.Lat += (x0 + x1) * a;
            centroid.Lng += (y0 + y1) * a;
        }

        // Do last vertex
        x0            = vertices[i].Lat;
        y0            = vertices[i].Lng;
        x1            = vertices[0].Lat;
        y1            = vertices[0].Lng;
        a             = x0 * y1 - x1 * y0;
        signedArea   += a;
        centroid.Lat += (x0 + x1) * a;
        centroid.Lng += (y0 + y1) * a;

        signedArea   *= 0.5F;
        centroid.Lat /= (6 * signedArea);
        centroid.Lng /= (6 * signedArea);

        return(centroid);
    }
Exemple #6
0
        private static int isLeft(LatLngLiteral P0, LatLngLiteral P1, LatLngLiteral P2)
        {
            double calc = ((P1.Lng - P0.Lng) * (P2.Lat - P0.Lat)
                           - (P2.Lng - P0.Lng) * (P1.Lat - P0.Lat));

            if (calc > 0)
            {
                return(1);
            }
            else if (calc < 0)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
Exemple #7
0
        public static bool IsPointInPolygon(LatLngLiteral p, List <LatLngLiteral> poly)
        {
            int n = poly.Count();

            poly.Add(new LatLngLiteral {
                Lat = poly[0].Lat, Lng = poly[0].Lng
            });
            LatLngLiteral[] v = poly.ToArray();

            int wn = 0;    // the winding number counter

            // loop through all edges of the polygon
            for (int i = 0; i < n; i++)
            {                                              // edge from V[i] to V[i+1]
                if (v[i].Lat <= p.Lat)
                {                                          // start y <= P.y
                    if (v[i + 1].Lat > p.Lat)              // an upward crossing
                    {
                        if (isLeft(v[i], v[i + 1], p) > 0) // P left of edge
                        {
                            ++wn;                          // have a valid up intersect
                        }
                    }
                }
                else
                {                                          // start y > P.y (no test needed)
                    if (v[i + 1].Lat <= p.Lat)             // a downward crossing
                    {
                        if (isLeft(v[i], v[i + 1], p) < 0) // P right of edge
                        {
                            --wn;                          // have a valid down intersect
                        }
                    }
                }
            }
            if (wn != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #8
0
        public async Task RenderMap(Graph <VertexInfo, EdgeInfo> graph)
        {
            await ClearMap();

            // Add markers for each vertex
            foreach (var vertex in graph.Vertices)
            {
                _markers.Add(await Marker.CreateAsync(_map.JsRuntime, new MarkerOptions()
                {
                    Map       = _map.InteropObject,
                    Position  = new LatLngLiteral(vertex.Info.Position.Item2, vertex.Info.Position.Item1),
                    Clickable = false,
                    //Label = vertex.Info.Name,
                    Icon = new Icon()
                    {
                        Url = vertex.Info.Type switch
                        {
                            VertexType.Target => "icons/circle_green.svg",
                            VertexType.Base => "icons/home_black.svg",
                            VertexType.Both => "icons/home_green.svg",
                        },
Exemple #9
0
 public Point(LatLngLiteral latLng)
 {
     _latLng = latLng;
 }