Server type detection works exactly the same as file type detection. Let's add a detection function for a Tileserver /index.json
response and register it.
src/plugin/tileserver/mime.js
Let's test that.
test/plugin/tileserver/mime.test.js
Now have the plugin import it.
src/plugin/tileserver/tileserverplugin-server_ui-1.js
Now we need to make an Angular directive so the user has a form to give the server a title and potentially modify the URL.
src/plugin/tileserver/tileserverimport-server_ui-1.js
Note that we do not have our own UI template. We are reusing one from OpenSphere and just overriding a couple of functions in the controller.
Now let's hook that up in our plugin.
src/plugin/tileserver/tileserverplugin-server_ui-2.js
Save and run the build. Open the debug instance and go to Settings > Data Servers. You can now hit the little view icon on the Tileserver provider in that list. In addition, you can go to Add Data > Import File/URL and add the URL to the index.json
. It will pop up a UI for you to edit the title and the URL, as shown below:
Saving this should save a new persistent copy of the provider in Data Servers. Edit and Delete should also work as expected. Note that the user cannot edit or delete providers that are configured in settings.
The final step is getting the provider type to appear in the Data Servers > Add Server UI. This UI enumerates supported server types to allow importing a specific type.
First we'll create a directive to display the import form without the additional window content.
src/plugin/tileserver/tileserverimport-server_ui-2.js
Then we'll register the server type with the form UI.
src/plugin/tileserver/tileserverplugin-server_ui-3.js
Reload the debug application, then go to Settings > Data Servers > Add Server. You should now see a Tileserver option in the dropdown that will display the import UI.
That's pretty much it for providers. If you want to connect to a provider using formats not already supported by OpenSphere, then follow the file-parser
and file-layer-config
sections of the file-type-guide
.