1
votes

I'm using Xamarin and have a Google Map added. For licensing reasons I want to replace google maps api by an alternative.

I found MapBox, which is working quite fine. Still I'm having some issues with MapBox.

  • Polyline
    I need to change the color of the line but PolyLine.Color is readonly.
    How can I change the color ?

  • Polyline
    I need to toggle visibility. This feature seems not to be implemented yet.
    It seems to be recently added to mapbox/mapbox-gl-native under #5663
    Any idea, when this would be picked by Xamarin?

  • Polyline
    I need to change the points afterwards. Again Points is just read only
    Is there is any way to access the points? (e.g. by using Handle ?!?)

  • Marker
    I need to toggle visibility. There is also no method implemented.
    Any Idea for a workaround?

1

1 Answers

0
votes

After a while I figured out these functions for Android:

    void PolylineOptions_SetWidth(PolylineOptions obj, float width)
    {
        try
        {
            Java.Lang.Reflect.Method method = obj.Class.GetMethod("width", new Java.Lang.Class[] { Java.Lang.Float.Type });
            method.Invoke(obj, new Java.Lang.Object[] { (Java.Lang.Float)(float)width });
        }
        catch (Java.Lang.SecurityException e)
        {
            // exception handling here
        }
        catch (Java.Lang.NoSuchMethodException e)
        {
            // exception handling here
        }
    }

    void PolylineOptions_SetColor(PolylineOptions obj, int col)
    {
        try
        {
            Java.Lang.Reflect.Method method = obj.Class.GetMethod("color", new Java.Lang.Class[] { Java.Lang.Integer.Type });
            method.Invoke(obj, new Java.Lang.Object[] { col });
        }
        catch (Java.Lang.SecurityException e)
        {
            // exception handling here
        }
        catch (Java.Lang.NoSuchMethodException e)
        {
            // exception handling here
        }
    }

    void PolylineOptions_SetAlpha(PolylineOptions obj, float col)
    {
        try
        {
            Java.Lang.Reflect.Method method = obj.Class.GetMethod("alpha", new Java.Lang.Class[] { Java.Lang.Float.Type });
            method.Invoke(obj, new Java.Lang.Object[] { col });
        }
        catch (Java.Lang.SecurityException e)
        {
            // exception handling here
        }
        catch (Java.Lang.NoSuchMethodException e)
        {
            // exception handling here
        }
    }

    void Polyline_SetAlpha(Polyline obj, float col)
    {
        try
        {
            Java.Lang.Reflect.Method method = obj.Class.GetMethod("alpha", new Java.Lang.Class[] { Java.Lang.Float.Type });
            method.Invoke(obj, new Java.Lang.Object[] { col });
        }
        catch (Java.Lang.SecurityException e)
        {
            // exception handling here
        }
        catch (Java.Lang.NoSuchMethodException e)
        {
            // exception handling here
        }
    }