Coder Social home page Coder Social logo

Comments (3)

valentasm1 avatar valentasm1 commented on August 11, 2024

After checking samples i found this example.
Does it work for you?
Could you add you code if no.

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}",
                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"
            });

            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();
            });
        }

from blazorgooglemaps.

jeffsurcess avatar jeffsurcess commented on August 11, 2024

Hi @valentasm1
Sorry I didn't get notification of this reply but thanks for doing that. The code which worked well for me was:

        await marker.AddListener<MouseEvent>("dragend", async delegate (MouseEvent e)
        {
            await DoSomethingAsync(marker);
        });

Thanks.

from blazorgooglemaps.

valentasm1 avatar valentasm1 commented on August 11, 2024

Happy to hear.

from blazorgooglemaps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.