Share via

How to initialize RCL?

A Terentiev 85 Reputation points
2023-12-14T19:50:13.3566667+00:00

/Dear Gurus!

I want to make a wrapper over the library (mapbox-gl-js). Now I use in _hosts.cshtml:

<script src='https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.js'></script>

<link href='https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.css' rel='stylesheet' />

How I can do this in my RCL? How can the RCL initialize mapbox-gl-js? Should I call a static library C# method that initializes the JS?

Developer technologies | .NET | Blazor
Developer technologies | ASP.NET Core | Other
0 comments No comments

Answer accepted by question author

Bruce (SqlWork.com) 84,086 Reputation points
2023-12-14T21:47:40.8333333+00:00

you would use jsinterop to have js test if the files were loaded, and if not use javascript to load the script and css file.

load js file:
https://www.educative.io/answers/how-to-dynamically-load-a-js-file-in-javascript

load css file:
https://www.geeksforgeeks.org/how-to-load-css-files-using-javascript/

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.