Hi,
I need immediate help . Iam new to arcgis javascript api.Iam working on 3.26 version. I have a geojson file as below : Please let me know how i can create a graphic at the coordinate given in this json file. Actually i should be able to read co-ordinates from this json file and display it as a graphic on map
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-88.13198711899997, 41.79304797900005]
},
"properties": {
"LocationId": 1,
"GeometryType": "Point"
}
}
]
}
Please find my code snippet below :
var map;
require([
"esri/map", "esri/layers/FeatureLayer", "esri/layers/GraphicsLayer",
"esri/tasks/query", "esri/geometry/Circle", "esri/SpatialReference", "esri/geometry/Point",
"esri/graphic", "esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "esri/renderers/SimpleRenderer",
"esri/config", "esri/Color", "dojo/dom", "dojo/domReady!"
], function(
Map, FeatureLayer,
GraphicsLayer,
Query, Circle, SpatialReference, Point,
Graphic, SimpleMarkerSymbol,
SimpleLineSymbol, SimpleFillSymbol, SimpleRenderer,
esriConfig, Color, dom
) {
map = new Map("mapDiv", {
basemap: "streets",
center: [-88.158805, 41.786075],
zoom: 17,
slider: false
});
var pointGLayer = new GraphicsLayer();
map.addLayer(pointGLayer);
var data = [
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-88.13198711899997, 41.79304797900005]
},
"properties": {
"LocationId": 1,
"GeometryType": "esriGeometryPoint"
}
}]
}];
var symbol = new SimpleMarkerSymbol(
SimpleMarkerSymbol.STYLE_CIRCLE,
12,
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_NULL,
new Color([247, 34, 101, 0.9]),
1
),
new Color([207, 34, 171, 0.5])
);
for (i = 0; i < data.features.length; i++) {
var pt = new Point(features.geometry.coordinates[0], features.geometry.coordinates[1],
new SpatialReference({
wkid: 4326
}));
var graphic = new Graphic(pt, symbol);
pointGLayer.add(graphic);
console.log(data);
}
});
Hi,Its a bit urgent.I couldnt find anything related to display of geojson co-ordinates on map as graphic. Please let me know if this will work or it works with only json format file. Iam using 3.26 version javascript api.