Kevin Bradshaw
Posts: 0
Joined: Sun Feb 01, 2015 2:05 pm

referencing an array in local storage

I've an array of reverse geocoded location names stored in an array called "locations" as follows:

[{"name":"2-26 Walnut Hill Road, Clinton, CT 06413, USA","latlng":-72.532335,"type":"RANGE_INTERPOLATED","formatted_name":"2-26 Walnut Hill Road, Clinton, CT 06413, USA","lat":41.2943101,"lng":-72.532335},{"name":"Clinton, CT 06413, USA","latlng":-72.53231389999999,"type":"APPROXIMATE","formatted_name":"Clinton, CT 06413, USA","lat":41.2943477,"lng":-72.53231389999999},{"name":"Clinton, CT, USA","latlng":-72.5288034,"type":"APPROXIMATE","formatted_name":"Clinton, CT, USA","lat":41.2882208,"lng":-72.5288034},{"name":"Middlesex County, CT, USA","latlng":-72.4731529,"type":"APPROXIMATE","formatted_name":"Middlesex County, CT, USA","lat":41.46985050000001,"lng":-72.4731529},{"name":"New Haven, CT, USA","latlng":-72.7570024,"type":"APPROXIMATE","formatted_name":"New Haven, CT, USA","lat":41.3583849,"lng":-72.7570024},{"name":"Connecticut, USA","latlng":-73.087749,"type":"APPROXIMATE","formatted_name":"Connecticut, USA","lat":41.6032207,"lng":-73.087749},{"name":"United States","latlng":-95.712891,"type":"APPROXIMATE","formatted_name":"United States","lat":37.09024,"lng":-95.712891}]

I'd like to reference one of these via

var location_name = Apperyio.storage.locations.get( "$[2].['formatted_name']" );

but I get a "Mapping expression is incorrect".

Regards,

Kevin

Kevin Bradshaw
Posts: 0
Joined: Sun Feb 01, 2015 2:05 pm

referencing an array in local storage

Fixed it!

Seems the notation should be as follows:

var location_name = Apperyio.storage.reverse_geocode.get( "$['results'][2]" ).formatted_address;

meaning, you need to get the array item as an objecr, then reference the specific parameter.

Return to “Issues”