|
POST
|
I building building a basic application with the ESRI javascript API 3.24, accepting that I don't have ArcGIS Server or AGO, is there any approach to add nearby geojson record to the guide, this inquiry had been asked commonly. I don't have to utilize Terraformer. I am attaching my geojson document and the code I have up until now, there is no error, yet geojson isn't appearing in the map. In the event that there is an answer for this would i be able to apply it on WAB, or is there any out of box widget to add local geojson file to the map (on map load ). <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>FeatureLayer</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.24/esri/css/esri.css">
<script src="http://js.arcgis.com/3.24/"></script>
<!--<script src="travel6.json" type="text/javascript"></script> -->
<style>
html, body, #map {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/map",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"esri/renderers/SimpleRenderer",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/FeatureSet",
"esri/layers/FeatureLayer",
"esri/request",
"esri/geometry/Polygon",
"esri/graphic",
"dojo/on",
"dojo/_base/array",
"dojo/domReady!"
], function(
Map, SimpleMarkerSymbol, Color, SimpleRenderer, SimpleFillSymbol,SimpleLineSymbol,
FeatureSet, FeatureLayer , esritRequest, Polygon, Graphic, on, array
) {
var map = new Map("map", {
basemap : "streets",
center : [-96.68338, 33.02529],
zoom : 18
});
var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
new Color([255,0,0]), 2),new Color([255,255,0,0.25])
);
// First we create an empty feature collection:
var featureCollection = {
"layerDefinition": null,
"featureSet": {
"features": [],
"geometryType": "esriGeometryPolygon"
}
};
//give the feature collection a layer definition:
featureCollection.layerDefinition = {
"geometryType": "esriGeometryPolygon",
"objectIdField": "ObjectID",
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"type" : "esriSFS",
"style" : "esriSFSSolid",
"color": [
31,
121,
180,
255],
"outline": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [ 110,110, 110, 255],
width: 0.4}
}
}
},
"fields": [{
"name" : "OBJECTID",
"type" : "esriFieldTypeOID",
"alias" : "OBJECTID"
},
{
"name" : "RectangleID",
"type" : "esriFieldTypeString",
"alias" : "RectangleID",
"length" : 10
},
{
"name" : "section",
"type" : "esriFieldTypeString",
"alias" : "section",
"length" : 2
},
{
"name" : "lot",
"type" : "esriFieldTypeString",
"alias" : "lot",
"length" : 3
},
{
"name" : "space",
"type" : "esriFieldTypeString",
"alias" : "space",
"length" : 4
},
{
"name" : "spaceid",
"type" : "esriFieldTypeString",
"alias" : "spaceid",
"length" : 10
},
{
"name" : "Shape_Length",
"type" : "esriFieldTypeDouble",
"alias" : "Shape_Length"
},
{
"name" : "Shape_Area",
"type" : "esriFieldTypeDouble",
"alias" : "Shape_Area"
}
]
};
//featureCollection object is in the correct format to be passed in to a FeatureLayer:
featureLayer = new FeatureLayer(featureCollection, {
id: 'myFeatureLayer',
// fields: fields, // This is required when creating a layer from Graphics
ObjectIdField: "OBJECTID", // This must be defined when creating a layer from Graphics
spatialReference: {
wkid: 4326
},
mode: FeatureLayer.MODE_ONDEMAND
});
function requestData() {
var requestHandle = esriRequest({
url: "ab_py_wms.json",
callbackParamName: "jsoncallback"
});
requestHandle.then(requestSucceeded, requestFailed);
}
function requestSucceeded(response, io) {
//loop through the items and add to the feature layer
var features = [];
array.forEach(response.features, function(item) {
var attr = {};
//pull in any additional attributes if required
attr["section"] = item.properties.section;
var geometry = new polygon(
{rings: item.geometry.coordinates});
var graphic = new Graphic(geometry);
graphic.setAttributes(attr);
features.push(graphic);
});
featureLayer.applyEdits(features, null, null);
}
function requestFailed(error) {
console.log('failed');
}
map.addLayers([featureLayer]);
console.log(featureLayer);
});
</script>
</head>
<body class='claro'>
<div id="map" style="width:900px; height:600px;" ></div>
</body>
</html>
... View more
07-05-2018
04:51 AM
|
0
|
2
|
3603
|
|
POST
|
Xander This script saved my day a couple of times one line of your script I had never used before. return "{}-{}-{}".format(part1, part2, part3)
format is it a method to concatenate string elements. "Thank you" does not even begin to express the gratitude I have for this help.
... View more
06-28-2018
09:48 PM
|
0
|
4
|
1990
|
|
POST
|
You are absolutely correct, I mean labeling, and almost exactly right correct in your all other assumptions. Thank you
... View more
06-28-2018
07:22 AM
|
0
|
16
|
1990
|
|
POST
|
Thank you Xander, this worked as supposed to be "smarter". One last question-is it possible to generate the attribute as requested earlier?. Thanks Again
... View more
06-27-2018
07:18 PM
|
0
|
18
|
3103
|
|
POST
|
Yes Yes that's it. Thank you Bakker, I did not test it yet but from code and the result, hat was exactly what I am looking for. its just missing the attribute tables, I will try the field calculator for that. Will get back to you ASAP. I do appreciate that
... View more
06-27-2018
03:43 PM
|
0
|
0
|
3103
|
|
POST
|
Thank you Bakker for your help. the initial coordinate (lower left for instance)= (2523853.5,7124354.1) The spatial reference to be used (NAD83 / Texas North Central(ftUS) ) the number of blocks horizontally and vertically, (Horizontally 6, Vertically 5 the size of each rectangle (width and height): 40x40ft the spacing between the blocks: 3ft after that I need to divide each block to 32 sub sections (w:10ft h:5ft) just like what I have in attached pic, and fill the attribute similar as shown in the attached pic.
... View more
06-26-2018
05:14 PM
|
0
|
21
|
3103
|
|
POST
|
Thank you, do you have any code for replicating new location using the field calculator
... View more
06-26-2018
12:13 PM
|
0
|
0
|
1818
|
|
POST
|
thanks , yes I do have many blocks, I have to think of that script.
... View more
06-26-2018
12:12 PM
|
0
|
23
|
3103
|
|
POST
|
The Only problem I am facing now, is how to generate the grid with offset. I mean did fishnet support creating the polygons with offset, for each row and column?
... View more
06-26-2018
11:53 AM
|
0
|
27
|
3103
|
|
POST
|
I have to generate thousands of cells as a grid, and then I have to assign values to the cells, so far I know the a fishnet tool can generate the grid but how can I manage to create the offset. May some one have better Idea. The details of the grid are as illustrated in the attached diagram. I have 5 Rows and 6 column, after the 3rd column the grid should start with B, other numbering should be the same as A.
... View more
06-23-2018
08:04 PM
|
0
|
28
|
7382
|
|
POST
|
NO Luck still same error of the network dataset has not been dissolved.
... View more
06-12-2018
01:18 PM
|
0
|
1
|
2262
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-19-2020 12:53 AM | |
| 1 | 04-06-2020 10:52 AM | |
| 2 | 11-13-2018 07:53 AM | |
| 1 | 09-13-2019 10:55 AM | |
| 1 | 03-07-2019 11:43 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-07-2022
04:49 AM
|