Map Layers from JSON api

784
4
04-10-2017 12:56 PM
BeckBeach
New Contributor

Hi! I am trying to make map layers from my JSON API links. Here is my codepen, which doesn't work:

http://codepen.io/beckbeach/pen/EWqJzL 

What do I need to do in order to get my links to display the data points?

It works with the CSV data layers but the client wants the layers to run from an API.

Tags (2)
0 Kudos
4 Replies
KellyHutchins
Esri Frequent Contributor

It doesn't look like the output from your url is valid json? This is what I see if I log out the value to the console. 

Object {0: "h", 1: "t", 2: "t", 3: "p", 4: "s", 5: ":", 6: "/", 7: "/", 8: "w", 9: "w", 10: "w", 11: ".", 12: "v", 13: "e", 14: "r", 15: "i", 16: "z", 17: "o", 18: "n", 19: "c", 20: "l", 21: "o", 22: "u", 23: "d", 24: "p", 25: "l", 26: "a", 27: "t", 28: "f", 29: "o", 30: "r", 31: "m", 32: ".", 33: "c", 34: "o", 35: "m", 36: "/", 37: "s", 38: "e", 39: "r", 40: "v", 41: "i", 42: "c", 43: "e", 44: "-", 45: "s", 46: "t", 47: "a", 48: "t", 49: "u", 50: "s", 51: "/", 52: "a", 53: "p", 54: "i", 55: "2", 56: ".", 57: "p", 58: "h", 59: "p", 60: "?", 61: "s", 62: "t", 63: "a", 64: "t", 65: "u", 66: "s", 67: "=", 68: "t", 69: "r", 70: "u", 71: "e", 72: "&", 73: "d", 74: "e", 75: "p", 76: "t", 77: "h", 78: "=", 79: "1", 80: "&", 81: "p", 82: "r", 83: "o", 84: "j", 85: "e", 86: "c", 87: "t", 88: "=", 89: "v", 90: "c", 91: "p", 92: "%", 93: "2", 94: "F", 95: "s", 96: "t", 97: "a", 98: "t", 99: "u"…}

I also tested it out using the esriRequest sample in the help. What is the output of your url supposed to look like? 

ArcGIS API for JavaScript Sandbox 

BeckBeach
New Contributor

Hi! Here it is. Thanks for helping me!!

