POST
|
So I tried to add Print function on my arcgis map. It's doesn't work at all. So I tried to start new project and figure it out. It worked fine. Back to my main project, I realized the errors is came from parser itself. When I comment the parser.parse(); the print function is work but a part of my function didn't work out. I've tried to add this: <script> var dojoConfig = { parseOnLoad: false, async: true, tlmSiblingOfDojo: false }; </script>
It doesn't work out. Here is the print function: parser.parse();
esriConfig.defaults.io.corsEnabledServers.push("1xx.1xx.xx.xx2:6443");
map = new Map("mapDiv", {
// basemap: "satellite",
basemap: "topo",
center: [118,-1],
zoom: 5,
sliderStyle: "small"
});
printUrl = "https://1xx.1xx.7x.2xx:6443/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
var printInfo = esriRequest({
"url": printUrl,
"content": { "f": "json" }
});
printInfo.then(dojo.hitch(printUrl,dojo.hitch(map,handlePrintInfo)), handleError);
function handlePrintInfo(resp) {
var layoutTemplate, templateNames, mapOnlyIndex, templates;
layoutTemplate = arrayUtils.filter(resp.parameters, function(param, idx) {
return param.name === "Layout_Template";
});
if ( layoutTemplate.length === 0 ) {
console.log("print service parameters name for templates must be \"Layout_Template\"");
return;
}
templateNames = layoutTemplate[0].choiceList;
// remove the MAP_ONLY template then add it to the end of the list of templates
mapOnlyIndex = arrayUtils.indexOf(templateNames, "MAP_ONLY");
if ( mapOnlyIndex > -1 ) {
var mapOnly = templateNames.splice(mapOnlyIndex, mapOnlyIndex + 1)[0];
templateNames.push(mapOnly);
}
// create a print template for each choice
templates = arrayUtils.map(templateNames, function(ch) {
var plate = new PrintTemplate();
plate.layout = plate.label = ch;
plate.format = "PDF";
plate.layoutOptions = {
"authorText": "Author.",
"copyrightText": "<copyright info here>",
"legendLayers": [],
"titleText": "A title",
"scalebarUnit": "Kilometers"
};
return plate;
});
// create the print dijit
var printer = new Print({
"map": map,
"templates": templates,
"url": printUrl
}, dojo.byId("print_map"));
printer.startup();
}
function handleError(err) {
console.log("Something broke: ", err);
} How can I make the print function work out without removing parser.parse(); ? If I didn't use parser, all my function can't be loaded, and if I use parser, the json can't be sent to server service.
... View more
08-01-2017
02:47 AM
|
0
|
0
|
319
|
POST
|
I have some problem with sticking draggable SVG to ArcGIS map, using D3.js. Let's assume that I had latitude:-34.42507,longitude: 150.89315 to place some point that the SVG would be stick. Here the point of code: var newg = svg.append("g")
.data([{x: width / 2, y: height / 2}]);
var dragline = newg.append("line")
.attr("x1", function(d) { return d.x + (width - 20); })
.attr("y1", function(d) { return d.y + (height - 20); })
.attr("x2", 700)
.attr("y2", 465)
.attr("stroke-width", 2)
.attr("stroke", "gray")
.attr("width",width)
.attr("height",height)
.attr("cursor", "move")
.call(drag); When I drag the map, the SVG is stay on the screen, exactly with screen coodinates. What I want is the line is sticked with the coordinates. What I supposed to do to insert coordinates and make them stick with maps? Thanks a lot.
... View more
07-20-2017
01:39 AM
|
0
|
0
|
992
|
POST
|
Hi Thomas, thanks for your answer, I'll try it now. But I think we need to draw it manually, not put some point that can generate to be curved line? By the way, still related question, is it possible to make a modified curved arrow like this? My teacher says to me that I can use SVG/dojo but I can't find any documentation related about this curved arrow.
... View more
07-19-2017
07:23 PM
|
0
|
0
|
702
|
POST
|
Hi, if you looking for something that is look same with Arrows (Symbols) | Google Maps JavaScript API | Google Developers, then I'll suggest you this one: DirectionalLineSymbol. You can create polyline and arrow at the end of line or make it repeatly along the line.
... View more
07-19-2017
07:17 PM
|
0
|
0
|
3085
|
POST
|
I need to implemented code below to arcgis. Can you help me? <html>
<head>
<script src="http://dev.openlayers.org/OpenLayers.js" type="text/javascript"></script>
<title>Ya Mahdi</title>
<style>
html,body {
height: 99%;
width: 99%;
}
#map {
width: 100%;
height: 100%;
border: 1px solid black;
}
</style>
<script>
mmGetCurvePoints = function(ptsa, tension, isClosed, numOfSegments)
{
if (ptsa.length <= 2)
return ptsa;
tension = typeof tension === 'number' ? tension : 0.5;
isClosed = typeof isClosed === 'boolean' ? isClosed : false;
numOfSegments = typeof numOfSegments === 'number' ? numOfSegments : 16;
var ptsaClone = ptsa.slice(0);
if (isClosed)
ptsaClone.push(ptsa[0], ptsa[1], ptsa[2], ptsa[3]);
var _pts, res = [], /// clone array
x, y, /// our x,y coords
t1x, t2x, t1y, t2y, /// tension vectors
c1, c2, c3, c4, /// cardinal points
st, t, i, /// steps based on num. of segments
pow3, pow2, /// cache powers
pow32, pow23,
p0, p1, p2, p3, /// cache points
pl = ptsaClone.length;
/// clone array so we don't change the original content
_pts = ptsaClone.concat();
_pts.unshift(ptsaClone[1]); /// copy 1. point and insert at beginning
_pts.unshift(ptsaClone[0]);
_pts.push(ptsaClone[pl - 2], ptsaClone[pl - 1]); /// copy last point and append
/// 1. loop goes through point array
/// 2. loop goes through each segment between the two points + one point before and after
for (i = 2; i < pl; i += 2) {
p0 = _pts[i];
p1 = _pts[i + 1];
p2 = _pts[i + 2];
p3 = _pts[i + 3];
/// calc tension vectors
t1x = (p2 - _pts[i - 2]) * tension;
t2x = (_pts[i + 4] - p0) * tension;
t1y = (p3 - _pts[i - 1]) * tension;
t2y = (_pts[i + 5] - p1) * tension;
for (t = 0; t <= numOfSegments; t++) {
/// calc step
st = t / numOfSegments;
pow2 = Math.pow(st, 2);
pow3 = pow2 * st;
pow23 = pow2 * 3;
pow32 = pow3 * 2;
/// calc cardinals
c1 = pow32 - pow23 + 1;
c2 = pow23 - pow32;
c3 = pow3 - 2 * pow2 + st;
c4 = pow3 - pow2;
/// calc x and y cords with common control vectors
x = c1 * p0 + c2 * p2 + c3 * t1x + c4 * t2x;
y = c1 * p1 + c2 * p3 + c3 * t1y + c4 * t2y;
/// store points in array
res.push(x, y);
}
}
if (isClosed)
res = res.slice(0, res.length - 2 * numOfSegments);
return res;
};
var map, control,layer,feature,points;
var xy = [];
var array = [];
function init(){
map = new OpenLayers.Map('map', {
center: [45.476333, 39.4854095],
zoom: 10
});
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0?", {layers: 'basic'});
layer = new OpenLayers.Layer.Vector("Simple Geometry");
map.addLayer(wms);
map.addLayer(layer);
function drawEnd(e){
if(xy.length<6) {
xy.push(e.x);
xy.push(e.y);
return;
}
else if(xy.length==6){
feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString(array),{properties: {state: 'a'}}
);
layer.addFeatures(feature);
console.log("add f");
feature="";
layer.refresh({force:true});
xy=[];
}
}
function putPoint(e){
if(xy.length<6) {
return;
}
}
function sketchModified(e, ee, eee){
if(xy.length<6)
return;
try{
layer.removeFeatures(feature);
}catch(err){}
var xytemp = [];
xytemp.push(xy[0]);
xytemp.push(xy[1]);
xytemp.push(xy[2]);
xytemp.push(xy[3]);
xytemp.push(e.x);
xytemp.push(e.y);
points = mmGetCurvePoints(xytemp, 0.5, false, 15);
var i = 0;
while(i<points.length){
array.push(new OpenLayers.Geometry.Point(points[i], points[i+1]));
i++;
i++;
}
feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString(array),{properties: {state: 'a'}}
);
layer.addFeatures([feature]);
array=[];
points=[];
layer.refresh({force:true});
}
function cancel(){
}
var callBackParams = {
"done": drawEnd,
"point": putPoint,
"modify": sketchModified,
"cancel": cancel
};
var drawCrtl = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {callbacks: callBackParams});
map.addControls([drawCrtl]);
drawCrtl.activate();
}
</script>
</head>
<body onload="init()">
<div id="map" style="width: 400px; height: 400px;"></div>
</body>
</html>
... View more
07-19-2017
01:04 AM
|
0
|
0
|
772
|
POST
|
I'm planning to make curved tools by joining two point / three point. Here, I found some example that is easy to understand Point and Chart. and Draw Smooth Path The question is, how to implement them to arcgis? I mean, how to modify polyline tools and implemented the method above so I can make it curved? Thank you.
... View more
07-19-2017
12:54 AM
|
0
|
2
|
1161
|
POST
|
I'm planning to apply turf to bezier the line. The line has been stated before, but seems like the line isn't rendered to curved. Let's check out my code. //======= Load data Polyline ==========
var line = new Polyline(wgs84);
var b = 0;
var a = 0;
// console.log(hasilarray);
arrayUtils.forEach(hasilarray, function(ple){
// console.log();
if(a==0){
var jumlah = akhir.length;
for(c=0;c<jumlah;c++){
var load = JSON.stringify(hasilarray[0][c]);
console.log(load +" jalur "+c);
var jumlah_k = hasilarray[0][c].length;
for(d=0;d<jumlah_k;d++){
// array_koordinat.push(hasilarray[0] );
var koor_x_p = hasilarray[1][d][0].toString();
var koor_y_p = hasilarray[1][d][1].toString();
var x_ = Number(koor_x_p);
var y_ = Number(koor_y_p);
array_koordinat.push(x_,y_);
koordinat_a.push(array_koordinat);
array_koordinat=[];
}
line.addPath(hasilarray[0][c]);
}
}else{
var load = JSON.stringify(hasilarray[1]);
// console.log(JSON.stringify(hasilarray[1]));
//console.log(load +" jalur terakhir");
var jumlah_k = hasilarray[1].length;
for(e=0;e<jumlah_k;e++){
var koor_x_p = hasilarray[1][e][0].toString();
var koor_y_p = hasilarray[1][e][1].toString();
var x_ = Number(koor_x_p);
var y_ = Number(koor_y_p);
array_koordinat.push(x_,y_);
koordinat_a.push(array_koordinat);
array_koordinat=[];
}
// array_koordinat.push(hasilarray[1]);
line.addPath(hasilarray[1]);
}
a++;
b++;
}) ;
console.log(JSON.stringify(koordinat_a));
/* var lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0,0.5]),3);
map.graphics.add(new esri.Graphic(line, lineSymbol));*/
var bg = new Graphic(line, basicSymbol, {}, null);
graphicsLayer.add(bg);
showEndSymbol.push(basicSymbol); Where should I put the turf bezier function so it can be showed and rendered on the view? Thanks.
... View more
07-16-2017
09:58 PM
|
0
|
1
|
751
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|