Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker animation set and get dont work #84

Closed
markschroeder77 opened this issue Jan 1, 2021 · 6 comments
Closed

Marker animation set and get dont work #84

markschroeder77 opened this issue Jan 1, 2021 · 6 comments

Comments

@markschroeder77
Copy link
Contributor

Hi,

Can anyone confirm if marker animation works?

I tried:

var marker = await Marker.CreateAsync(map1.JsRuntime, new MarkerOptions()
{
Position = mapCenter,
Map = map1.InteropObject,
Animation = Animation.Bounce
});

but the marker doesn't bounce.

Thanks

valentasm1 pushed a commit that referenced this issue Jan 1, 2021
#84 BugFix. Added marker animations
@valentasm1
Copy link
Collaborator

@markschroeder77
Copy link
Contributor Author

markschroeder77 commented Jan 2, 2021

Thanks for the change.

It now works when you add the maker with an animation already set, however calling setAnimation() on an existing marker doesn't work.

getAnimation works if you allow for a nullable return type.

public async Task<Animation?> GetAnimation()
        {
            var animation = await _jsObjectRef.InvokeAsync<string>(
                "getAnimation");

            return Helper.ToNullableEnum<Animation>(animation);
        }

internal static T? ToNullableEnum<T>(string str)
            where T : struct
        {
            var enumType = typeof(T);

            if (str == "null")
                return null;

            foreach (var name in Enum.GetNames(enumType))
            {
                var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single();
                if (enumMemberAttribute.Value == str) return (T)Enum.Parse(enumType, name);
            }

            //throw exception or whatever handling you want
            return default;
        }

@valentasm1
Copy link
Collaborator

I will try to look into more next week

@valentasm1 valentasm1 changed the title Marker animation Marker animation set and get dont work Jan 14, 2021
@valentasm1
Copy link
Collaborator

Reopen if it dont work

@markschroeder77
Copy link
Contributor Author

I can now start the animation, but is there a way to stop it?
The only way I could get it to work was to make the Animation enum nullable and pass it as an int in the js interop.
Here is what I did https://github.com/markschroeder77/BlazorGoogleMaps

@valentasm1
Copy link
Collaborator

Thank you very much
https://www.nuget.org/packages/BlazorGoogleMaps/2.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants