Esempio n. 1
0
        private async Task <IEnumerable <Marker> > GetMarkers(IEnumerable <LatLngLiteral> coords, Map map)
        {
            var result = new List <Marker>(coords.Count());
            var index  = 1;

            foreach (var latLngLiteral in coords)
            {
                var marker = await Marker.CreateAsync(map1.JsRuntime, new MarkerOptions()
                {
                    Position = latLngLiteral,
                    Map      = map,
                    Label    = $"Test {index++}",
                    //Icon = new Icon()
                    //{
                    //    Url = "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"
                    //}
                    //Icon = "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"
                });

                result.Add(marker);
            }


            return(result);
        }
Esempio n. 2
0
        private async Task AddMarkerStyled()
        {
            var mapCenter = await map1.InteropObject.GetCenter();

            ZIndex++;

            var marker = await Marker.CreateAsync(map1.JsRuntime, new MarkerOptions()
            {
                Position = mapCenter,
                Map      = map1.InteropObject,
                ZIndex   = ZIndex,
                //Icon = new Symbol()
                //{
                //    Path = "M10.453 14.016l6.563-6.609-1.406-1.406-5.156 5.203-2.063-2.109-1.406 1.406zM12 2.016q2.906 0 4.945 2.039t2.039 4.945q0 1.453-0.727 3.328t-1.758 3.516-2.039 3.070-1.711 2.273l-0.75 0.797q-0.281-0.328-0.75-0.867t-1.688-2.156-2.133-3.141-1.664-3.445-0.75-3.375q0-2.906 2.039-4.945t4.945-2.039z"
                //},
                //Note that font properties are overriden in class
                //Please be cautious about versioning issues and some issues when using other tools
                //https://developers.google.com/maps/documentation/javascript/reference/marker#MarkerLabel.className
                Label = new MarkerLabel
                {
                    Text       = $"Test {markers.Count()}",
                    FontWeight = "bold",
                    Color      = "#5B32FF",
                    FontSize   = "24",
                    ClassName  = "map-marker-label",
                },
            });

            markers.Push(marker);

            return;
        }
Esempio n. 3
0
        private async Task AddMarker()
        {
            var mapCenter = await map1.InteropObject.GetCenter();

            ZIndex++;

            var marker = await Marker.CreateAsync(map1.JsRuntime, new MarkerOptions()
            {
                Position = mapCenter,
                Map      = map1.InteropObject,
                //Label = $"Test {markers.Count}",
                ZIndex = ZIndex,
                //CollisionBehavior = CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY,//2021-07 supported only in beta google maps version
                //Animation = Animation.Bounce
                //Icon = new Icon()
                //{
                //    Url = "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"
                //}
                //Icon = "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"
            });

            markers.Push(marker);

            //return;
            await bounds.Extend(mapCenter);

            var icon = await marker.GetIcon();

            Console.WriteLine($"Get icon result type is : {icon.Value?.GetType()}");

            icon.Switch(
                s => Console.WriteLine(s),
                i => Console.WriteLine(i.Url),
                _ => { });

            markers.Push(marker);

            await marker.AddListener <MouseEvent>("click", async e =>
            {
                var markerLabel = await marker.GetLabel();
                _events.Add("click on " + markerLabel);
                StateHasChanged();

                await e.Stop();
            });
        }
Esempio n. 4
0
        private async Task AddMarker()
        {
            var mapCenter = await map1.InteropObject.GetCenter();

            var marker = await Marker.CreateAsync(map1.JsRuntime, new MarkerOptions()
            {
                Position = mapCenter,
                Map      = map1.InteropObject,
                Label    = $"Test {markers.Count}",
                //Animation = Animation.Bounce
                //Icon = new Icon()
                //{
                //    Url = "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"
                //}
                //Icon = "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"
            });

            markers.Push(marker);

            return;

            await bounds.Extend(mapCenter);

            var icon = await marker.GetIcon();

            Console.WriteLine($"Get icon result type is : {icon.Value.GetType()}");

            icon.Switch(
                s => Console.WriteLine(s),
                i => Console.WriteLine(i.Url),
                _ => { });

            markers.Push(marker);

            await marker.AddListener <MouseEvent>("click", async e =>
            {
                var markerLabel = await marker.GetLabel();
                _events.Add("click on " + markerLabel);
                StateHasChanged();

                await e.Stop();
            });
        }
Esempio n. 5
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",
                        },
Esempio n. 6
0
 protected async Task <Marker> AddMarker(MarkerOptions TheMarkerOptions)
 {
     return(await Marker.CreateAsync(JsRuntime, TheMarkerOptions));
 }