How to render points on webmap from json object?

285
3
Jump to solution
04-28-2020 10:47 PM
KevinCheriyan
New Contributor III

I have a .json objects array with data that I want to use in my webmap. What is the best option to add this data (<3000 points) to the map? Should I use a GraphicsLayer object inside which I'll be adding each point as a Graphic with point geometry to? Should I use a FeatureLayer? Are there any examples in the ArcGIS JS docs that someone could point me to? 

As it is now, I can add point graphics individually to a Graphic object and then add to a GraphicsLayer using layer.graphics.add(newGraphic). But how can I do this on the fly as the map is receiving data from the json?

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
Egge-JanPollé1
MVP Regular Contributor

Hi Kevin Cheriyan,

Is your .json data proper GeoJSON (in compliance with the RFC 7946 specification)?

In that case you might have a look at GeoJSONLayer | ArcGIS API for JavaScript 4.15 with a nice example with USGS data: GeoJSONLayer | ArcGIS API for JavaScript 4.15.

HTH,

Egge-Jan

View solution in original post

3 Replies
Egge-JanPollé1
MVP Regular Contributor

Hi Kevin Cheriyan,

Is your .json data proper GeoJSON (in compliance with the RFC 7946 specification)?

In that case you might have a look at GeoJSONLayer | ArcGIS API for JavaScript 4.15 with a nice example with USGS data: GeoJSONLayer | ArcGIS API for JavaScript 4.15.

HTH,

Egge-Jan

View solution in original post

KevinCheriyan
New Contributor III

Thank you for your reply, Egge-Jan. The data is not in GeoJSON. However, I think converting it to GeoJSON may be my best option, since a simple graphics layer may not scale well up to 3000 points. 

What I'm really doing here is fetching data from a Postgres database, returned as a .json object. To use GeoJSON, looks like I'll need to convert the .json to a GeoJSON file and then use it. 

Also, what are the limitations of a GeoJSON? Can it hold 3,000 individual records (keys) with 50 values each? So one individual element would have 50 values. I'll be doing some research on this...

Thanks!

VictorTey
Esri Contributor

I had graphic layer with over 5k points and works fine however if it is easy enough for you to convert it to GeoJSON, that would probably be better practice and will make your life easier in the future to maintain