Eduardo Herrera
Eduardo Herrera

Reputation: 13

How to add a custom Point of Interest with MapBox in Unity

excuse me for my bad English. It's my first time using MapBox in Unity. I have the doubt of how to add a point of interest in a specific sector, as it would be a house or a local in particular. Also, I would like you to show me a message by approaching this point. I've been looking for documentation on the subject, but I do not find anything useful. Thank you so much for everything.

Upvotes: 0

Views: 1758

Answers (1)

Colin Young
Colin Young

Reputation: 3058

Spend some time exploring Mapbox Studio and getting a good understanding of datasets and tilesets and how they are created and relate to each other. That will make the following much easier to understand. To add new POIs from user input in Unity, here is a basic outline of what you'll need to do:

  1. Create a dataset in Mapbox (and, optionally, see below, a tileset)
  2. In Unity, perform a hit test to determine where the user has clicked. Use the AbstractMap GameObject to translate Unity coordinates to geographical coordinates.
  3. Use a Mapbox API to upload the data: a. Uploads API - multi-step process, but produces a tileset: https://docs.mapbox.com/help/tutorials/upload-curl/ b. Dataset API - will require you to read from the dataset later: https://docs.mapbox.com/api/maps/#insert-or-update-a-feature

If you used 3.a, you should be able to use the POI demo directly, since it gets its data from a tileset. See the explanation of the Data Explorer sample. Map Id is the id of your tileset.

If you use 3.b, you will need to write your own code to query the dataset API directly and use the provided methods to transform the geographical coordinate to Unity world space.

If you don't need to update your dataset in real time, you could update the dataset, then go into Mapbox Studio and manually update the tileset, at which point the new data would be available next time you run your Unity project. It all depends on your specific requirements.

Upvotes: 1

Related Questions