回答
這應該工作:
班反序列化JSON字符串
public class PlaceInfo
{
public string place_id { get; set; }
public string licence { get; set; }
public string osm_type { get; set; }
public string osm_id { get; set; }
public List<string> boundingbox { get; set; }
public string lat { get; set; }
public string lon { get; set; }
public string display_name { get; set; }
public string @class { get; set; }
public string type { get; set; }
public double importance { get; set; }
public string icon { get; set; }
}
這是代碼從網站上的信息: 格式是JSON,我使用的是json serializor的c#
using System.Runtime.Serialization; using System.Runtime.Serialization.Json;
WebClient webClient = new WebClient();
string jsonString = webClient.DownloadString("http://nominatim.openstreetmap.org/search?city=%22new%20york%22&format=json");
//load into memorystream
using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(jsonString)))
{
//parse
var ser = new DataContractJsonSerializer(typeof(PlaceInfo[]));
PlaceInfo[] obj = (PlaceInfo[])ser.ReadObject(ms);
}
該數組obj現在已在所有的地方找到那個名字。例如jsut首先找到obj [0] .lon和obj [0] .lat
也許你可以使用開放街道地圖:
http://nominatim.openstreetmap.org/search?city=%22new%20york%22&format=json
http://nominatim.openstreetmap.org/search?city= 「---城市名---」 & countrycodes = 「--- COUNTRYCODE ---」 &限制= 2 & format = json
http://wiki.openstreetmap.org/wiki/Nominatim
就可以得到結果作爲JSON或XML
對WP7很新穎如何從c#調用這個url# – sunny
WebClient webClient = new WebClient();
string xml = webClient.DownloadString("http://nominatim.openstreetmap.org/search?city=%22new%20york%22&format=xml");
你有沒有使用過這個函數來獲取緯度和lang度? ? – sunny
- 1. 如何找到任何地方的緯度經度和時區?
- 2. 找到許多地方的經度和緯度一次
- 3. 如何找到經度和緯度
- 4. 如何從asp.net中的地址找到經度和緯度
- 5. 如何查找多個地址的經度和緯度
- 6. 如何從地址中找到緯度和經度?
- 7. 如何查找緯度和經度
- 8. 如何在Google地圖中找到緯度和經度爲一點的地址?
- 9. 查找經度和緯度
- 10. 如何經緯度ArryList複製到另一個經緯度ArryList
- 11. 無法找到一個地址的緯度/經度
- 12. 地圖經度和緯度
- 13. 緯度和經度地址
- 14. 如何找到緯度/經度/緯度點之間的距離?
- 15. C#LINQ SqlGeography - 找到緯度和經度
- 16. 地名到緯度和經度
- 17. 如何從iOS中的經度和緯度查找地址?
- 18. 通過緯度和經度查找最近的地方
- 19. 如何從WP7上的GPS獲取經度和緯度?
- 20. 查找多個地址的經緯度
- 21. 如何將兩個緯度和經度
- 22. 如何使用jVector地圖插件查找緯度和經度
- 23. 如何使用緯度和經度在iPhone中查找地址?
- 24. 如何從地址找到緯度經度?
- 25. 地球緯度和經度在3D球體上的緯度和經度
- 26. 如何找到經度和緯度位置的平均值?
- 27. 如何根據用戶輸入的經度和緯度找到一個位置?
- 28. 獲取地址的緯度和經度
- 29. 如何在mongodb中查找附近有經度和緯度的地方?
- 30. 地理編碼谷歌地圖的經度和緯度查找
感謝您的回答:) – sunny