Coder Social home page Coder Social logo

Add POI and Polyline about mapbox-xamarin-forms HOT 4 CLOSED

naxam avatar naxam commented on August 11, 2024
Add POI and Polyline

from mapbox-xamarin-forms.

Comments (4)

tuyen-vuduc avatar tuyen-vuduc commented on August 11, 2024

@heraknos

Thank you for trying out our library. It's still in development and we only covers the case we need internally, not all cases covered by Mapbox.

Feel free to fork it, customize it and create a pull request.

Cheers.

from mapbox-xamarin-forms.

fleuverouge avatar fleuverouge commented on August 11, 2024

Hi @heraknos,
You can use PolylineAnnotation to draw polyline.

Firstly, initialize the annotations list of the mapview (which is recommended to be an observable collection):

mapview.Annotations = new ObservableCollection<Annotation>();

(We didn't create any AddAnnotation function since we found that using collections made binding easier).

Then create a polyline with predefined coordinates, or an observable collection of coordinates if you want to update them later:

var myPolyline = new PolylineAnnotation()
                    {
                        Id = "my_polyline",
                        Coordinates = new ObservableCollection<Position>(new Position[] { startingPoint })
};

If you already has a PolylineFeature, you may use it instead of this newly created annotation.
Finally, add it into the annotations list.

If you want to styling the line, you need to create a new ShapeSource and a LineLayer (no need to add the line into the annotations list):

var source = new ShapeSource("polyline_source", myPolyline);
mapView.MapStyle.CustomSources = new ObservableCollection<ShapeSource>(
    new ShapeSource[] { source }
) ;

var layer = new LineLayer("polyline_layer", "polyline_source")
     {
           LineWidth = 2.0
     };
mapview.MapStyle.CustomLayers = new ObservableCollection<Layer>(new Layer[] { layer });

Hope this'll help :)

from mapbox-xamarin-forms.

CartierPierre avatar CartierPierre commented on August 11, 2024

I will check that, thx.
Any other features for markers ?

from mapbox-xamarin-forms.

fleuverouge avatar fleuverouge commented on August 11, 2024

There are also PointAnnotation, MultiPolylineAnnotation and CircleLayer, which work similar to the example above. You can use CanShowCalloutChecker function to set whether callout view should be shown when user taps on a annotation (input is the annotation's Id). For example:

            mapview.CanShowCalloutChecker = (annotationId) =>
            {
                if (annotationId != null
                    && annotationId.StartsWith("my_prefix", StringComparison.CurrentCulture))
                {
                    return true;
                }
                return false;
            };

There's no function to customize the callout view yet though.

from mapbox-xamarin-forms.

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.