POST
|
I am trying to use printTask as shown below, but it's not going in the printResult function. function printImage() {
var printTask;
var params = new PrintParameters();
if (sentScale == 1000) {
printTask = new PrintTask('http://10.10.100.50:6080/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
params.map = map;
}
else if (sentScale == 2500) {
printTask = new PrintTask('http://10.10.100.50:6080/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
params.map = map;
}
var template = new PrintTemplate();
template.format = 'JPG';
template.layout = 'MAP_ONLY';
template.preserveScale = false;
params.template = template;
console.log("params", params)
//printTask.execute(params).then(printResult);
printTask.execute(params, printResult);
}
// PRINT IMAGE
// PRINT RESULT
function printResult(evt) {
imageUrl = evt.url;
setCookie('imageUrl', imageUrl, 1);
if (reportType == 1) {
printReport();
}
if (reportType == 2) {
console.log("reporttype2 start")
var printTaskLegend;
var printPars = new PrintParameters();
printPars.map = map;
if (sentScale == 1000) {
console.log("reporttype2 1000")
printTaskLegend = new PrintTask('http://10.10.100.50:6080/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
printPars.map = map;
}
else if (sentScale == 2500) {
console.log("reporttype2 2500")
printTaskLegend = new PrintTask('http://10.10.100.50:6080/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
printPars.map = map;
}
var template = new PrintTemplate();
template.format = 'JPG';
template.layout = 'Print_legend_included';
template.preserveScale = true;
printPars.template = template;
printTaskLegend.execute(printPars, printImageLegend);
//printTaskLegend.execute(printPars).then(printImageLegend);
console.log("reporttype2 end")
}
} I am printing out the params with console.log in printImage and according to this, I think it ok? I tried to use both printTask.execute(params).then(printResult); as well as printTask.execute(params, printResult); but it just does not go into printResult. Anyone has any idea why?
... View more
10-03-2020
05:20 AM
|
0
|
3
|
592
|
POST
|
I am trying to import a Web Appbuilder app into my existing .net core web application. So far, I created a folder in wwwroot, called WebAppBuilder. All the content from the Web Appbuilder app, I moved to this folder. Then I moved the following files to wwwroot/js They were originally in the Web AppBuilder folder. I also added a controller with a view and copied the body from index.html to the view. @{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no">
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>ArcGIS Web Application</title>
<link rel="shortcut icon" href="images/shortcut.ico">
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="jimu.js/css/jimu-ie.css" />
<![endif]-->
<style type="text/css">
* {
box-sizing: border-box;
}
body,
html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#main-loading {
width: 100%;
height: 100%;
text-align: center;
overflow: hidden;
}
#main-loading #ie-note {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
#main-loading #ie-note {
width: 586px;
height: 253px;
background-image: url('images/notes.png');
padding: 0 30px 40px 30px;
font-size: 14px;
color: #596679;
}
#ie-note .hint-title {
height: 40px;
line-height: 48px;
text-align: left;
font-weight: bold;
}
#ie-note .hint-img {
background-image: url('images/hint.png');
background-position: left;
padding-left: 40px;
margin-top: 20px;
background-repeat: no-repeat;
height: 30px;
text-align: left;
line-height: 30px;
font-weight: bold;
}
#ie-note span {
display: block;
line-height: 14px;
}
#main-page {
display: none;
width: 100%;
height: 100%;
position: relative;
}
#jimu-layout-manager {
width: 100%;
height: 100%;
position: absolute;
}
</style>
<link rel="stylesheet" type="text/css" href="configs/loading/loading.css" />
<script>
/*******************************
* This is the function you can modify to customize the loading page
* This function will be invoked when one resource is loaded.
********************************/
// var progress;
// function loadingCallback(url, i, count) {
// var loading = document.getElementById('main-loading-bar');
// loading.setAttribute('title', url);
// if(!progress){
// progress = document.createElement('div');
// progress.setAttribute('class', 'loading-progress');
// loading.appendChild(progress);
// }
// progress.style.width = (((i - 1)/count) * 100) + '%';
// }
</script>
</head>
<body class="claro jimu-main-font">
<div id="main-loading">
<!-- This is section you can modify to customize the loading page -->
<div id="app-loading"></div>
<div id="loading-gif"></div>
<!-- ////////////////// END ////////////////////////////// -->
<div id="ie-note" style="display:none;">
<div class="hint-title">Error</div>
<div class="hint-img">Your browser is currently not supported.</div>
<p class="hint-text">
<span>
Please note that creating presentations is not supported in Internet Explorer versions 6, 7.
</span>
<br>
<span>
We recommend upgrading to the latest Internet Explorer, Google Chrome, or Firefox.
</span>
<br>
<span>
If you are using IE 8 or later, make sure you turn off "Compatibility View".
</span>
</p>
</div>
</div>
<div id="main-page">
<a role="link" id="trapLinkNode" tabindex="0">Trap Link Node</a>
<div id="jimu-layout-manager"></div>
<div id="skipContainer"></div>
</div>
<script src="~/js/env.js"></script>
<script src="~/js/init.js"></script>
<script src="~/js/simpleLoader.js"></script>
</body>
</html> The app builds successfully and runs, but when I navigate to the view I get errors in console. Would anyone have any idea why it can't find /load the resources? Also, why does it say loadResources is not defined?
... View more
08-05-2020
02:35 PM
|
0
|
1
|
619
|
POST
|
I am trying to import a Web Appbuilder app into my existing .net core web application. So far, I created a folder in wwwroot, called WebAppBuilder. All the content from the Web Appbuilder app, I moved to this folder. Then I moved the following files to wwwroot/js They were originally in the Web AppBuilder folder. I also added a controller with a view and copied the body from index.html to the view. @{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no">
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>ArcGIS Web Application</title>
<link rel="shortcut icon" href="images/shortcut.ico">
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="jimu.js/css/jimu-ie.css" />
<![endif]-->
<style type="text/css">
* {
box-sizing: border-box;
}
body,
html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#main-loading {
width: 100%;
height: 100%;
text-align: center;
overflow: hidden;
}
#main-loading #ie-note {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
#main-loading #ie-note {
width: 586px;
height: 253px;
background-image: url('images/notes.png');
padding: 0 30px 40px 30px;
font-size: 14px;
color: #596679;
}
#ie-note .hint-title {
height: 40px;
line-height: 48px;
text-align: left;
font-weight: bold;
}
#ie-note .hint-img {
background-image: url('images/hint.png');
background-position: left;
padding-left: 40px;
margin-top: 20px;
background-repeat: no-repeat;
height: 30px;
text-align: left;
line-height: 30px;
font-weight: bold;
}
#ie-note span {
display: block;
line-height: 14px;
}
#main-page {
display: none;
width: 100%;
height: 100%;
position: relative;
}
#jimu-layout-manager {
width: 100%;
height: 100%;
position: absolute;
}
</style>
<link rel="stylesheet" type="text/css" href="configs/loading/loading.css" />
<script>
/*******************************
* This is the function you can modify to customize the loading page
* This function will be invoked when one resource is loaded.
********************************/
// var progress;
// function loadingCallback(url, i, count) {
// var loading = document.getElementById('main-loading-bar');
// loading.setAttribute('title', url);
// if(!progress){
// progress = document.createElement('div');
// progress.setAttribute('class', 'loading-progress');
// loading.appendChild(progress);
// }
// progress.style.width = (((i - 1)/count) * 100) + '%';
// }
</script>
</head>
<body class="claro jimu-main-font">
<div id="main-loading">
<!-- This is section you can modify to customize the loading page -->
<div id="app-loading"></div>
<div id="loading-gif"></div>
<!-- ////////////////// END ////////////////////////////// -->
<div id="ie-note" style="display:none;">
<div class="hint-title">Error</div>
<div class="hint-img">Your browser is currently not supported.</div>
<p class="hint-text">
<span>
Please note that creating presentations is not supported in Internet Explorer versions 6, 7.
</span>
<br>
<span>
We recommend upgrading to the latest Internet Explorer, Google Chrome, or Firefox.
</span>
<br>
<span>
If you are using IE 8 or later, make sure you turn off "Compatibility View".
</span>
</p>
</div>
</div>
<div id="main-page">
<a role="link" id="trapLinkNode" tabindex="0">Trap Link Node</a>
<div id="jimu-layout-manager"></div>
<div id="skipContainer"></div>
</div>
<script src="~/js/env.js"></script>
<script src="~/js/init.js"></script>
<script src="~/js/simpleLoader.js"></script>
</body>
</html> The app builds successfully and runs, but when I navigate to the view I get errors in console. Would anyone have any idea why it can't find /load the resources? Also, why does it say loadResources is not defined?
... View more
08-05-2020
05:29 AM
|
0
|
0
|
473
|
POST
|
I am using printTask to print out my map but the end result is very weird. This is what the map should look like and this is what it actually looks like. It's like it's missing a layer or something function printResult(evt) {
map = new Map("map", {
basemap: new Basemap({
layers: [new BasemapLayer({
url: 'http://10.0.0.10:6080/arcgis/rest/services/DUP_podlogi_Izvodi/MapServer'
})]
}),
extent: new Extent({
'xmin': 7530850.8094923375,
'ymin': 4647910.133863028,
'xmax': 7536270.404088697,
'ymax': 4655172.52276435,
'spatialReference': {
'wkid': 6316
}
}),
sliderStyle: 'small',
zoom: 5,
});
var secondLayer = new ArcGISDynamicMapServiceLayer("http://10.0.0.10:6080/arcgis/rest/services/Karpos_Vector_Izvodi/MapServer", {
"opacity": 1
});
map.addLayer(secondLayer);
map.on("load", selectRoute);
// code shortened for brevity
printTaskLegend = new PrintTask('http://10.0.0.10/arcgis/rest/services/Print_GISKarpos_Sync/GPServer/Export%20Web%20Map');
printPars.map = map;
var template = new PrintTemplate();
template.format = 'JPG';
template.layout = 'Print_legend_included';
template.preserveScale = true;
printPars.template = template;
printTaskLegend.execute(printPars).then(printImageLegend);
} This is my code.
... View more
07-09-2020
02:48 PM
|
0
|
1
|
430
|
POST
|
I am trying to figure out why my printTask is not working when I host my .NET Core app on a server. It works locally, when I run the code via Visual Studio but not when I publish and host the app. For example, it works on line 12 in the code below. queryTask.execute(query).then(zoomToRoute) works but it does not work. I am not sure how or why it works when I run the app via Visual Studio but all I know is, it doesn't work when I host the app. Anyone with any insight will help me out, so please feel free to share any opinion. function printMap() {
require(["dojo/on", "esri/config", "esri/tasks/QueryTask", "esri/tasks/query", 'esri/symbols/SimpleMarkerSymbol', "esri/symbols/SimpleLineSymbol", "esri/Color", 'esri/geometry/Extent', "esri/tasks/PrintTask", "esri/tasks/PrintParameters", "esri/tasks/PrintTemplate", "dojo/domReady!"],
function (on, esriConfig, QueryTask, Query, SimpleMarkerSymbol, SimpleLineSymbol, Color, Extent, PrintTask, PrintParameters, PrintTemplate) {
console.log("globalParcel :: " + globalParcel + " reportType :: " + reportType + " globalScale :: " + sentScale);
//esriConfig.defaults.io.corsEnabledServers.push("http://localhost:60024");
var queryTask = new QueryTask("https://app.gdi.mk:6443/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer/1");
var query = new Query();
query.where = "code ='" + globalParcel + "'";
query.outSpatialReference = map.spatialReference;
query.returnGeometry = true;
query.outFields = ["*"];
queryTask.execute(query).then(zoomToRoute);
// ZOOM TO ROUTE
function zoomToRoute(features) {
console.log("zoomtoroute start" );
var map = this.map;
map.graphics.clear();
var pointSymbolNew = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 255]), 1), new Color([255, 0, 127, 1]));
var selectedFeature = features.features;
selectedFeature[0].setSymbol(pointSymbolNew);
map.graphics.add(selectedFeature[0]);
map.setScale(sentScale);
map.centerAt(selectedFeature[0].geometry);
setTimeout(printImage, 1000);
console.log("zoomtoroute end");
}
// ZOOM TO ROUTE
// PRINT IMAGE
function printImage() {
console.log("printImage start");
var printTask;
var params = new PrintParameters();
if (sentScale == 1000) {
printTask = new PrintTask('https://app.gdi.mk:6443/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
params.map = map;
}
else if (sentScale == 2500) {
printTask = new PrintTask('https://app.gdi.mk:6443/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
params.map = map;
}
var template = new PrintTemplate();
template.format = 'JPG';
template.layout = 'MAP_ONLY';
template.preserveScale = false;
params.template = template;
//printTask.execute(params).then(printResult);
printTask.execute(params, printResult);
console.log("printImage end");
console.log("params", params);
}
// PRINT IMAGE
// PRINT RESULT
function printResult(evt) {
console.log("printResult start")
imageUrl = evt.url;
setCookie('imageUrl', imageUrl, 1);
if (reportType == 1) {
console.log("reportType == 1")
printReport();
}
if (reportType == 2) {
console.log("reportType == 2")
var printTaskLegend;
var printPars = new PrintParameters();
printPars.map = map;
if (sentScale == 1000) {
console.log("sentScale == 1000")
printTaskLegend = new PrintTask('https://app.gdi.mk:6443/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
printPars.map = map;
}
else if (sentScale == 2500) {
console.log("sentScale == 2500")
printTaskLegend = new PrintTask('https://app.gdi.mk:6443/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
printPars.map = map;
}
var template = new PrintTemplate();
template.format = 'JPG';
template.layout = 'Print_legend_included';
template.preserveScale = true;
printPars.template = template;
printTaskLegend.execute(printPars, printImageLegend);
//printTaskLegend.execute(printPars).then(printImageLegend);
console.log("printTaskLegend.execute")
console.log("printResult end")
}
}
... View more
07-08-2020
04:45 AM
|
0
|
0
|
331
|
POST
|
I am trying to figure out why my printTask is not working when I host my .NET Core app on a server. It works locally, when I run the code via Visual Studio but not when I publish and host the app. For example, it works on line 12 in the code below. queryTask.execute(query).then(zoomToRoute) works but it does not work. I am not sure how or why it works when I run the app via Visual Studio but all I know is, it doesn't work when I host the app. Anyone with any insight will help me out, so please feel free to share any opinion. function printMap() {
require(["dojo/on", "esri/config", "esri/tasks/QueryTask", "esri/tasks/query", 'esri/symbols/SimpleMarkerSymbol', "esri/symbols/SimpleLineSymbol", "esri/Color", 'esri/geometry/Extent', "esri/tasks/PrintTask", "esri/tasks/PrintParameters", "esri/tasks/PrintTemplate", "dojo/domReady!"],
function (on, esriConfig, QueryTask, Query, SimpleMarkerSymbol, SimpleLineSymbol, Color, Extent, PrintTask, PrintParameters, PrintTemplate) {
console.log("globalParcel :: " + globalParcel + " reportType :: " + reportType + " globalScale :: " + sentScale);
//esriConfig.defaults.io.corsEnabledServers.push("http://localhost:60024");
var queryTask = new QueryTask("https://app.gdi.mk:6443/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer/1");
var query = new Query();
query.where = "code ='" + globalParcel + "'";
query.outSpatialReference = map.spatialReference;
query.returnGeometry = true;
query.outFields = ["*"];
queryTask.execute(query).then(zoomToRoute);
// ZOOM TO ROUTE
function zoomToRoute(features) {
console.log("zoomtoroute start" );
var map = this.map;
map.graphics.clear();
var pointSymbolNew = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 255]), 1), new Color([255, 0, 127, 1]));
var selectedFeature = features.features;
selectedFeature[0].setSymbol(pointSymbolNew);
map.graphics.add(selectedFeature[0]);
map.setScale(sentScale);
map.centerAt(selectedFeature[0].geometry);
setTimeout(printImage, 1000);
console.log("zoomtoroute end");
}
// ZOOM TO ROUTE
// SET COOKIE
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
// SET COOKIE
// PRINT IMAGE
function printImage() {
console.log("printImage start");
var printTask;
var params = new PrintParameters();
if (sentScale == 1000) {
printTask = new PrintTask('https://app.gdi.mk:6443/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
params.map = map;
}
else if (sentScale == 2500) {
printTask = new PrintTask('https://app.gdi.mk:6443/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
params.map = map;
}
var template = new PrintTemplate();
template.format = 'JPG';
template.layout = 'MAP_ONLY';
template.preserveScale = false;
params.template = template;
//printTask.execute(params).then(printResult);
printTask.execute(params, printResult);
console.log("printImage end");
console.log("params", params);
}
// PRINT IMAGE
// PRINT RESULT
function printResult(evt) {
console.log("printResult start")
imageUrl = evt.url;
setCookie('imageUrl', imageUrl, 1);
if (reportType == 1) {
console.log("reportType == 1")
printReport();
}
if (reportType == 2) {
console.log("reportType == 2")
var printTaskLegend;
var printPars = new PrintParameters();
printPars.map = map;
if (sentScale == 1000) {
console.log("sentScale == 1000")
printTaskLegend = new PrintTask('https://app.gdi.mk:6443/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
printPars.map = map;
}
else if (sentScale == 2500) {
console.log("sentScale == 2500")
printTaskLegend = new PrintTask('https://app.gdi.mk:6443/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
printPars.map = map;
}
var template = new PrintTemplate();
template.format = 'JPG';
template.layout = 'Print_legend_included';
template.preserveScale = true;
printPars.template = template;
printTaskLegend.execute(printPars, printImageLegend);
//printTaskLegend.execute(printPars).then(printImageLegend);
console.log("printTaskLegend.execute")
console.log("printResult end")
}
}
... View more
07-08-2020
04:23 AM
|
0
|
0
|
402
|
POST
|
Noah Sager Since I cannot provide you with a Codepen, I'll try it like this. I replaced my satellite basemap with this one, I thought that might be the issue. I set the proper WKID and extent. Aaaand here is my printMap() function called on the click of the "Print map" button. In the printMap() function, I call the zoomToRoute() function which I use to zoom on a point. So, when I click the Print map button once, it takes me here - at the X, marked on the map. And I zoomed out quite a bit to shop the point on the map, which I also highlighted. So it zooms me quite a bit off point. But if I click the Print map button again, it takes me to the correct point on the map. I tried to use map.centerAndZoom as well as map.centerAt but the same thing happens. And the weirdest part of all is that I get this warning /error in the console Map: Geometry (wkid: 4326) cannot be converted to spatial reference of the map (wkid: 6316) I tripled checked all my layers /services. They are all the correct WKID, the one I need is 6316.
... View more
07-02-2020
06:59 AM
|
0
|
0
|
936
|
POST
|
I'm trying to provide you with a codepen but my feature layers are not public, I'll try to get a working codepen version
... View more
07-01-2020
04:14 PM
|
0
|
0
|
936
|
POST
|
I tried that out and it just zooms me further away than before
... View more
07-01-2020
03:55 PM
|
0
|
2
|
936
|
POST
|
So I am trying to zoom in on a point with my following function but it zooms me way off course, far from the point which I need to be zoomed at. map = new Map("map", { basemap: "satellite", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd center: [21.403316, 42.002183], zoom: 10 }); var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://62.162.113.130:6080/arcgis/rest/services/DUP_podlogi_Izvodi/MapServer", { "opacity": 1 }); var secondLayer = new ArcGISDynamicMapServiceLayer("https://app.gdi.mk:6443/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer", { "opacity": 1 }); map.addLayers([dynamicMapServiceLayer, secondLayer]); map.on("load", selectRoute); function zoomToRoute(features) { var num = features.features.length; var map = this.map; function zoomToRoute(features) { var num = features.features.length; var map = this.map; map.graphics.clear(); var pointSymbolNew = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 255]), 1), new Color([255, 0, 127, 1])); var selectedFeature = features.features; selectedFeature[0].setSymbol(pointSymbolNew); map.graphics.add(selectedFeature[0]); var lat = selectedFeature[0].geometry.x; //getLatitude(); var longs = selectedFeature[0].geometry.y; //getLongitude(); var point = new esri.geometry.Point({ latitude: lat, longitude: longs }); map.centerAndZoom(point, 3); var factor = 3; //some factor for converting point to extent --> var extent = new Extent(lat - factor, longs - factor, lat + factor, longs + factor, map.spatialReference); map.setExtent(extent); map.setScale(sentScale); setTimeout(printImage, 1000); } I tried increasing and decreasing the factor value but still nothing. I also increased and decreased the levelOrFactor of centerAndZoom and it didn't help. Anyone has any idea what I'm doing wrong that it zooms me far off point?
... View more
07-01-2020
05:59 AM
|
0
|
6
|
1032
|
POST
|
So, I'm printing a map on the click of a button. I am zooming at a certain point but the map is showing on the second click on the print button. This is my code where I am querying the map, zooming, printing the image, etc. What could be the issue for the map? function printMap() { require(["dojo/on", "esri/config", "esri/tasks/QueryTask", "esri/tasks/query", 'esri/symbols/SimpleMarkerSymbol', "esri/symbols/SimpleLineSymbol", "esri/Color", 'esri/geometry/Extent', "esri/tasks/PrintTask", "esri/tasks/PrintParameters", "esri/tasks/PrintTemplate", "dojo/domReady!"], function (on, esriConfig, QueryTask, Query, SimpleMarkerSymbol, SimpleLineSymbol, Color, Extent, PrintTask, PrintParameters, PrintTemplate) { console.log("globalParcel :: " + globalParcel + " reportType :: " + reportType + " globalScale :: " + sentScale); var queryTask = new QueryTask("https://service.com"); var query = new Query(); query.where = "code ='" + globalParcel + "'"; query.outSpatialReference = map.spatialReference; query.returnGeometry = true; query.outFields = ["*"]; queryTask.execute(query, zoomToRoute); // ZOOM TO ROUTE function zoomToRoute(features) { var num = features.features.length; var map = this.map; map.graphics.clear(); var pointSymbolNew = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 255]), 1), new Color([255, 0, 127, 1])); var selectedFeature = features.features; selectedFeature[0].setSymbol(pointSymbolNew); map.graphics.add(selectedFeature[0]); var lat = selectedFeature[0].geometry.x; //getLatitude(); var longs = selectedFeature[0].geometry.y; //getLongitude(); var point = new esri.geometry.Point({ latitude: lat, longitude: longs }); map.centerAt(point); var factor = 3; //some factor for converting point to extent --> var extent = new Extent(lat - factor, longs - factor, lat + factor, longs + factor, map.spatialReference); map.setExtent(extent); map.setScale(sentScale); setTimeout(printImage, 1000); } // ZOOM TO ROUTE // SET COOKIE function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toGMTString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } // SET COOKIE // PRINT IMAGE function printImage() { var printTask; var params = new PrintParameters(); if (sentScale == 1000) { printTask = new PrintTask('https://service.com/GPServer/Export%20Web%20Map'); params.map = map; } else if (sentScale == 2500) { printTask = new PrintTask('https://service.com/GPServer/Export%20Web%20Map'); params.map = map; } var template = new PrintTemplate(); template.format = 'JPG'; template.layout = 'MAP_ONLY'; template.preserveScale = false; params.template = template; printTask.execute(params, printResult); } // PRINT IMAGE // PRINT RESULT function printResult(evt) { imageUrl = evt.url; setCookie('imageUrl', imageUrl, 1); console.log("imageUrl", imageUrl); if (reportType == 1) { printReport(); } if (reportType == 2) { var printTaskLegend; var printPars = new PrintParameters(); printPars.map = map; if (sentScale == 1000) { printTaskLegend = new PrintTask('https://service.com/GPServer/Export%20Web%20Map'); printPars.map = map; } else if (sentScale == 2500) { printTaskLegend = new PrintTask('https://service.com/GPServer/Export%20Web%20Map'); printPars.map = map; } var template = new PrintTemplate(); template.format = 'JPG'; template.layout = 'Print_legend_included'; template.preserveScale = true; printPars.template = template; printTaskLegend.execute(printPars, printImageLegend); } } // PRINT RESULT // PRINT IMAGE LEGEND function printImageLegend(evt) { imageLegendUrl = evt.url; setCookie('imageLegendUrl', imageLegendUrl, 1); console.log("image legend url :: " + imageLegendUrl); printReport(); } // PRINT IMAGE LEGEND }); }
... View more
06-25-2020
12:21 AM
|
0
|
1
|
365
|
POST
|
I actually figured out my issue, so I'll be posting here and maybe it'll help someone out in the future. The issue with the CORS policy was that I was doing an $.ajax call and not specifying that the datatype is in JSON format. The browser doesn't like that, so the lack of datatype is considered a security risk by the browser and it blocks it. I did lose quite a bit of time to solve this but at least it's resolved.
... View more
06-23-2020
11:17 AM
|
1
|
1
|
1234
|
POST
|
I actually figured out my issue, so I'll be posting here and maybe it'll help someone out in the future. The issue with the CORS policy was that I was doing an $.ajax call and not specifying that the datatype is in JSON format. The browser doesn't like that, so the lack of datatype is considered a security risk by the browser and it blocks it. I did lose quite a bit of time to solve this but at least it's resolved.
... View more
06-23-2020
11:16 AM
|
0
|
0
|
812
|
POST
|
So I have a .net core app which currently throws an error in console saying: Access to XMLHttpRequest at 'https://app.test.mk/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer?f=json&dpi=96&transparent=true&format=png8' from origin 'https://localhost:44348' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'https://localhost:44348, *', but only one is allowed. and this is what my Startup file looks like: public void ConfigureServices(IServiceCollection services)
{
services.AddCors(o => o.AddDefaultPolicy(builder =>
{
builder
.WithOrigins("https://localhost:44348/", "https://app.gdi.mk/arcgis/rest/info?f=json",
"Access-Control-Allow-Origin", "Access-Control-Allow-Credentials")
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
}));
services.AddControllersWithViews();
services.AddRazorPages().AddNewtonsoftJson();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseCors();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
} and this is at the top of my View, in a script tag. require(["esri/config"], function (esriConfig) {
esriConfig.defaults.io.corsEnabledServers.push("http://app.test.mk");
esriConfig.defaults.io.corsEnabledServers.push("https://localhost:44348/");
// esriConfig.defaults.io.corsEnabledServers.push("http://app.test.mk/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer");
// esriConfig.defaults.io.corsEnabledServers.push("https://app.test.mk/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer?f=json&dpi=96&transparent=true&format=png8");
});
Anyone has any idea what the problem could be? I've been trying things for two days and the app keeps throwing the same error.
... View more
06-21-2020
02:14 PM
|
0
|
1
|
1479
|
POST
|
Hey Noah, Thanks for the input. I actually have CORS enabled but it still throws that console error. The CORS thing is not quite clear to me, I have it enabled in the Startup class like so: public class Startup { readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins"; public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddRazorPages().AddNewtonsoftJson(); // Configure dependencies for ReportsController. services.TryAddSingleton<IReportServiceConfiguration>(sp => new ReportServiceConfiguration { ReportingEngineConfiguration = ConfigurationHelper.ResolveConfiguration(sp.GetService<IWebHostEnvironment>()), HostAppId = "KarposReports", Storage = new FileStorage(), ReportSourceResolver = new UriReportSourceResolver( System.IO.Path.Combine(sp.GetService<IWebHostEnvironment>().ContentRootPath, "ReportTemplate")) }); services.AddCors(options => { options.AddPolicy(name: MyAllowSpecificOrigins, builder => { builder.WithOrigins("http://some.server.here", "https://localhost:44348/") .AllowAnyHeader() .AllowAnyMethod(); }); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseCors(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}") .RequireCors(MyAllowSpecificOrigins); }); } } and like so in the controller [EnableCors("MyAllowSpecificOrigins")] public ActionResult PrintReport(string selectedStreet) { ViewBag.streetName = new SelectList(dataRepo.GetAllNameUlici(), "Ime_1251", "Ime_1251"); ViewBag.houseNumber = new SelectList(dataRepo.GetHouseNumberByStreet(selectedStreet)); ViewBag.KBR = new SelectList(dataRepo.GetAllKO(), "Ime_1251", "Ime_1251"); return View(); } Even despite my CORS configuration, I am still getting that CORS error in the console, I must be doing something wrong. Maybe I should enable /disable something in the esriConfigs?
... View more
06-19-2020
12:36 AM
|
1
|
0
|
1234
|
Title | Kudos | Posted |
---|---|---|
1 | 06-23-2020 11:17 AM | |
1 | 06-19-2020 12:36 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|