mapbox / mapbox/mapbox-navigation-ios

Remove waypoint

Open
#1,465 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

archived
Dominant language
Swift
Stars
918
Forks
326
Avg merge
1h 16m
Merged PRs (30d)
3

Description

Im trying to remove the waypoint after ive visited it, but im using custom waypoint markers using the waypointSymbolStyleLayer delegate method for navigationMapView.

```
var features = [MGLPointFeature]()
for waypoint in self.waypoints {
let feature = MGLPointFeature()
feature.coordinate = waypoint.coordinate
if let name = waypoint.name{
if name == "Pickup" || name == "Delivery"{
feature.attributes = ["type": name.lowercased()]
features.append(feature)
}
}
}
let deliveryImage = UIImage(named: "delivery")
let pickupImage = UIImage(named: "pickup")
let y = MGLShapeSource(identifier: "waypointLayer", features: features, options: nil)
mglSource = y
mapView.style?.addSource(mglSource)
mapView.style?.setImage(deliveryImage!.resizeImage(targetSize: CGSize(size: 40)), forName: "delivery")
mapView.style?.setImage(pickupImage!.resizeImage(targetSize: CGSize(size: 40)), forName: "pickup")
let x = MGLSymbolStyleLayer(identifier: "waypointLayer", source: mglSource)
x.iconImageName = NSExpression(forKeyPath: "type")
x.iconAllowsOverlap = NSExpression(forConstantValue: true)
x.iconIgnoresPlacement = NSExpression(forConstantValue: true)

return x
```

Thats my code inside the delegate. When I call .removeWaypoints, and then call .showWaypoints at the new legIndex, it crashes and tells me that the source "waypointLayer" is already there.

What am I doing wrong? Am I stylying my map wrong?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the navigationMapView waypointSymbolStyleLayer delegate method and trace how removeWaypoints and showWaypoints handle the MGLShapeSource and MGLSymbolStyleLayer using the "waypointLayer" identifier. Reproduce the crash, then verify that updating or removing waypoints no longer attempts to add a source that already exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.