I am having trouble activating an ArcGIS layer with a button game object.
I want the user to click on a button to activate an ArcGIS layer and make it visible. However, I cannot drag the ARCGIS layer on to the button component function. I have tried producing some code for the interaction, but no lucky yet. Does anyone know how to do this? Thanks
You can simply replace the service URL with your local file path such as "C:\\Data\\Mylayer.slpk"
Thanks! The script works, but it cannot be used twice. I want the script to to show and hide differnet maps on different buttons. It crashes my Unity Project if I use it twice.
Like a tile package from a file on your local computer
When I delete line 138 I get this error message.
That's strange you are having that error, it should have that namespace though. Is the SDK installed properly along with the sample packages?
I just tried to create a brand new scene and threw the same script there, I had no errors and everything was running fine.
On a side note, I'd also recommend you to have a read on the API tutorial to understand the detail step of the code I shared.
https://developers.arcgis.com/unity/maps/tutorials/display-a-map-api/
I just got it to work! Thank you so much for your help.
The issue was I had an old ArcGIS Unity Plugin installed. I created a new scene with the most up to date ArcGIS Plugin.
This script does not work if you want to use it on more than one button.
You can just add another button onclick event to the script if you want to add another button.
Unfortanely, that does not work.
Simply adding another button in the script as show below. Results in ArcGIS blanking out. No error message is shown, the plugin just stops working after I add a second.
public Button addBtn;
public Button addBtn2;