Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Add POI and Polyline #9

Closed
CartierPierre opened this issue Aug 16, 2017 · 4 comments
Closed

Add POI and Polyline #9

CartierPierre opened this issue Aug 16, 2017 · 4 comments

Comments

@CartierPierre
Copy link

Hello,
I'm trying to add some points of interest and trying to draw a polyline, but I don't see any function for that. There is no documentation. Have you any idea ?

@tuyen-vuduc
Copy link
Contributor

@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.

@fleuverouge
Copy link
Contributor

fleuverouge commented Aug 17, 2017

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 :)

@CartierPierre
Copy link
Author

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

@fleuverouge
Copy link
Contributor

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.

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

No branches or pull requests

3 participants