POST
|
I have created a file geodatabase with a string field. Some records contain emojis for that field. I used ArcMap to set up a ArcGIS REST service for that database, and so far it seems to work. However, another service (non-Esri) pulls from this REST service. Sometimes, while trying to pull data from the REST service, it gives an error: "Error while processing: The remote ArcGIS server is not responding: [500] Error performing query operation" I've contacted support for that other service, and they think it's coming from ArcGIS server. The strange thing, though, is that this other service pulls from other ArcGIS REST services just fine. So I'm trying to think of reasons why there is problems with this ArcGIS REST service in particular. One of the things I can think of is that it is probably the only one with emojis. When I query the service from the web url, the emojis are displayed with weird characters: �� So my question is what kind of encoding do string fields support for ArcGIS REST services? Could emojis in the data mess up a service?
... View more
01-08-2020
01:57 PM
|
0
|
0
|
509
|
POST
|
I am trying to figure out a good way to retrieve the fields from an ArcGIS REST service. I first create a FeatureLayer from the a feature server url. When I console.log the feature layer, I see that it has fields, but when I try to console.log(featureLayer.fields) it is just null. I need the field information to create a popup template, but I am trying to find a way to avoid having to hard-code the field information. What is a good way of going about this? <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.13/esri/css/main.css">
<script src="https://js.arcgis.com/4.13/"></script>
</head>
<body>
<div id="viewDiv"></div>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/widgets/Legend",
"esri/PopupTemplate",
"esri/layers/FeatureLayer",
"esri/Graphic"
], function(Map, MapView, Legend, PopupTemplate, FeatureLayer, Graphic){
var map = new Map({
basemap: "gray"
});
var view = new MapView({
container: "viewDiv",
map: map
});
var featureLayer = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/earthquakes_geojson/FeatureServer/0"
});
console.log(featureLayer);
console.log(featureLayer.fields);
// add the layer to the map
map.add(featureLayer);
});
</script>
</body>
</html>
... View more
12-04-2019
11:35 AM
|
0
|
12
|
3390
|
POST
|
I figured out what the problem was. I needed to just create a new FeatureLayer using new graphics.
... View more
10-31-2019
09:48 AM
|
0
|
0
|
723
|
POST
|
I am trying to modify a Feature Layer that is created from data that is on a rest service. The goal is to add new attributes to each feature in-memory to create a visualization. I am trying to use queryFeatures with applyEdits, but I am having trouble. When I console.log the feature after I modify them, it looks correct, but it seems like the renderer can't find the new attribute. <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>Intro to FeatureLayer - 4.13</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.13/esri/themes/light/main.css"/>
<script src="https://js.arcgis.com/4.13/"></script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/layers/support/LabelClass",
"esri/widgets/Legend"
], function(Map, MapView, FeatureLayer, LabelClass, Legend) {
var map = new Map({
basemap: "gray"
});
var view = new MapView({
container: "viewDiv",
map: map,
center: [-121.6555013,36.6777372],
zoom: 13
});
var customLabels = new LabelClass({
labelExpression: "[BEAT_NO]",
symbol: {
type: "text",
color: [255, 255, 255, 1],
haloColor: [255, 255, 255, 1],
haloSize: 0
}
})
var featureLayer = new FeatureLayer({
url: "https://giswebservices.ci.salinas.ca.us/arcgis/rest/services/PublishedServices/PoliceBeats/MapServer/0",
labelingInfo: customLabels
});
featureLayer.queryFeatures().then(function(result){
console.log(result);
var numFeatures = result.features.length;
// arbitaryValues corresponds to the i'th feature in featureLayer
var arbitraryValues = [];
for (var i=0; i<numFeatures; i++){
arbitraryValues.push(i);
}
// add new fields to the features
for (var i=0; i<numFeatures; i++){
result.features[i]['attributes']['newField'] = arbitraryValues[i];
}
console.log(result.features);
// change the renderer
featureLayer.renderer = {
type: "simple",
symbol: {
type: "simple-fill",
outline: {
color: [255, 255, 255, 1]
}
},
visualVariables: [
{
type: "color",
field: "newField",
legendOptions: {
title: "Some Arbitary Measurement"
},
stops: [
{
value: 1,
color: "#000000",
label: "1"
},
{
value: 12,
color: "#FF0000",
label: "12"
}
]
}
]
}
// use applyEdits
edits = {
updateFeatures: result.features
}
featureLayer.applyEdits(edits);
// add the feature layer to the map
map.add(featureLayer);
view.ui.add(
new Legend({
view: view
}), "top-right"
);
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
10-30-2019
02:37 PM
|
0
|
1
|
839
|
POST
|
Thanks. One reason I didn't do this was that I was worried about CPU usage. However this seems to work fine. Oddly enough, operations dashboards seem to create visualizations based on all records yet they load fast and don't use up as much CPU. I'm wondering if there are other approaches to querying records with ArcGIS JS.
... View more
05-29-2019
09:57 AM
|
0
|
2
|
1847
|
POST
|
Hello. I am trying to figure out a quick way to query features that are on a feature service or map service so that I can go on to create visualizations from them. Feature services have a limit of how many records you can query at once. This limit is usually 1000. So, as a result I have to keep re-querying until I have all records. So far one way I found to do this is using QueryTask. However it seems quite slow compared to operations dashboard. Is this a bad approach? Here is my current method for querying records: <html>
<head>
<meta name="description" content="DevLav: Query a feature layer">
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Query All using QueryTask</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.11/esri/css/main.css">
<script src="https://js.arcgis.com/4.11/"></script>
</head>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/tasks/support/Query",
"esri/tasks/QueryTask",
"esri/Graphic",
"dojo/domReady!"
],
function(
Map,
MapView,
Query,
QueryTask,
Graphic
){
serviceUrl = "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/earthquakes_geojson/FeatureServer/0";
var map = new Map({
basemap: "topo-vector"
});
var view = new MapView({
container: "viewDiv",
map: map
});
// gets a time delta dictionary between two Date objects, 'start' and 'stop'
function getTimeDelta(start, stop){
var timeDelta = parseInt(stop - start);
var days = parseInt(timeDelta / 86400000);
var daysRem = timeDelta - (days * 86400000);
var hours = parseInt(daysRem / 3600000);
var hoursRem = daysRem - (hours * 3600000);
var minutes = parseInt(hoursRem / 60000);
var minutesRem = hoursRem - (minutes * 60000);
var seconds = parseInt(minutesRem / 1000);
var milliseconds = minutesRem - (seconds * 1000);
var results = {
days: days,
hours: hours,
minutes: minutes,
seconds: seconds,
milliseconds: milliseconds
}
return results;
}
// return Promise<Number> (should be total number of records, since OBJECTID should never be blank)
function getNumRecords(){
var query = new Query();
query.where = "'OBJECTID' LIKE '%'";
query.outFields = ['*'];
query.returnGeometry = true;
var queryTask = new QueryTask({
url: serviceUrl
});
return queryTask.executeForCount(query);
}
function createQueryFunction(startId, numRecords){
return function(){
var query = new Query();
query.start = startId;
query.num = numRecords;
query.outFields = ['*'];
query.returnGeometry = true;
var queryTask = new QueryTask({
url: serviceUrl
});
return queryTask.execute(query)
}
}
async function doWork(promises){
var results = [];
for (var promise of promises){
result = await promise();
results = results.concat(result.features);
}
return results;
}
var startTime = new Date();
getNumRecords().then(function(numRecords){
console.log(numRecords);
var promises = [];
for (var i=0; i<numRecords; i += 1000){
promises.push(createQueryFunction(i, 1000));
}
doWork(promises).then(results => {
console.log('results', results);
var stopTime = new Date();
console.log(getTimeDelta(startTime, stopTime));
});
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
05-28-2019
10:26 AM
|
0
|
4
|
2267
|
POST
|
Is there no way to do conversions in arcpy for floating point raster layers?
... View more
04-12-2019
09:59 AM
|
0
|
0
|
355
|
POST
|
I have a raster layer hosted on some arcgis rest service, let's say it's https://domain.com/arcgis/rest/services/rasters/Heatmap/MapServer/0 Is there a way to convert this to a polygon feature layer using arcpy? I have tried the following: import arcpy
inRaster = r"https://domain.com/arcgis/rest/services/rasters/Heatmap/MapServer"
inField = 'Value'
outType = 'POLYGON'
simplify = 'SIMPLIFY'
outPolygons = r"C:\test\output.shp"
arcpy.ConvertRasterToFeature_ra(inRaster, inField, outType, simplify, outPolygons) and import arcpy
from arcpy import env
from arcpy.sa import *
url = r"https://domain.com/arcgis/rest/services/rasters/Heatmap/MapServer/0"
inRaster = Raster(url)
outPolygons = r"C:\test\output.shp"
field = "VALUE"
arcpy.RasterToPolygon_conversion(inRaster, outPolygons, "NO_SIMPLIFY", field) I always get errors: RuntimeError: ERROR 000732: Input Raster: Dataset https://domain.com/arcgis/rest/services/rasters/Heatmap/MapServer/0 does not exist or is not supported I know it does exist, because it shows up fine when I try to view the map service in ArcMap
... View more
04-12-2019
09:01 AM
|
0
|
4
|
424
|
POST
|
Is it possible to create static heatmaps? I know that ArcGIS JS is capable of heatmap visualizations: https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=visualization-heatmap However, I'm trying to figure out a way to make a static heatmap (one that is not dependent on extents or zoom) based on the density of points. AFAIK there's nothing in the HeatmapRenderer documentation regarding static heatmaps, so it looks like I can't use HeatmapRenderer. Does anyone know if it is possible to accomplish that with ArcGIS JS?
... View more
02-25-2019
05:14 PM
|
0
|
1
|
345
|
POST
|
Memory usage does increase over time. Why would accumulated garbage in memory slow down successive calls to SelectLayerByAttribute_management?
... View more
02-22-2019
02:25 PM
|
0
|
1
|
969
|
POST
|
How do I delete the selection between calls? I have tried adding "del addSelect" at the end of the loop, it does nothing. Adding "addSelect = arcpy.SelectLayerByAttribute_management(addresses, "CLEAR_SELECTION")" after each loop simply makes it longer, since all it does is add more calls
... View more
02-22-2019
02:14 PM
|
0
|
3
|
969
|
POST
|
I have set up a simple test script to demonstrate the problem I'm running into: #importing python modules
import arcpy, time
basePath = r"C:\Users\vincentl\AppData\Local\PythonTesting\Geodatabases\ScratchAddressing.gdb"
arcpy.env.workspace = basePath
addresses = basePath + r"\GIS_DBO_Places_Sample"
whereClause = "OBJECTID IN (1)"
for i in range(0, 100):
start = time.time()
addSelect = arcpy.SelectLayerByAttribute_management(addresses, "NEW_SELECTION", whereClause) #selecting current record
stop = time.time()
print("Time elapsed: {0}".format(stop - start))
Output: Time elapsed: 2.4421534538269043
Time elapsed: 0.2509007453918457
Time elapsed: 0.26900672912597656
Time elapsed: 0.2650105953216553
Time elapsed: 0.2917516231536865
Time elapsed: 0.2583498954772949
Time elapsed: 0.27279186248779297
Time elapsed: 0.2871057987213135
Time elapsed: 0.31418442726135254
Time elapsed: 0.2747483253479004
Time elapsed: 0.2698488235473633
Time elapsed: 0.2711470127105713
Time elapsed: 0.30519843101501465
Time elapsed: 0.30664968490600586
Time elapsed: 0.3076004981994629
Time elapsed: 0.2947726249694824
Time elapsed: 0.3275151252746582
Time elapsed: 0.3086280822753906
Time elapsed: 0.3205225467681885
Time elapsed: 0.32954835891723633
Time elapsed: 0.32260847091674805
Time elapsed: 0.328507661819458
Time elapsed: 0.3341994285583496
Time elapsed: 0.32455968856811523
Time elapsed: 0.3244626522064209
Time elapsed: 0.3398430347442627
Time elapsed: 0.3336300849914551
Time elapsed: 0.3469429016113281
Time elapsed: 0.3484632968902588
Time elapsed: 0.3517005443572998
Time elapsed: 0.3604257106781006
Time elapsed: 0.36439085006713867
Time elapsed: 0.3885536193847656
Time elapsed: 0.44512104988098145
Time elapsed: 0.395768404006958
Time elapsed: 0.3962588310241699
Time elapsed: 0.4052317142486572
Time elapsed: 0.4457588195800781
Time elapsed: 0.4870429039001465
Time elapsed: 0.42713308334350586
Time elapsed: 0.4171907901763916
Time elapsed: 0.4220712184906006
Time elapsed: 0.4343099594116211
Time elapsed: 0.4841780662536621
Time elapsed: 0.4685649871826172
Time elapsed: 0.4868438243865967
Time elapsed: 0.4662456512451172
Time elapsed: 0.5436382293701172
Time elapsed: 0.5267820358276367
Time elapsed: 0.5091872215270996
Time elapsed: 0.5081048011779785
Time elapsed: 0.5297191143035889
Time elapsed: 0.5239181518554688
Time elapsed: 0.5485963821411133
Time elapsed: 0.5876140594482422
Time elapsed: 0.5736618041992188
Time elapsed: 0.5639777183532715
Time elapsed: 0.5830345153808594
Time elapsed: 0.6187348365783691
Time elapsed: 0.5978899002075195
Time elapsed: 0.6382076740264893
Time elapsed: 0.6436002254486084
Time elapsed: 0.6225919723510742
Time elapsed: 0.6568043231964111
Time elapsed: 0.7085685729980469
Time elapsed: 0.6644773483276367
Time elapsed: 0.6723501682281494
Time elapsed: 0.6834757328033447
Time elapsed: 0.6862823963165283
Time elapsed: 0.7144062519073486
Time elapsed: 0.75490403175354
Time elapsed: 0.7380294799804688
Time elapsed: 0.7777352333068848
Time elapsed: 0.782534122467041
Time elapsed: 0.8311202526092529
Time elapsed: 0.7933468818664551
Time elapsed: 0.8011541366577148
Time elapsed: 0.8183913230895996
Time elapsed: 0.8311331272125244
Time elapsed: 0.8553295135498047
Time elapsed: 0.8610031604766846
Time elapsed: 0.9558396339416504
Time elapsed: 0.9203469753265381
Time elapsed: 0.9103479385375977
Time elapsed: 0.9160957336425781
Time elapsed: 0.928046703338623
Time elapsed: 0.950376033782959
Time elapsed: 0.9951839447021484
Time elapsed: 0.9768331050872803
Time elapsed: 0.9877028465270996
Time elapsed: 1.0079317092895508
Time elapsed: 1.0394885540008545
Time elapsed: 1.0345790386199951
Time elapsed: 1.0764164924621582
Time elapsed: 1.0987389087677002
Time elapsed: 1.108257532119751
Time elapsed: 1.114212989807129
Time elapsed: 1.1997053623199463
Time elapsed: 1.154165267944336
Time elapsed: 1.1690573692321777 If SelectLayerByAttribute_management is called multiple times, each successive call will take longer and longer. Is there anything I am doing wrong?
... View more
02-22-2019
12:54 PM
|
0
|
10
|
1352
|
POST
|
I am trying to write code that will query from a FeatureLayer using queryFeatures() and then call MapView goTo to zoom to that result. I am verifying that the query matches the attributes of the expected attributes when I query for a single objectid, but MapView goTo doesn't work when I try to zoom to the Graphics from the query. However, if I create my own Graphics manually, it works as expected. I have created an example with two buttons demonstrating my issue below. One button "workingButton" correctly zooms to some manually created Graphics. The other "notWorkingButton" tries to zoom to the result of a query, but doesn't work. <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Street Sweeping Routes</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://js.arcgis.com/4.10/esri/css/main.css">
<script src="https://js.arcgis.com/4.10/"></script>
<style>
html,
body{
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#viewDiv {
padding: 0;
margin: 0;
height: 70%;
width: 100%;
}
</style>
<script>
var app = {};
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/widgets/Legend",
"esri/PopupTemplate",
"esri/Graphic",
"dojo/domReady!"
], function(
Map, MapView, FeatureLayer, Legend, PopupTemplate, Graphic
) {
var fields = [
{
name: "OBJECTID",
alias: "OBJECTID",
type: "oid"
},
{
name: "Street_seg",
alias: "Street_seg",
type: "integer"
},
{
name: "Route",
alias: "Route",
type: "string"
},
{
name: "Miles",
alias: "Miles ",
type: "double"
},
{
name: "Drive_time",
alias: "Drive_time",
type: "double"
},
{
name: "Av_side",
alias: "Av_side",
type: "string"
},
{
name: "Low_addr",
alias: "Low_addr",
type: "integer"
},
{
name: "High_addr",
alias: "High_addr",
type: "integer"
},
{
name: "St_prefix",
alias: "St_prefix",
type: "string"
},
{
name: "St_name",
alias: "St_name",
type: "string"
},
{
name: "St_type",
alias: "St_type",
type: "string"
},
{
name: "St_suffix",
alias: "St_suffix",
type: "string"
},
{
name: "Mode",
alias: "Mode",
type: "string"
},
{
name: "Meander",
alias: "Meander",
type: "smallinteger"
},
{
name: "LoopNum",
alias: "LoopNum",
type: "integer"
},
{
name: "ServiceDay",
alias: "ServiceDay",
type: "smallinteger"
},
{
name: "ID",
alias: "ID",
type: "double"
},
{
name: "Street_ID",
alias: "Street_ID",
type: "double"
},
{
name: "ServiceSeq",
alias: "ServiceSeq",
type: "integer"
},
{
name: "Day",
alias: "Day",
type: "string"
},
{
name: "Schedule",
alias: "Schedule",
type: "string"
},
{
name: "Shape",
alias: "Shape",
type: "geometry"
},
{
name: "Shape.STLength()",
alias: "Shape.STLength()",
type: "double"
}
];
pTemplate = new PopupTemplate({
content: [{
type: "fields",
fieldInfos: [{
fieldName: "OBJECTID",
label: "OBJECTID",
},{
fieldName: "Street_seg",
label: "Street_seg",
},{
fieldName: "Route",
label: "Route",
},{
fieldName: "Miles",
label: "Miles ",
},{
fieldName: "Drive_time",
label: "Drive_time",
},{
fieldName: "Av_side",
label: "Av_side",
},{
fieldName: "Low_addr",
label: "Low_addr",
},{
fieldName: "High_addr",
label: "High_addr",
},{
fieldName: "St_prefix",
label: "St_prefix",
},{
fieldName: "St_name",
label: "St_name",
},{
fieldName: "St_type",
label: "St_type",
},{
fieldName: "St_suffix",
label: "St_suffix",
},{
fieldName: "Mode",
label: "Mode",
},{
fieldName: "Meander",
label: "Meander",
},{
fieldName: "LoopNum",
label: "LoopNum",
},{
fieldName: "ServiceDay",
label: "ServiceDay",
},{
fieldName: "ID",
label: "ID",
},{
fieldName: "Street_ID",
label: "Street_ID",
},{
fieldName: "ServiceSeq",
label: "ServiceSeq",
},{
fieldName: "Day",
label: "Day",
},{
fieldName: "Schedule",
label: "Schedule",
},{
fieldName: "Shape",
label: "Shape",
},{
fieldName: "Shape.STLength()",
label: "Shape.STLength()",
}
]
}]
});
var defaultSym = {
type: "simple-line", // autocasts as new SimpleLineSymbol()
color: "#EBEBEB",
width: 3,
style: "solid"
};
/*****************************************************************
* Set a size visual variable on the renderer. Size visual variables
* create continuous ramps that map low data values to small icons
* and high data values to large icons. Features
* with data values in between the min and max data values are assigned
* a size proportionally between the min and max sizes specified in
* `minSize` and `maxSize` or `stops`.
*****************************************************************/
var renderer = {
type: "unique-value",
defaultSymbol: defaultSym,
field: "Schedule",
uniqueValueInfos: [
{
value: "First Monday of the month",
label: "First Monday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [252, 32, 32, 0.5] // fourth value is opacity (from 0 to 1)
}
},{
value: "Second Monday of the month",
label: "Second Monday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [252, 93, 35, 0.5]
}
},{
value: "First Tuesday of the month",
label: "First Tuesday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [255, 240, 38, 0.5]
}
},{
value: "Second Tuesday of the month",
label: "Second Tuesday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [113, 255, 43, 0.5]
}
},{
value: "First Wednesday of the month",
label: "First Wednesday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [42, 255, 156, 0.5]
}
},{
value: "Second Wednesday of the month",
label: "Second Wednesday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [41, 233, 255, 0.5]
}
},{
value: "First Thursday of the month",
label: "First Thursday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [40, 90, 255, 0.5]
}
},{
value: "Second Thursday of the month",
label: "Second Thursday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [118, 40, 255, 0.5]
}
},{
value: "First Friday of the month",
label: "First Friday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [168, 40, 255, 0.5]
}
},{
value: "Second Friday of the month",
label: "Second Friday of the month",
symbol: {
style: "solid",
type: 'simple-line',
width: 3,
color: [255, 40, 233, 0.5]
}
}
]
};
app.pLineLayer = new FeatureLayer({
url: "https://giswebservices.ci.salinas.ca.us/arcgis/rest/services/PublishedServices/CurrentSweeperRoutes/MapServer/0",
outFields: ["*"],
fields: fields,
renderer: renderer,
popupTemplate: pTemplate,
minScale: 0,
maxScale: 0
});
var map = new Map({
basemap: "dark-gray",
layers: [app.pLineLayer]
});
var view = new MapView({
container: "viewDiv",
map: map,
center: [-121.6555, 36.6777],
zoom: 13
});
console.log(app.pLineLayer);
selectGraphic = null;
/******************************************************************
*
* Add layers to layerInfos on the legend
*
******************************************************************/
var legend = new Legend({
view: view,
layerInfos: [
{
layer: app.pLineLayer,
title: "Street Sweeping"
}]
});
view.ui.add(legend, "top-right");
$('#workingButton').click(function(){
// First create a line geometry (this is the Keystone pipeline)
var polyline = {
type: "polyline", // autocasts as new Polyline()
paths: [
[-111.30, 52.68],
[-98, 49.5],
[-93.94, 29.89]
]
};
// Create a symbol for drawing the line
var lineSymbol = {
type: "simple-line", // autocasts as SimpleLineSymbol()
color: [150, 150, 255],
width: 4
};
// Create an object for storing attributes related to the line
var lineAtt = {
Name: "Keystone Pipeline",
Owner: "TransCanada",
Length: "3,456 km"
};
polylineGraphic = new Graphic({
geometry: polyline,
symbol: lineSymbol,
attributes: lineAtt,
popupTemplate: { // autocasts as new PopupTemplate()
title: "{Name}",
content: [{
type: "fields",
fieldInfos: [{
fieldName: "Name"
}, {
fieldName: "Owner"
}, {
fieldName: "Length"
}]
}]
}
});
console.log("working polyline", polyline);
console.log("working graphic", polylineGraphic);
view.when(function(){
view.goTo({
target: polylineGraphic,
animate: true
}).then(function(){
view.popup.open({
features: [polylineGraphic],
location: polylineGraphic.geometry.paths[0][0]
});
});
});
});
$('#notWorkingButton').click(function(){
queryParams = app.pLineLayer.createQuery();
queryParams.where = "OBJECTID = 1709";
app.pLineLayer.queryFeatures(queryParams).then(function(results){
console.log("FeatureSet:", results);
// go to that graphic
view.when(function(){
view.goTo({
target: results.features[0], // Graphic object
zoom: 20
});
});
});
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
<input type="submit" id="workingButton" value="working">
<input type="submit" id="notWorkingButton" value="not working">
</body>
</html>
... View more
01-04-2019
03:58 PM
|
0
|
2
|
2087
|
Title | Kudos | Posted |
---|---|---|
1 | 05-29-2019 11:11 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|