asp.net-corearcgis-js-api

Arcgis maps SDK 4.27 with Asp.Net Core 3.1 MVC does not read require tag constructors


The below code works when launched when created as an html page in notepad. However, once I try to deploy as part of a Asp.net Core project it will not display unless i change the Arcgis SDK down to 4.15. Anything greater than SDK 4.16 will not work. Can't find any reason for this on the web. Below code returns error: Uncaught TypeError: MapView is not a constructor.

<link rel="stylesheet" href="https://js.arcgis.com/4.27/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.27/"></script>


<style>
    html,
    body,
    #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
    }
</style>

<script>
        
    require(["esri/WebMap", "esri/views/MapView", "esri/widgets/Editor"], (
        WebMap,
        MapView,
        Editor
    ) => {
        // Create a map from the referenced webmap item id
        const webmap = new WebMap({
            portalItem: {
                id: "4793230052ed498ebf1c7bed9966bd35"
            }
        });

        const view = new MapView({
            container: "viewDiv",
            map: webmap
        });

        view.when(() => {
            const editor = new Editor({
                view: view
            });

            // Add the widget to the view
            view.ui.add(editor, "top-right");
        });
    });
    
</script>

<div id="viewDiv"></div>


Solution

  • Had a hunch that this had something to with my page/view references conflicting js. By doing the following sdk 4.27 is no working.

    The way I got around was to comment out this section of the shared Asp.net Core App _layout.cshtml view

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
    @RenderSection("Scripts", required: false)
    

    As it appears to conflict with any arcgis sdk of higher than 4.15

    I also had to comment out the following in my view:

    section Scripts {
            @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
        }