{

"last-update-author": "Faes, David B",

"last-update-date": "2017-04-10T12:41:27Z",

"last-update-message": "updated OpenStack version",

"response-schema": "default",

"sites": [

{

"attributes": {

"Facility_Type": "GNDC",

"Site_Catagories": "VCP Lab",

"Tier": 1,

"address": {

"Address": "1880 Campus Commons Drive",

"City": "Reston",

"Country": "USA",

"Latitude": 38.943438,

"Longitude": -77.334092,

"State": "VA",

"Zip": 20191,

"address_full": "1880 Campus Commons Drive, Reston VA, 20191"

},

"aliases": {

"Data_Center": "Reston",

"Name": "Reston",

"VES_MARKET_NAME": "Reston/Washington DC",

"monitoring": "reston"

},

"title": "Southlake VCP Site",

"type": "site"

},

"last-update-author": "SVC-STATUS-S1-ARLING",

"last-update-date": "2017-04-08T03:09:24Z",

"last-update-message": "VCP Remediation - service compute on vcp-vcp_labs s2 status 100 severity 100 at 2017-04-08T03:09:04Z",

"messages": [

"This is a VCP lab environment and may not be available at all times.\n"

],

"project": "vcp",

"response-schema": "default",

"site": "vcp_labs"

},

{

"attributes": {

"Facility_Type": "GNDC",

"Site_Catagories": "N&T/Teremark",

"Tier": 1,

"address": {

"Address": "1501 Francisco Street",

"City": "Torrance",

"Country": "USA",

"Latitude": 33.849997,

"Longitude": -118.303402,

"State": "CA",

"Zip": 90501,

"address_full": "1501 Francisco Street, Torrance CA, 90501"

},

"aliases": {

"Data_Center": "Torrance",

"Name": "Torrance",

"VES_MARKET_NAME": "Torrance/LA/San Diego"

},

"title": "Torrance VCP Site",

"type": "site"

},

"last-update-author": "SVC-STATUS-S1-ARLING",

"last-update-date": "2017-04-03T22:13:05Z",

"last-update-message": "Testing PATCH",

"messages": [

"VCP Torrance Decommission Date - 01/31/2017\n"

],

"project": "vcp",

"response-schema": "default",

"site": "torrance"

},

{

"attributes": {

"Facility_Type": "GNDC",

"Site_Catagories": "VCP Core",

"Tier": 1,

"address": {

"Address": "903 113th Street",

"City": "Arlington",

"Country": "USA",

"Latitude": 32.75793,

"Longitude": -97.044004,

"State": "TX",

"Zip": 76011,

"address_full": "903 113th Street, Arlington TX, 76011"

},

"aliases": {

"Data_Center": "Arlington",

"Name": "Arlington",

"VES_MARKET_NAME": "Arlington/Dallas",

"monitoring": "arlington"

},

"title": "Arlington VCP Site",

"type": "site"

},

"last-update-author": "SVC-STATUS-S1-ARLING",

"last-update-date": "2017-04-09T14:17:59Z",

"last-update-message": "VCP Remediation - service platform_orchestration on vcp-arlington s4 status 100 severity 100 at 2017-04-09T14:17:38Z",

"project": "vcp",

"response-schema": "default",

"site": "arlington"

},

{

"attributes": {

"Facility_Type": "Wireless IT",

"Site_Catagories": "VCP Core",

"Tier": 1,

"address": {

"Address": "200 Highland Road",

"City": "Twinsburg",

"Country": "USA",

"Latitude": 41.29934678,

"Longitude": -81.51575612,

"State": "OH",

"Zip": 44087,

"address_full": "200 Highland Road, Twinsburg OH, 44087"

},

"aliases": {

"Data_Center": "Twinsburg",

"Name": "Twinsburg",

"VES_MARKET_NAME": "Twinsburg",

"monitoring": "twinsburg"

},

"title": "Twinsburg VCP Site",

"type": "site"

},

"last-update-author": "SVC-STATUS-S1-ARLING",

"last-update-date": "2017-04-09T14:40:51Z",

"last-update-message": "VCP Remediation - service platform_orchestration on vcp-twinsburg s2 status 100 severity 100 at 2017-04-09T14:40:30Z",

"project": "vcp",

"response-schema": "default",

"site": "twinsburg"

},

{

"attributes": {

"Facility_Type": "Wireless NEC",

"Site_Catagories": "VCP Core",

"Tier": 1,

"address": {

"Address": "135 Cyber Court",

"City": "Rocklin ",

"Country": "USA",

"Latitude": 38.82272,

"Longitude": -121.306042,

"State": "CA",

"Zip": 95795,

"address_full": "135 Cyber Court, Rocklin CA, 95795"

},

"aliases": {

"Data_Center": "Rocklin",

"Name": "Rocklin",

"VES_MARKET_NAME": "Rocklin CA"

},

"title": "Rocklin VCP Site",

"type": "site"

},

"last-update-author": "Desai, Kalindee",

"last-update-date": "2017-04-05T21:41:33Z",

"last-update-message": "Update default.attributes",

"project": "vcp",

"response-schema": "default",

"site": "rocklin"

},

{

"attributes": {

"Facility_Type": "Wireless NEC",

"Site_Catagories": "VCP Core",

"Tier": 1,

"address": {

"Address": "4323 Arrowswest Drive",

"City": "Colorado Springs",

"Country": "USA",

"Latitude": 38.895326,

"Longitude": -104.86778,

"State": "CO",

"Zip": 80907,

"address_full": "4323 Arrowswest Drive, Colorado Springs CO, 80907"

},

"aliases": {

"Data_Center": "Colorado Springs",

"Name": "Colorado Springs",

"VES_MARKET_NAME": "Denver/Colorado Springs",

"short": "CO Springs"

},

"title": "Colorado Springs VCP Site",

"type": "site"

},

"last-update-author": "Desai, Kalindee",

"last-update-date": "2017-04-05T21:41:05Z",

"last-update-message": "Update default.attributes",

"project": "vcp",

"response-schema": "default",

"site": "colorado_springs"

},

{

"attributes": {

"Facility_Type": "Wireless NEC",

"Site_Catagories": "VCP Core",

"Tier": 1,

"address": {

"Address": "500 West Dove Road",

"City": "Southlake",

"Country": "USA",

"Latitude": 32.9703877,

"Longitude": -97.15676048,

"State": "TX",

"Zip": 76902,

"address_full": "500 West Dove Road, Southlake TX, 76902"

},

"aliases": {

"Data_Center": "Southlake",

"Name": "Southlake",

"VES_MARKET_NAME": "Southlake"

},

"title": "Southlake VCP Site",

"type": "site"

},

"last-update-author": "faesda",

"last-update-date": "2017-03-24T13:45:33Z",

"last-update-message": "cleanup",

"project": "vcp",

"response-schema": "default",

"site": "southlake"

},

{

"attributes": {

"Facility_Type": "Wireless NEC",

"Site_Catagories": "VCP Core",

"Tier": 1,

"address": {

"Address": "145 Chubb Way",

"City": "Branchburg",

"Country": "USA",

"Latitude": 40.556644,

"Longitude": -74.704956,

"State": "NJ",

"Zip": "08876",

"address_full": "145 Chubb Way, Branchburg NJ, 08876"

},

"aliases": {

"Data_Center": "Branchburg",

"Name": "Branchburg",

"VES_MARKET_NAME": "Branchburg/New York"

},

"title": "Branchburg VCP Site",

"type": "site"

},

"last-update-author": "Faes, David B",

"last-update-date": "2017-04-10T12:41:27Z",

"last-update-message": "updated OpenStack version",

"project": "vcp",

"response-schema": "default",

"site": "branchburg"

},

{

"attributes": {

"Facility_Type": "",

"Site_Catagories": "VCP Core",

"Tier": 1,

"address": {

"Address": "2606 Carsins Run Road",

"City": "Aberdeen",

"Country": "USA",

"Latitude": 39.498314,

"Longitude": -76.242099,

"State": "MD",

"Zip": 21001,

"address_full": "2606 Carsins Run Road, Aberdeen MD, 21001"

},

"aliases": {

"Data_Center": "Aberdeen",

"Name": "Aberdeen",

"VES_MARKET_NAME": "Aberdeen/Perryman"

},

"title": "Aberdeen VCP Site",

"type": "site"

},

"last-update-author": "faesda",

"last-update-date": "2017-03-24T13:45:33Z",

"last-update-message": "cleanup",

"project": "vcp",

"response-schema": "default",

"site": "aberdeen"

}

]

}

