POST
|
Robert Its not working properly and map goes to wrong position while graphic update/add on exact location
... View more
11-04-2019
03:41 AM
|
0
|
2
|
2665
|
POST
|
Hi View.goTo is not working any suggestion..? let point = {
type: "point",
x: i.geometry.x,
y: i.geometry.y,
spatialReference: { wkid: 32642}
}
let g = new Graphic({
geometry: point,
symbol: {
type: "simple-marker",
size: 7,
color: [227, 241, 18],
outline: null
}
})
view.goTo({
target: point,
zoom: 12
});
view.graphics.add(g)
Output of point object is....
... View more
10-30-2019
04:51 AM
|
0
|
4
|
2924
|
POST
|
Thank you Robert, error occurs because of an array inside and array. I create an empty array with name myData and push graphic object into myData then call its instance in FeatureLayer. Its working well. let myData = [];
let g = new Graphic({
geometry:projectedPoint,
symbol: markerSymbol,
attributes: atts
})
myData.push(g)
let layer = new FeatureLayer({
geometryType: "point",
source: myData,
fields: fields,
objectIdField: "ObjectID",
renderer: dataRenderer,
popupTemplate: pTemplate
});
... View more
10-02-2019
12:20 AM
|
0
|
1
|
1548
|
POST
|
Robert, Full code is mentioned below. I received same error in my console <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>JSON</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link
rel="stylesheet"
href="https://js.arcgis.com/4.12/esri/themes/light/main.css"
/>
<script src="https://js.arcgis.com/4.12/"></script>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/request",
"esri/Graphic",
"esri/geometry/Point",
"esri/layers/FeatureLayer",
"esri/geometry/projection",
"esri/geometry/SpatialReference"
], function(Map, MapView, esriRequest, Graphic,Point, FeatureLayer, projection, SpatialReference) {
projection.load()
let url ="http://localhost:5000"
let fields = [
{
name: "ObjectID",
alias: "ObjectID",
type: "oid"
},
{
name: "Name",
alias: "Name",
type: "string"
},
{
name: "FAT",
alias: "FAT",
type: "string"
},
{
name: "Type",
alias: "Type",
type: "string"
},
{
name: "DC",
alias: "DC",
type: "string"
},
{
name: "ID",
alias: "ID",
type: "string"
},
{
name: "POP",
alias: "POP",
type: "string"
}
];
let pTemplate = {
title: "{title}",
content: [
{
type: "fields",
fieldInfos: [
{
fieldName: "Name",
label: "Name",
visible: true
},
{
fieldName: "FAT",
label: "FAT",
visible: true
},
{
fieldName: "Type",
label: "Type",
visible: true
},
{
fieldName: "DC",
label: "DC",
visible: true
},
{
fieldName: "ID",
label: "ID",
visible: true
},
{
fieldName: "POP",
label: "POP",
visible: true,
format: {
digitSeparator: true,
places: 0
}
}
]
}
]
};
let dataRenderer = {
type: "simple",
symbol : {
type: "simple-marker",
color: "blue",
size: 3,
outline: { // autocasts as new SimpleLineSymbol()
width: 0.5,
color: [0, 0, 0, 0.2]
}
},
}
let map = new Map({
basemap: "satellite",
});
let view = new MapView({
container: "viewDiv",
center: [67.068037, 24.872328],
zoom: 12,
map: map
});
let options = {
query: {
f: "json"
},
responseType: "json"
};
let fetchData = () => esriRequest(url, options).then(response => response.data)
let webservice = res => {
let graphicsArray = res.map(function(result){
let resultPnts = result.SHAPE.points.map(function(point){
return new Point({
x:point.x,
y:point.y,
spatialReference : result.SHAPE.srid
});
})
let atts = {
"ObjectID": result.OBJECTID,
"Splitter": result.Splitter,
"Comment": result.Comment,
"Name": result.Name,
"ID": result.ID,
"Placement": result.Placement,
"POP": result.POP
};
let graArr = resultPnts.map(function(pnt){
let projectedPoint = projection.project(pnt,view.spatialReference);
let markerSymbol = {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
color: [226, 119, 40]
};
return new Graphic({
geometry:projectedPoint,
symbol: markerSymbol,
attributes: atts
})
//console.log(graphic)
})
return graArr
})
console.log(graphicsArray)
let layer = new FeatureLayer({
geometryType: "point",
source: [graphicsArray],
fields: fields,
objectIdField: "ObjectID",
renderer: dataRenderer,
popupTemplate: pTemplate
});
map.add(layer)
}
view.when(() =>{
fetchData()
.then(webservice)
})
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
This is response of my data that i received in console.. I want to discuss one more thing. When i use geojson service(http://localhost:5000/geojson ) instead of json service(http://localhost:5000) the above code is working well. Why its not working on json service. Result of geojson service.
... View more
09-30-2019
11:43 PM
|
0
|
3
|
512
|
POST
|
Robert, There is no return in my console.log.... Can i use variable outSpatialReference in point object instead of result.SHAPE.srid..?? function webservice(response){
const outSpatialReference = new SpatialReference({
wkid: 32642
});
var graphicsArray = response.data.map(function(result){
//console.log(result)
var resultPnts = result.SHAPE.points.map(function(point){
return new Point({
x:point.x,
y:point.y,
spatialReference : result.SHAPE.srid
});
})
var atts = {
"ObjectID": result.OBJECTID,
"Splitter": result.Splitter,
"Comment": result.Comment,
"Name": result.Name,
"ID": result.ID,
"Placement": result.Placement,
"POP": result.POP
};
var graArr = resultPnts.map(function(pnt){
var projectedPoint = projection.project(pnt,outSpatialReference);
var markerSymbol = {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
color: [226, 119, 40]
};
var graphic = new Graphic({
geometry:projectedPoint,
symbol: markerSymbol,
attributes: atts
})
console.log(graphic)
})
return graArr
})
... View more
09-27-2019
05:16 AM
|
0
|
5
|
512
|
POST
|
Sorry Robert 4326 is spatial reference of my another service. Spatial reference of data returned by this service is 32642
... View more
09-26-2019
10:57 AM
|
0
|
7
|
1036
|
POST
|
Spatial reference is 4326 but when i used GeoJSON service it works well. GeoJSON service that i had used has same spatial reference as same as this web service.
... View more
09-26-2019
09:33 AM
|
0
|
9
|
1036
|
POST
|
Yes Robert. I get data in console. Following data is from line 199.
... View more
09-26-2019
06:14 AM
|
0
|
2
|
1036
|
POST
|
Hi Any one can help to pick my mistakes in given code. In web console data is showing but it's not displaying on map. <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>GeoJSONLayer - 4.12</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link
rel="stylesheet"
href="https://js.arcgis.com/4.12/esri/themes/light/main.css"
/>
<script src="https://js.arcgis.com/4.12/"></script>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/request",
"esri/Graphic",
"esri/geometry/Point",
"esri/layers/FeatureLayer",
], function(Map, MapView, esriRequest, Graphic,Point, FeatureLayer) {
const url ="http://localhost:5000"
const map = new Map({
basemap: "satellite",
});
const view = new MapView({
container: "viewDiv",
center: [67.068037, 24.872328],
zoom: 12,
map: map
});
const fields = [
{
name: "ObjectID",
alias: "ObjectID",
type: "oid"
},
{
name: "Name",
alias: "Name",
type: "string"
},
{
name: "FAT",
alias: "FAT",
type: "string"
},
{
name: "Type",
alias: "Type",
type: "string"
},
{
name: "DC",
alias: "DC",
type: "string"
},
{
name: "ID",
alias: "ID",
type: "string"
},
{
name: "POP",
alias: "POP",
type: "string"
}
];
const pTemplate = {
title: "{title}",
content: [
{
type: "fields",
fieldInfos: [
{
fieldName: "Name",
label: "Name",
visible: true
},
{
fieldName: "FAT",
label: "FAT",
visible: true
},
{
fieldName: "Type",
label: "Type",
visible: true
},
{
fieldName: "DC",
label: "DC",
visible: true
},
{
fieldName: "ID",
label: "ID",
visible: true
},
{
fieldName: "POP",
label: "POP",
visible: true,
format: {
digitSeparator: true,
places: 0
}
}
]
}
]
};
const dataRenderer = {
type: "simple",
symbol : {
type: "simple-marker",
color: "blue",
size: 3,
outline: { // autocasts as new SimpleLineSymbol()
width: 0.5,
color: [0, 0, 0, 0.2]
}
},
}
var options = {
query: {
f: "json"
},
responseType: "json"
};
esriRequest(url, options).then(webservice)
function webservice(response){
var graphicsArray = response.data.map(function(result){
//console.log(result)
var resultPnts = result.SHAPE.points.map(function(point){
return new Point({
x:point.x,
y:point.y,
spatialReference : result.SHAPE.srid
});
})
var atts = {
"ObjectID": result.OBJECTID,
"Splitter": result.Splitter,
"Comment": result.Comment,
"Name": result.Name,
"ID": result.ID,
"Placement": result.Placement,
"POP": result.POP
};
var graArr = resultPnts.map(function(pnt){
var markerSymbol = {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
color: [226, 119, 40]
};
return new Graphic({
geometry:pnt,
symbol: markerSymbol,
attributes: atts
})
})
return graArr
})
//console.log(graphicsArray)
const layer = new FeatureLayer({
geometryType: "point",
source: [graphicsArray],
fields: fields,
objectIdField: "ObjectID",
renderer: dataRenderer,
popupTemplate: pTemplate
});
map.add(layer);
}
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
... View more
09-26-2019
05:35 AM
|
0
|
15
|
1757
|
POST
|
Hi i have some records of related table.I want to add click event on row that when clicked on table row map should go to feature location. Please consider the following snippet of code in which click event is working only for first click if i click second time to same row or any other row it does not working. Robert Scheitlin, GISP Egge-Jan PolléKelly Hutchins Response from related record array of relatedRecordGroups let fatdiv = document.getElementById('fat')
fatdiv.addEventListener('click', () =>{
queryRelated({
url: "https://172.16.6.159:6443/arcgis/rest/services/KarachiSDE/FeatureServer/1",
objectIds: _this.state.id,
relationshipId: 1,
returnGeometry: true,
outFields: ["Name", "FAT", "DC", "POP"]
/* params: { returnCountOnly: true } */
})
.then(response => {
console.log(response)
myTableDiv.innerHTML = ''
var table = document.createElement('TABLE');
table.setAttribute('id', 'table')
//table.appendChild(close)
var thead = document.createElement('thead')
table.appendChild(thead)
var header = document.createElement("tr");
header.setAttribute('id', 'header-tr')
thead.appendChild(header)
var tbody = document.createElement('tbody')
table.appendChild(tbody)
if (response.fields) {
response.fields.forEach(j => {
var column = document.createElement("th");
column.setAttribute('id', 'table-header')
column.textContent = j.alias;
header.appendChild(column);
// console.log(j)
})
}
else {
return null
}
response.relatedRecordGroups.forEach(e => {
e.relatedRecords.forEach(i => {
console.log(i)
var row = document.createElement("tr");
tbody.appendChild(row);
response.fields.forEach(k => {
//console.log(response.fields)
var columns = document.createElement("td");
columns.textContent = i.attributes[k.name];
row.appendChild(columns);
columns.addEventListener('click', () => {
//console.log(i.geometry)
view.goTo({
target: [i.geometry],
zoom: 18
})
})
})
/* console.log(i.attributes.Name)
console.log(i.attributes.FAT)
console.log(i.attributes.DC)
console.log(i.attributes.POP) */
})
}) //console.log(response.relatedRecordGroups)
myTableDiv.appendChild(table);
//view.ui.add(expand, 'top-left')
})
})
... View more
08-28-2019
10:35 PM
|
0
|
0
|
536
|
POST
|
Robert I am very grateful to your help and i am really sorry that you had to suffer so much because of me.
... View more
08-25-2019
09:56 PM
|
0
|
0
|
265
|
POST
|
Robert Could you please give me sample code for given json string that how to parse and create feature layer.. {
"data": [
{
"OBJECTID": 146,
"Splitter": "64",
"Comment": "DHA Phase05",
"Name": "Plaza POP ODB 02",
"ID": "2100604",
"Placement": "Aerial",
"POP": 21006,
"Shape": {
"srid": 32642,
"version": 1,
"points": [
{
"x": 301997.6824000003,
"y": 2746232.8489999995,
"z": null,
"m": null
}
],
"figures": [
{
"attribute": 1,
"pointOffset": 0
}
],
"shapes": [
{
"parentOffset": -1,
"figureOffset": 0,
"type": 1
}
],
"segments": []
}
},
{
"OBJECTID": 147,
"Splitter": "64",
"Comment": "DHA Phase06",
"Name": "Badar POP ODB Muhafiz",
"ID": "2100502",
"Placement": "Aerial",
"POP": 21005,
"Shape": {
"srid": 32642,
"version": 1,
"points": [
{
"x": 302831.8328999998,
"y": 2742953.342599999,
"z": null,
"m": null
}
],
"figures": [
{
"attribute": 1,
"pointOffset": 0
}
],
"shapes": [
{
"parentOffset": -1,
"figureOffset": 0,
"type": 1
}
],
"segments": []
}
}
]
}
... View more
08-22-2019
09:27 PM
|
0
|
2
|
1960
|
POST
|
Robert.. i have called json service and got data in console. But when i use code from this sample https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=layers-featurelayer-collection and try to got data with featureCollection, i received "undefined". How can i create featureCollection?? Response from JSON service {
"data": [
{
"OBJECTID": 146,
"Splitter": "64",
"Comment": "DHA Phase05",
"Name": "Plaza POP ODB 02",
"ID": "2100604",
"Placement": "Aerial",
"POP": 21006,
"Shape": {
"srid": 32642,
"version": 1,
"points": [
{
"x": 301997.6824000003,
"y": 2746232.8489999995,
"z": null,
"m": null
}
],
"figures": [
{
"attribute": 1,
"pointOffset": 0
}
],
"shapes": [
{
"parentOffset": -1,
"figureOffset": 0,
"type": 1
}
],
"segments": []
}
}
]
}
... View more
08-22-2019
12:14 AM
|
0
|
4
|
1960
|
Title | Kudos | Posted |
---|---|---|
1 | 11-11-2021 01:04 AM | |
2 | 11-22-2022 01:18 AM | |
1 | 07-15-2021 08:05 AM | |
1 | 07-21-2019 03:12 AM |
Online Status |
Offline
|
Date Last Visited |
01-02-2024
04:00 PM
|