POST
|
I want to change TextSymbol size with every change in map scale. 1. I have seen this sample but I was not able make it work with graphicsLayer. 2. Tried following: simpleRenderer.setVisualVariables(
{
"type": "sizeInfo",
"field": "pop2000",
"minDataValue": 493782,
"maxDataValue": 33871648,
"valueUnit": "unknown",
"minSize": {
"type": "sizeInfo",
"expression": "view.scale",
"stops": [
{ "value": 1128, "size": 16 },
{ "value": 288895, "size": 16 },
{ "value": 73957191, "size": 9 },
{ "value": 591657528, "size": 2 }
]
},
"maxSize": {
"type": "sizeInfo",
"expression": "view.scale",
"stops": [
{ "value": 1128, "size": 80 },
{ "value": 288895, "size": 80 },
{ "value": 73957191, "size": 50 },
{ "value": 591657528, "size": 25 }
]
}
});
graphicLayer.renderer = simpleRenderer;
I dont know what to put in expression and field field. This is not working. All the samples for renderers use featureLayer, I am wondering if they are meant to work with graphicsLayer or otherwise. I am using JS API version 3.15.
... View more
01-29-2019
01:57 AM
|
0
|
0
|
396
|
POST
|
404 for init.js? If yes 1. Try adding /init.js to path 2. Paste HTML page in same dir and try to access it to see if it works Did you followed the guide that is shipped with API to make it work on local server? like change names and ports of server in js files?
... View more
02-23-2017
09:41 PM
|
0
|
0
|
290
|
POST
|
I solved it by porting this code GitHub - bramus/google-maps-polygon-moveto: Programmatically move a google.maps.Polygon to a new google.maps.LatLng usin… and its site Google Maps v3 Move Polygon | Bram.us Thanks for the participation
... View more
02-23-2017
09:33 PM
|
1
|
0
|
1942
|
POST
|
I think that was implemented using Editor class with user intervention not programmatically.
... View more
02-22-2017
08:21 PM
|
0
|
2
|
1942
|
POST
|
I want to move it from centroid that can be calculated as: singlePathPolyline.getExtent().getCenter(); What function do you use to calculate distance? I can not use GeometricEngine for distance calculation for some reasons. I used this in conjunction with GeoUtil (code pasted above) but it did not worked well. function Haversine(lat1, long1, lat2, long2) {
var _eQuatorialEarthRadius = 6378.1370;
var _d2r = (Math.PI / 180.0);
var dlong = (long2 - long1) * _d2r;
var dlat = (lat2 - lat1) * _d2r;
var a = Math.pow(Math.sin(dlat / 2.0), 2.0) + Math.cos(lat1 * _d2r) * Math.cos(lat2 * _d2r) * Math.pow(Math.sin(dlong / 2.0), 2.0);
var c = 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));
var d = _eQuatorialEarthRadius * c;
return d;
} Any idea? Any snippet?
... View more
02-22-2017
08:20 PM
|
1
|
1
|
1942
|
POST
|
I want to move polyline geometry to a new point programmatically. <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,user-scalable=no">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Maps Electrical Power Distribtution</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.19/dijit/themes/nihilo/nihilo.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.19/esri/css/esri.css">
<style>
html, body, #mainWindow {
font-family: sans-serif;
height: 100%;
width: 100%;
}
html, body {
margin: 0;
padding: 0;
}
#header {
height: 80px;
overflow: auto;
padding: 0.5em;
}
</style>
<script src="https://js.arcgis.com/3.19/"></script>
<script>
var map, toolbar, symbol, geomTask;
require([ "esri/map",
"esri/toolbars/draw",
"esri/graphic",
"esri/geometry/Polyline",
"esri/geometry/Point",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"dojo/parser",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane", "dojo/domReady!"
], function(Map, Draw, Graphic, Polyline, Point, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, parser) {
parser.parse();
map = new Map("map", {
basemap: "streets",
center: [-122.148466, 47.585580],
zoom: 7
});
map.on("load", function(){
var singlePathPolyline = new Polyline();
singlePathPolyline.addPath([[-123.2, 48.9], [-122.148, 47.585], [-124.50, 49.4]]);
var graphic = new Graphic(singlePathPolyline, new SimpleFillSymbol());
map.graphics.add(graphic);
var p = new Point(-100, 40);
var graphic = new Graphic(p, new SimpleMarkerSymbol());
map.graphics.add(graphic);
});
map.on("click", function(evt){
console.log(evt.mapPoint);
});
});
</script>
</head>
<body class="nihilo">
<div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'">
<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>
</div>
</body>
</html> variable p is a new point where I want to move singlePathPolyline. Is there any way out? I have seen geoUtil which contains following functions geoUtil.moveGeometry = function (geometry, distance, angle) {
var isWebMercator = geometry.spatialReference.isWebMercator();
var geometry = isWebMercator ? geometry : webMercatorUtils.geographicToWebMercator(geometry);
var newGeometry;
switch (geometry.type) {
case "point":
newGeometry = this._movePoint(geometry, distance, angle);
break;
case "polyline":
newGeometry = this._movePolygon(geometry, geometry.paths, distance, angle);
break;
case "polygon":
newGeometry = this._movePolygon(geometry, geometry.rings, distance, angle);
break;
}
return isWebMercator ? newGeometry : webMercatorUtils.webMercatorToGeographic(newGeometry);
};
/**
* Move a point geometry by a distance and angle
* @param {Point} point - The Point geometry to move
* @param {Number} distance - The distance to move the geometry in meters
* @param {Number} angle - The angle to move the geometry by
* @returns {Point}
* @private
*/
geoUtil._movePoint = function (point, distance, angle) {
var radians = angle * (Math.PI / 180); // Convert angle to radians
var newX = point.x + distance * Math.cos(radians); // calc new X
var newY = point.y + distance * Math.sin(radians); // calc new Y
var deltaX = newX - point.x;
var deltaY = newY - point.y;
return point.offset(deltaX, deltaY);
};
/**
* Move a polygon geometry by a distance and angle
* @param {Polygon} polygon - The Polygon geometry to move
* @param {Number[][][]} Rings An array of rings
* @param {Number} distance - The distance to move the geometry in meters
* @param {Number} angle - The angle to move the geometry by
* @returns {Polygon}
* @private
*/
geoUtil._movePolygon = function (geometry, rings, distance, angle) {
for (var ringIndex = 0; ringIndex < rings.length; ringIndex++) {
var ring = rings[ringIndex];
for (var pointIndex = 0; pointIndex < ring.length; pointIndex++) {
var ringPoint = geometry.getPoint(ringIndex, pointIndex);
geometry.setPoint(ringIndex, pointIndex, this._movePoint(ringPoint, distance, angle));
}
}
return geometry;
}; They accept distance and angle. In my case I have a point. I tried to calculate angle and distance but no avail. Is there any other way out?
... View more
02-22-2017
02:59 AM
|
0
|
8
|
3654
|
POST
|
I am using something similar in my code but I thought it would be easy and every point specific (not just centroid - as I have rooms in my example) when we use graphic and layer transform properties. I have seen use of graphic and layer transform properties for the said purpose somewhere. Thanks for your time.
... View more
05-31-2016
10:07 PM
|
0
|
0
|
544
|
POST
|
Makes sense. Delta between two centroids? But Room points might not be at centroid! Can you please share the snippet?
... View more
05-31-2016
02:36 AM
|
0
|
2
|
544
|
POST
|
I have 4 graphics on map with 3 map points and a polyline. As I am scaling / rotating polyline with editor I want 3 map points to calculate its new position relatively to scale or rotation of polyline. editToolbar.on('graphic-move-stop',function(evt){
var graphicTransform = graphicDojoShape.getTransform();
var layerTransform = evt.graphic.getLayer()._div.getTransform();
var wrapOffset = 0;
var f = map.toScreen({x: roomGeometry.x, y: roomGeometry.y, spatialReference: spatialReference}, !0);
f.x += wrapOffset;
f = matrix.multiplyPoint([layerTransform, graphicTransform, matrix.invert(layerTransform)], f);
f.x -= wrapOffset;
f = map.toMap(f);
}); This code is not working. Any clue?
... View more
05-29-2016
10:29 PM
|
0
|
4
|
3564
|
POST
|
Do anybody have experienced to play with Fabric.js Javascript Canvas Library and ArcGIS API for JavaScript 4? I am just curious to use its grouping feature and symbols in 4.0. It would be a great experience. Any link or hint would suffice.
... View more
05-29-2016
10:31 AM
|
0
|
0
|
2724
|
POST
|
Do you agree that we can pas an array like this? If yes then I should start blaming the tool and testing it via REST endpoint. By the way it works all well in ArcMap. Thanks for the help.
... View more
05-25-2016
04:20 AM
|
0
|
1
|
570
|
POST
|
Sorry for the late reply. I have changed submit parameters like this: var param1 = {
"Input_Layer": dijit.byId('spreadmodel1layers').value,
"Start_locations": featureSet,
"Default_break_values": box0.attr("value")
};
esri.show(loading);
gp.submitJob([param1], completeCallback, statusCallback, function(error){
alert(error);
esri.hide(loading);
}); But result is pity much same. I have also tried var features= [];
features.push(f1Graphic);
var f1featureSet = new FeatureSet();
var f2featureSet = new FeatureSet();
f1featureSet.features = features;
features = [];
features.push(f2Graphic);
f2featureSet.features = features;
var featureSetParam = [];
featureSetParam.push({"f1s":f1featureSet,"f2s":f2featureSet});
featureSetParam.push({"f1s":f1featureSet,"f2s":f2featureSet});
gp.submitJob(featureSetParam, completeCallback, statusCallback); with same result. According to API docs submitJob(inputParameters, callback?, statusCallback?, errback?) < Object > inputParameters Required The inputParameters argument specifies the input parameters accepted by the task and their corresponding values. These input parameters are listed in the parameters field of the associated GP Task resource. For example, assume that a GP Task resource has the following input parameters: < GPFeatureRecordSetLayer > Input_Points < GPDouble > Distance The parameters argument for the above inputs is a data object of the form: { Input_Points: <FeatureSet>, Distance: <Number> } It does not clearly says that inputParameters can be an Array. Please guide how I can pass any array of params in submitJob function.
... View more
05-25-2016
12:29 AM
|
0
|
3
|
570
|
POST
|
I have a geoprocessing tool that accepts multiple input parameters, how to pass multiple parameters from javaScript. var param1 = {
"Input_Layer": dijit.byId('spreadmodel1layers').value,
"Start_locations": featureSet,
"Default_break_values": box0.attr("value")
};
var param2 = {
"Input_Layer": dijit.byId('spreadmodel2layers').value,
"Start_locations": featureSet,
"Default_break_values": box1.attr("value")
};
var params = [];
params.push(param1);
params.push(param2);
esri.show(loading);
gp.submitJob(params, completeCallback, statusCallback, function(error){
alert(error);
esri.hide(loading);
}); After submitting the job it comes back crying "Esri Job Failed". I want to know that is it valid way to pass multiple parameters to Asynch GP tool. Thanks
... View more
05-24-2016
03:34 AM
|
0
|
5
|
2473
|
Title | Kudos | Posted |
---|---|---|
1 | 02-18-2016 11:31 PM | |
1 | 03-21-2015 11:17 PM | |
1 | 03-18-2015 09:50 PM | |
1 | 05-10-2015 04:00 AM | |
1 | 02-23-2017 09:33 PM |
Online Status |
Offline
|
Date Last Visited |
06-12-2021
10:07 AM
|