0 Kudos
BeckBeach
New Contributor

Hi! Here it is:

{
"last-update-author": "Faes, David B",
"last-update-date": "2017-04-10T12:41:27Z",
"last-update-message": "updated OpenStack version",
"response-schema": "default",
"sites": [
{
"attributes": {
"Facility_Type": "GNDC",
"Site_Catagories": "VCP Lab",
"Tier": 1,
"address": {
"Address": "1880 Campus Commons Drive",
"City": "Reston",
"Country": "USA",
"Latitude": 38.943438,
"Longitude": -77.334092,
"State": "VA",
"Zip": 20191,
"address_full": "1880 Campus Commons Drive, Reston VA, 20191"
},
"aliases": {
"Data_Center": "Reston",
"Name": "Reston",
"VES_MARKET_NAME": "Reston/Washington DC",
"monitoring": "reston"
},
"title": "Southlake VCP Site",
"type": "site"
},
"last-update-author": "SVC-STATUS-S1-ARLING",
"last-update-date": "2017-04-08T03:09:24Z",
"last-update-message": "VCP Remediation - service compute on vcp-vcp_labs s2 status 100 severity 100 at 2017-04-08T03:09:04Z",
"messages": [
"This is a VCP lab environment and may not be available at all times.\n"
],
"project": "vcp",
"response-schema": "default",
"site": "vcp_labs"
},
{
"attributes": {
"Facility_Type": "GNDC",
"Site_Catagories": "N&T/Teremark",
"Tier": 1,
"address": {
"Address": "1501 Francisco Street",
"City": "Torrance",
"Country": "USA",
"Latitude": 33.849997,
"Longitude": -118.303402,
"State": "CA",
"Zip": 90501,
"address_full": "1501 Francisco Street, Torrance CA, 90501"
},
"aliases": {
"Data_Center": "Torrance",
"Name": "Torrance",
"VES_MARKET_NAME": "Torrance/LA/San Diego"
},
"title": "Torrance VCP Site",
"type": "site"
},
"last-update-author": "SVC-STATUS-S1-ARLING",
"last-update-date": "2017-04-03T22:13:05Z",
"last-update-message": "Testing PATCH",
"messages": [
"VCP Torrance Decommission Date - 01/31/2017\n"
],
"project": "vcp",
"response-schema": "default",
"site": "torrance"
},
{
"attributes": {
"Facility_Type": "GNDC",
"Site_Catagories": "VCP Core",
"Tier": 1,
"address": {
"Address": "903 113th Street",
"City": "Arlington",
"Country": "USA",
"Latitude": 32.75793,
"Longitude": -97.044004,
"State": "TX",
"Zip": 76011,
"address_full": "903 113th Street, Arlington TX, 76011"
},
"aliases": {
"Data_Center": "Arlington",
"Name": "Arlington",
"VES_MARKET_NAME": "Arlington/Dallas",
"monitoring": "arlington"
},
"title": "Arlington VCP Site",
"type": "site"
},
"last-update-author": "SVC-STATUS-S1-ARLING",
"last-update-date": "2017-04-09T14:17:59Z",
"last-update-message": "VCP Remediation - service platform_orchestration on vcp-arlington s4 status 100 severity 100 at 2017-04-09T14:17:38Z",
"project": "vcp",
"response-schema": "default",
"site": "arlington"
},
{
"attributes": {
"Facility_Type": "Wireless IT",
"Site_Catagories": "VCP Core",
"Tier": 1,
"address": {
"Address": "200 Highland Road",
"City": "Twinsburg",
"Country": "USA",
"Latitude": 41.29934678,
"Longitude": -81.51575612,
"State": "OH",
"Zip": 44087,
"address_full": "200 Highland Road, Twinsburg OH, 44087"
},
"aliases": {
"Data_Center": "Twinsburg",
"Name": "Twinsburg",
"VES_MARKET_NAME": "Twinsburg",
"monitoring": "twinsburg"
},
"title": "Twinsburg VCP Site",
"type": "site"
},
"last-update-author": "SVC-STATUS-S1-ARLING",
"last-update-date": "2017-04-09T14:40:51Z",
"last-update-message": "VCP Remediation - service platform_orchestration on vcp-twinsburg s2 status 100 severity 100 at 2017-04-09T14:40:30Z",
"project": "vcp",
"response-schema": "default",
"site": "twinsburg"
},
{
"attributes": {
"Facility_Type": "Wireless NEC",
"Site_Catagories": "VCP Core",
"Tier": 1,
"address": {
"Address": "135 Cyber Court",
"City": "Rocklin ",
"Country": "USA",
"Latitude": 38.82272,
"Longitude": -121.306042,
"State": "CA",
"Zip": 95795,
"address_full": "135 Cyber Court, Rocklin CA, 95795"
},
"aliases": {
"Data_Center": "Rocklin",
"Name": "Rocklin",
"VES_MARKET_NAME": "Rocklin CA"
},
"title": "Rocklin VCP Site",
"type": "site"
},
"last-update-author": "Desai, Kalindee",
"last-update-date": "2017-04-05T21:41:33Z",
"last-update-message": "Update default.attributes",
"project": "vcp",
"response-schema": "default",
"site": "rocklin"
},
{
"attributes": {
"Facility_Type": "Wireless NEC",
"Site_Catagories": "VCP Core",
"Tier": 1,
"address": {
"Address": "4323 Arrowswest Drive",
"City": "Colorado Springs",
"Country": "USA",
"Latitude": 38.895326,
"Longitude": -104.86778,
"State": "CO",
"Zip": 80907,
"address_full": "4323 Arrowswest Drive, Colorado Springs CO, 80907"
},
"aliases": {
"Data_Center": "Colorado Springs",
"Name": "Colorado Springs",
"VES_MARKET_NAME": "Denver/Colorado Springs",
"short": "CO Springs"
},
"title": "Colorado Springs VCP Site",
"type": "site"
},
"last-update-author": "Desai, Kalindee",
"last-update-date": "2017-04-05T21:41:05Z",
"last-update-message": "Update default.attributes",
"project": "vcp",
"response-schema": "default",
"site": "colorado_springs"
},
{
"attributes": {
"Facility_Type": "Wireless NEC",
"Site_Catagories": "VCP Core",
"Tier": 1,
"address": {
"Address": "500 West Dove Road",
"City": "Southlake",
"Country": "USA",
"Latitude": 32.9703877,
"Longitude": -97.15676048,
"State": "TX",
"Zip": 76902,
"address_full": "500 West Dove Road, Southlake TX, 76902"
},
"aliases": {
"Data_Center": "Southlake",
"Name": "Southlake",
"VES_MARKET_NAME": "Southlake"
},
"title": "Southlake VCP Site",
"type": "site"
},
"last-update-author": "faesda",
"last-update-date": "2017-03-24T13:45:33Z",
"last-update-message": "cleanup",
"project": "vcp",
"response-schema": "default",
"site": "southlake"
},
{
"attributes": {
"Facility_Type": "Wireless NEC",
"Site_Catagories": "VCP Core",
"Tier": 1,
"address": {
"Address": "145 Chubb Way",
"City": "Branchburg",
"Country": "USA",
"Latitude": 40.556644,
"Longitude": -74.704956,
"State": "NJ",
"Zip": "08876",
"address_full": "145 Chubb Way, Branchburg NJ, 08876"
},
"aliases": {
"Data_Center": "Branchburg",
"Name": "Branchburg",
"VES_MARKET_NAME": "Branchburg/New York"
},
"title": "Branchburg VCP Site",
"type": "site"
},
"last-update-author": "Faes, David B",
"last-update-date": "2017-04-10T12:41:27Z",
"last-update-message": "updated OpenStack version",
"project": "vcp",
"response-schema": "default",
"site": "branchburg"
},
{
"attributes": {
"Facility_Type": "",
"Site_Catagories": "VCP Core",
"Tier": 1,
"address": {
"Address": "2606 Carsins Run Road",
"City": "Aberdeen",
"Country": "USA",
"Latitude": 39.498314,
"Longitude": -76.242099,
"State": "MD",
"Zip": 21001,
"address_full": "2606 Carsins Run Road, Aberdeen MD, 21001"
},
"aliases": {
"Data_Center": "Aberdeen",
"Name": "Aberdeen",
"VES_MARKET_NAME": "Aberdeen/Perryman"
},
"title": "Aberdeen VCP Site",
"type": "site"
},
"last-update-author": "faesda",
"last-update-date": "2017-03-24T13:45:33Z",
"last-update-message": "cleanup",
"project": "vcp",
"response-schema": "default",
"site": "aberdeen"
}
]
}

0 Kudos
KellyHutchins
Esri Frequent Contributor

Ok so that isn't what is being returned by the urls you are using. Perhaps they are missing something?  Here's a sample showing how you can  add data to a map - in this case we make a request to Flickr for photo info and display it on the map. 

Feature collection | ArcGIS API for JavaScript 3.20 

0 Kudos