For some reason, I'm having a hard time accessing a multidimensional array returned by an api call. I've spent hours trying different outcomes without success. I think I need a second pair of eyes. I'm trying to access the coordinates, latitude and longitude of the address. I tried with data.features.geometry.coordinates
and I get
error : geometry is undefined
Ajax api call :
$.ajax({
url: 'https://api.mapbox.com/access_token',
dataType: 'json',
type: 'GET',
contentType:'json',
success: function(data)
{
console.log(data);
}
});
Console returns this (sorry big data) :
{
"type": "FeatureCollection",
"features": [
{
"id": "address.2829218120531924",
"type": "Feature",
"place_type": [
"address"
],
"relevance": 1,
"properties": {
"accuracy": "rooftop"
},
"text": "Southwest 59th Court",
"place_name": "7313 Southwest 59th Court, Miami, Florida 33143, United States",
"matching_place_name": "7313 Southwest 59th Court, Miami, Florida 33143, United States of America",
"center": [
-80.290092,
25.70304
],
"geometry": {
"type": "Point",
"coordinates": [
-80.290092,
25.70304
]
},
"address": "7313",
"context": [
{
"id": "neighborhood.277794",
"text": "South Miami"
},
{
"id": "postcode.9047361780999760",
"text": "33143"
},
{
"id": "place.9791754866122320",
"wikidata": "Q8652",
"text": "Miami"
},
{
"id": "region.12218597351235010",
"short_code": "US-FL",
"wikidata": "Q812",
"text": "Florida"
},
{
"id": "country.9053006287256050",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
},
{
"id": "address.4735143261475820",
"type": "Feature",
"place_type": [
"address"
],
"relevance": 0.836667,
"properties": {
"accuracy": "street"
},
"text": "Southwest 59th Court",
"place_name": "Southwest 59th Court, Miami, Florida 33143, United States",
"matching_place_name": "Southwest 59th Court, Miami, Florida 33143, United States of America",
"center": [
-80.2906123,
25.7175916
],
"geometry": {
"type": "Point",
"coordinates": [
-80.2906123,
25.7175916
]
},
"context": [
{
"id": "neighborhood.277794",
"text": "South Miami"
},
{
"id": "postcode.9047361780999760",
"text": "33143"
},
{
"id": "place.9791754866122320",
"wikidata": "Q8652",
"text": "Miami"
},
{
"id": "region.12218597351235010",
"short_code": "US-FL",
"wikidata": "Q812",
"text": "Florida"
},
{
"id": "country.9053006287256050",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
},
{
"id": "address.3831267361566610",
"type": "Feature",
"place_type": [
"address"
],
"relevance": 0.801333,
"properties": {
"accuracy": "interpolated"
},
"text": "Southwest 59th Avenue",
"place_name": "7313 Southwest 59th Avenue, Miami, Florida 33143, United States",
"matching_place_name": "7313 Southwest 59th Avenue, Miami, Florida 33143, United States of America",
"center": [
-80.289343,
25.704199
],
"geometry": {
"type": "Point",
"coordinates": [
-80.289343,
25.704199
],
"interpolated": true
},
"address": "7313",
"context": [
{
"id": "neighborhood.277794",
"text": "South Miami"
},
{
"id": "postcode.9047361780999760",
"text": "33143"
},
{
"id": "place.9791754866122320",
"wikidata": "Q8652",
"text": "Miami"
},
{
"id": "region.12218597351235010",
"short_code": "US-FL",
"wikidata": "Q812",
"text": "Florida"
},
{
"id": "country.9053006287256050",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
},
{
"id": "postcode.9047361780999760",
"type": "Feature",
"place_type": [
"postcode"
],
"relevance": 0.787778,
"properties": {},
"text": "33143",
"place_name": "Miami, Florida 33143, United States",
"matching_place_name": "Miami, Florida 33143, United States of America",
"bbox": [
-80.3349178558439,
25.6880751353229,
-80.2450230532034,
25.7188419508551
],
"center": [
-80.29,
25.71
],
"geometry": {
"type": "Point",
"coordinates": [
-80.29,
25.71
]
},
"context": [
{
"id": "place.9791754866122320",
"wikidata": "Q8652",
"text": "Miami"
},
{
"id": "region.12218597351235010",
"short_code": "US-FL",
"wikidata": "Q812",
"text": "Florida"
},
{
"id": "country.9053006287256050",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
},
{
"id": "address.7544455348675994",
"type": "Feature",
"place_type": [
"address"
],
"relevance": 0.755,
"properties": {
"accuracy": "street"
},
"text": "Southwest 59th Court",
"place_name": "Southwest 59th Court, Miami, Florida 33156, United States",
"matching_place_name": "Southwest 59th Court, Miami, Florida 33156, United States of America",
"center": [
-80.2890202,
25.6464222
],
"geometry": {
"type": "Point",
"coordinates": [
-80.2890202,
25.6464222
]
},
"context": [
{
"id": "neighborhood.270046",
"text": "Deering Bay"
},
{
"id": "postcode.9496629846896750",
"text": "33156"
},
{
"id": "place.9791754866122320",
"wikidata": "Q8652",
"text": "Miami"
},
{
"id": "region.12218597351235010",
"short_code": "US-FL",
"wikidata": "Q812",
"text": "Florida"
},
{
"id": "country.9053006287256050",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
}
]
}