How to change marker for locations other than destination in Mapbox?












5














For navigation feature in my app, I am using Mapbox SDK. Following is a snippet that I am using.



func showNavigationMap() {

let origin = Waypoint(coordinate: currentLocation.coordinate, name: "Your Location")

guard pickUpCoordinate != nil, dropOffCoordinate != nil else {
showAlertMessage("Locations not generated")
return
}

let pickUpLocation = Waypoint(coordinate: pickUpCoordinate, name: "Pickup Location")
let deliveryLocation = Waypoint(coordinate: dropOffCoordinate, name: "Delivery Location")

let options = NavigationRouteOptions(waypoints: [origin, pickUpLocation, deliveryLocation])

Directions.shared.calculate(options) { (waypoints, routes, error) in
guard let route = routes?.first else {
self.showAlertMessage("No possible routes detected")
return
}

self.mapNavigationViewController = NavigationViewController(for: route)

self.mapNavigationViewController.delegate = self

self.present(self.mapNavigationViewController, animated: true, completion: {
print("Navigation shown")
})
}
}


The sample screen is as shown below.



enter image description here



The first stop location is indicated as "1". I would like this location to be represented by some custom marker image. I have tried the mapbox documentation (https://www.mapbox.com/ios-sdk/navigation/examples/custom-destination-marker/). However, I could change the destination marker only. Is it possible to change the marker for the desired location?










share|improve this question





























    5














    For navigation feature in my app, I am using Mapbox SDK. Following is a snippet that I am using.



    func showNavigationMap() {

    let origin = Waypoint(coordinate: currentLocation.coordinate, name: "Your Location")

    guard pickUpCoordinate != nil, dropOffCoordinate != nil else {
    showAlertMessage("Locations not generated")
    return
    }

    let pickUpLocation = Waypoint(coordinate: pickUpCoordinate, name: "Pickup Location")
    let deliveryLocation = Waypoint(coordinate: dropOffCoordinate, name: "Delivery Location")

    let options = NavigationRouteOptions(waypoints: [origin, pickUpLocation, deliveryLocation])

    Directions.shared.calculate(options) { (waypoints, routes, error) in
    guard let route = routes?.first else {
    self.showAlertMessage("No possible routes detected")
    return
    }

    self.mapNavigationViewController = NavigationViewController(for: route)

    self.mapNavigationViewController.delegate = self

    self.present(self.mapNavigationViewController, animated: true, completion: {
    print("Navigation shown")
    })
    }
    }


    The sample screen is as shown below.



    enter image description here



    The first stop location is indicated as "1". I would like this location to be represented by some custom marker image. I have tried the mapbox documentation (https://www.mapbox.com/ios-sdk/navigation/examples/custom-destination-marker/). However, I could change the destination marker only. Is it possible to change the marker for the desired location?










    share|improve this question



























      5












      5








      5







      For navigation feature in my app, I am using Mapbox SDK. Following is a snippet that I am using.



      func showNavigationMap() {

      let origin = Waypoint(coordinate: currentLocation.coordinate, name: "Your Location")

      guard pickUpCoordinate != nil, dropOffCoordinate != nil else {
      showAlertMessage("Locations not generated")
      return
      }

      let pickUpLocation = Waypoint(coordinate: pickUpCoordinate, name: "Pickup Location")
      let deliveryLocation = Waypoint(coordinate: dropOffCoordinate, name: "Delivery Location")

      let options = NavigationRouteOptions(waypoints: [origin, pickUpLocation, deliveryLocation])

      Directions.shared.calculate(options) { (waypoints, routes, error) in
      guard let route = routes?.first else {
      self.showAlertMessage("No possible routes detected")
      return
      }

      self.mapNavigationViewController = NavigationViewController(for: route)

      self.mapNavigationViewController.delegate = self

      self.present(self.mapNavigationViewController, animated: true, completion: {
      print("Navigation shown")
      })
      }
      }


      The sample screen is as shown below.



      enter image description here



      The first stop location is indicated as "1". I would like this location to be represented by some custom marker image. I have tried the mapbox documentation (https://www.mapbox.com/ios-sdk/navigation/examples/custom-destination-marker/). However, I could change the destination marker only. Is it possible to change the marker for the desired location?










      share|improve this question















      For navigation feature in my app, I am using Mapbox SDK. Following is a snippet that I am using.



      func showNavigationMap() {

      let origin = Waypoint(coordinate: currentLocation.coordinate, name: "Your Location")

      guard pickUpCoordinate != nil, dropOffCoordinate != nil else {
      showAlertMessage("Locations not generated")
      return
      }

      let pickUpLocation = Waypoint(coordinate: pickUpCoordinate, name: "Pickup Location")
      let deliveryLocation = Waypoint(coordinate: dropOffCoordinate, name: "Delivery Location")

      let options = NavigationRouteOptions(waypoints: [origin, pickUpLocation, deliveryLocation])

      Directions.shared.calculate(options) { (waypoints, routes, error) in
      guard let route = routes?.first else {
      self.showAlertMessage("No possible routes detected")
      return
      }

      self.mapNavigationViewController = NavigationViewController(for: route)

      self.mapNavigationViewController.delegate = self

      self.present(self.mapNavigationViewController, animated: true, completion: {
      print("Navigation shown")
      })
      }
      }


      The sample screen is as shown below.



      enter image description here



      The first stop location is indicated as "1". I would like this location to be represented by some custom marker image. I have tried the mapbox documentation (https://www.mapbox.com/ios-sdk/navigation/examples/custom-destination-marker/). However, I could change the destination marker only. Is it possible to change the marker for the desired location?







      ios swift mapbox markers






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 5 at 10:24

























      asked Nov 16 at 5:45









      Sujal

      457413




      457413





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332100%2fhow-to-change-marker-for-locations-other-than-destination-in-mapbox%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332100%2fhow-to-change-marker-for-locations-other-than-destination-in-mapbox%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?