MVC5 and typescript with hosted files

129
0
03-21-2019 01:11 PM
SallyMurdock
New Contributor

Hopefully this helps someone else but here's how we setup ESRI javascript API within our MVC 5 that is also written in typescript and where we are hosting the ESRI files

<script> //see also: https://developers.arcgis.com/javascript/3/jshelp/inside_web_optimizer.html#use
define = undefined;

var dojoConfig = {
packages: [

/////////////////////////any non GIS modules used in GIS.ts need to be defined here/////////////////////
{
name: "GIS",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/GIS"
},
{
name: "collections",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/collections"
},
////////////////////////////////////////

/////////////////////////////need this imports for GIS/////////////////////////////////////
{
name: "dojo",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/dojo"
},
{
name: "dojox",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/dojox"
},
{
name: "dijit",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/dijit"
},
{
name: "esri",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/esri"
},
{
name: "dgrid",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/dgrid"
},
{
name: "dgrid1",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/dgrid1"
},
{
name: "moment",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/moment"
},
{
name: "dstore",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/dstore"
},
{
name: "put-selector",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/put-selector"
},
{
name: "xstyle",
location: location.pathname.replace(/\/[^/]+$/, "") + "/Scripts/app/xstyle"
},
/////////////////////////////////////////////////////////////////////
],
async: true
};
</script>

<script src="@(Url.Content("~/Scripts/app/dojo/dojo.js"))" data-dojo-config="async: true"></script>

<script>

$(function() {
var gisModule;

require(["GIS/GIS"],
function(GIS) {
gisModule = new GIS("@(JsonConvert.SerializeObject(gisViewData))");
});

@(refreshFilter) = function(filterSequence) {
console.log("refresh function javascript");
gisModule.LoadFilterAssets(filterSequence);
}
});


</script>


<link rel="stylesheet" type="text/css" href="@Url.Content("~/Scripts/app")/dijit/themes/claro/claro.css" />
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Scripts/app")/esri/css/esri.css" />

we downloaded the argis javascript API and dumped the contents into Scripts/app

we stored our typescript typings in Scripts/typings; You have to go and get the typings for dojo, digit, dstore, etc. The typings for arcgis are here

Tags (2)
0 Kudos
0 Replies