开发者

SimpleGeo - Obtaining the Longitude and Latitude from response

I have the following response in JSON format, but, can't seem to figure out how to obtain the logitude and latitude from it

I tried

Dim result = JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(response.Content)

but when I try to obtain an an item with the key "address"...I get nothing

here is the JSON response

{"query":{"latitude":37.779278,"longitude":-122.416582,"address":"San Francisco, CA"},"timestamp":1311197030.697,"features":[{"handle":"SG_4oR6CqYUXZVEotM8ncLk80_37.780722_-122.417364","name":"06075012400","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-122.421050,37.775147,-122.413365,37.784657],"href":"http://api.simplegeo.com/1.0/features/SG_4oR6CqYUXZVEotM8ncLk80_37.780722_-122.417364.json","abbr":null,"classifiers":[{"category":"US Census","type":"Region","subcategory":"Tract"}]},{"handle":"SG_6qya2EVo227KTsivPoqx28_37.782005_-122.420177","name":"Civic Center","license":"Not For Redistribution","bounds":[-122.425482,37.773229,-122.409979,37.790629],"href":"http://api.simplegeo.com/1.0/features/SG_6qya2EVo227KTsivPoqx28_37.782005_-122.420177.json","abbr":null,"classifiers":[{"category":"Neighborhood","type":"Region","subcategory":null}]},{"handle":"SG_2TnIHbITsDUjuLyhbVeYgx_37.779398_-122.419353","name":"94102","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-122.429920,37.769441,-122.404583,37.789226],"href":"http://api.simplegeo.com/1.0/features/SG_2TnIHbITsDUjuLyhbVeYgx_37.779398_-122.419353.json","abbr":null,"classifiers":[{"category":"Postal Code","type":"Region","subcategory":null}]},{"handle":"SG_4gzxFRgOF9YjFAtAiQFpDC_37.793367_-122.397153","name":"Assembly District 13","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-122.546386,37.708230,-122.281780,37.929824],"href":"http://api.simplegeo.com/1.0/features/SG_4gzxFRgOF9YjFAtAiQFpDC_37.793367_-122.397153.json","abbr":null,"classifiers":[{"category":"Legislative District","type":"Region","subcategory":"Provincial (Lower)"}]},{"handle":"SG_2WBEyBsRAqLAHw1QuqXTv1_37.787198_-122.429550","name":"Congressional District 8","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-122.612285,37.708131,-122.281780,37.929824],"href":"http://api.simplegeo.com/1.0/features/SG_2WBEyBsRAqLAHw1QuqXTv1_37.787198_-122.429550.json","abbr":null,"classifiers":[{"category":"Legislative District","type":"Region","subcategory":"National"}]},{"handle":"SG_7TAYWdlPlAIzUDT7MVwxmZ_37.759717_-122.693971","name":"San Francisco","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-123.173825,37.639830,-122.281780,37.929824],"href":"http://api.simplegeo.com/1.0/features/SG_7TAYWdlPlAIzUDT7MVwxmZ_37.759717_-122开发者_如何学JAVA.693971.json","abbr":null,"classifiers":[{"category":"Administrative","type":"Region","subcategory":"County"}]},{"handle":"SG_1mNfKHr5aXH7LWgmZL8Uq7_37.759717_-122.693971","name":"San Francisco","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-123.173825,37.639830,-122.281780,37.929824],"href":"http://api.simplegeo.com/1.0/features/SG_1mNfKHr5aXH7LWgmZL8Uq7_37.759717_-122.693971.json","abbr":null,"classifiers":[{"category":"Municipal","type":"Region","subcategory":"City"}]},{"handle":"SG_4wyrIh6TQId1MiL2cfYa5d_37.759717_-122.693971","name":"San Francisco Unified School District","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-123.173825,37.639830,-122.281780,37.929824],"href":"http://api.simplegeo.com/1.0/features/SG_4wyrIh6TQId1MiL2cfYa5d_37.759717_-122.693971.json","abbr":null,"classifiers":[{"category":"School District","type":"Region","subcategory":"Unified"}]},{"handle":"SG_4n4ze6xOdAFr0gp1WboZrN_37.551206_-122.127401","name":"San Francisco","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-122.516667,37.191667,-121.733333,38.041667],"href":"http://api.simplegeo.com/1.0/features/SG_4n4ze6xOdAFr0gp1WboZrN_37.551206_-122.127401.json","abbr":null,"classifiers":[{"category":"Urban Area","type":"Region","subcategory":null}]},{"handle":"SG_1wm1YKOa9HLv5VI8IbHVW7_38.107525_-122.693633","name":"State Senate District 3","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-123.134523,37.708230,-122.281780,38.532067],"href":"http://api.simplegeo.com/1.0/features/SG_1wm1YKOa9HLv5VI8IbHVW7_38.107525_-122.693633.json","abbr":null,"classifiers":[{"category":"Legislative District","type":"Region","subcategory":"Provincial (Upper)"}]},{"handle":"SG_2MySaPILVQG3MoXrsVehyR_37.215297_-119.663837","name":"California","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-124.482003,32.528832,-114.131211,42.009517],"href":"http://api.simplegeo.com/1.0/features/SG_2MySaPILVQG3MoXrsVehyR_37.215297_-119.663837.json","abbr":"CA","classifiers":[{"category":"Subnational","type":"Region","subcategory":"State"}]},{"handle":"SG_3tLT0I5cOUWIpoVOBeScOx_41.316130_-119.116571","name":"America/Los_Angeles","license":"creativecommons.org/publicdomain/zero/1.0/","bounds":[-124.733253,32.534622,-114.039345,49.002892],"href":"http://api.simplegeo.com/1.0/features/SG_3tLT0I5cOUWIpoVOBeScOx_41.316130_-119.116571.json","abbr":null,"classifiers":[{"category":"Time Zone","type":"Region","subcategory":null}]},{"handle":"SG_3uwSAEdXVBzK1ZER9Nqkdp_45.687160_-112.493107","name":"United States of America","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-179.142471,18.930138,179.781150,71.412180],"href":"http://api.simplegeo.com/1.0/features/SG_3uwSAEdXVBzK1ZER9Nqkdp_45.687160_-112.493107.json","abbr":null,"classifiers":[{"category":"National","type":"Region","subcategory":null}]}],"weather":{"wind_speed":"6.9 meters per second","temperature":"78F","dewpoint":"59F","cloud_cover":"0%","wind_direction":"325 degrees","forecast":{"tonight":{"conditions":"Mostly cloudy","precipitation":"0%","temperature":{"max":"58F","min":"55F"}},"tomorrow":{"conditions":"Clear","precipitation":"0%","temperature":{"max":"70F","min":"56F"}},"today":{"conditions":"Clear","precipitation":"0%","temperature":{"max":"73F","min":"59F"}}},"conditions":"Clear"},"demographics":{"population_density":7489},"intersections":[{"distance":38.43225250350512,"geometry":{"type":"Point","coordinates":[-122.4167858,37.779583799999997]},"properties":{"highways":[{"osm_way_id":"33789567","type":"residential","name":"Fulton Street"},{"osm_way_id":"26988030","type":"tertiary","name":"Larkin Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) and contributors","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65287204"},{"distance":69.25254468826954,"geometry":{"type":"Point","coordinates":[-122.4165794,37.778655200000003]},"properties":{"highways":[{"osm_way_id":"26988030","type":"tertiary","name":"Larkin Street"},{"osm_way_id":"8920461","type":"unclassified","name":"Grove Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) and contributors","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65354417"},{"distance":139.2095933887024,"geometry":{"type":"Point","coordinates":[-122.41696140000001,37.780493499999999]},"properties":{"highways":[{"osm_way_id":"27167270","type":"residential","name":"McAllister Street"},{"osm_way_id":"26988030","type":"tertiary","name":"Larkin Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) and contributors","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65352337"},{"distance":139.9292506517826,"geometry":{"type":"Point","coordinates":[-122.415127,37.779789000000001]},"properties":{"highways":[{"osm_way_id":"8915763","type":"residential","name":"Fulton Street"},{"osm_way_id":"26988009","type":"tertiary","name":"Hyde Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) and contributors","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65287201"},{"distance":152.92687955288244,"geometry":{"type":"Point","coordinates":[-122.4149213,37.778867400000003]},"properties":{"highways":[{"osm_way_id":"26988009","type":"tertiary","name":"Hyde Street"},{"osm_way_id":"8920461","type":"unclassified","name":"Grove Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) and contributors","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65360267"}],"address":{"geometry":{"coordinates":[-122.41670097091016,37.77925384607872],"type":"Point"},"properties":{"address":"164 Larkin St","distance":"0.01","postcode":"94109","city":"San Francisco","county":"San Francisco","province":"CA","country":"US"},"type":"Feature"}}


In this example I would expect there to be a key called "query" which returns another dictionary. That would have keys for longitude and latitude.

Dim queryDict = result.Item("query")
Dim lng = queryDict.Item("longitude")
Dim lat = queryDict.Item("latitude")

Excuse the syntax, but I haven't done .net/VB for ages, so have no idea if that's right.

It might also help you if visualise the JSON you've got. Try pasting it in to this tool and clicking the render button: http://chris.photobooks.com/json/default.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