可以从街道名称,地名或城市名称获取GPS坐标吗?我的问题是我知道我目前的纬度/经度GPS,但我不知道我想去的街道名称的GPS纬度/经度。我该如何使用Bing Map服务?非常感谢您的帮助。如何从街道名称,地名或城市名称获取GPS坐标
1
A
回答
1
地址: - http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc
public void Obtainresult()
{
try
{
if (location == null)
return;
ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();
// Set the credentials using a valid Bing Maps key
reverseGeocodeRequest.Credentials = new GeocodeService.Credentials();
reverseGeocodeRequest.Credentials.ApplicationId = "Your Bing Map Key"
// Set the point to use to find a matching address
GeocodeService.Location point1 = new GeocodeService.Location();
point1.Latitude = location.Latitude;
point1.Longitude = location.Longitude;
reverseGeocodeRequest.Location = point1;
// Make the reverse geocode request
GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
geocodeService.ReverseGeocodeCompleted += new EventHandler<ReverseGeocodeCompletedEventArgs>(geocodeService_ReverseGeocodeCompleted);
geocodeService.ReverseGeocodeAsync(reverseGeocodeRequest);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void geocodeService_ReverseGeocodeCompleted(object sender, ReverseGeocodeCompletedEventArgs e)
{
try
{
// The result is a GeocodeResponse object
GeocodeResponse geocodeResponse = e.Result;
if (geocodeResponse.Results != null)
{
var yourresult = geocodeResponse.Results;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
让我知道如果你有问题:)
欢呼:)
0
有使用雅虎API这里的样本:http://www.devfish.net/fullblogitemview.aspx?blogid=826
莫非看起来像你可以使用的东西。
+0
。我需要GeoCode地址到GPS Lat/Lon。例如,给定像纽约这样的地名,美国。我需要知道它的Gps纬度/经度。谢谢 – MilkBottle
0
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Net;
using System.Web.UI;
namespace GoogleGeocoder
{
public interface ISpatialCoordinate
{
decimal Latitude {get; set; }
decimal Longitude {get; set; }
}
/// <summary>
/// Coordiate structure. Holds Latitude and Longitude.
/// </summary>
public struct Coordinate : ISpatialCoordinate
{
private decimal _latitude;
private decimal _longitude;
public Coordinate(decimal latitude, decimal longitude)
{
_latitude = latitude;
_longitude = longitude;
}
#region ISpatialCoordinate Members
public decimal Latitude
{
get
{
return _latitude;
}
set
{
this._latitude = value;
}
}
public decimal Longitude
{
get
{
return _longitude;
}
set
{
this._longitude = value;
}
}
#endregion
}
public class Geocode
{
private const string _googleUri = "http://maps.google.com/maps/geo?q=";
private const string _googleKey = "yourkey"; // Get your key from: http://www.google.com/apis/maps/signup.html
private const string _outputType = "csv"; // Available options: csv, xml, kml, json
private static Uri GetGeocodeUri(string address)
{
address = HttpUtility.UrlEncode(address);
return new Uri(String.Format("{0}{1}&output={2}&key={3}", _googleUri, address, _outputType, _googleKey));
}
/// <summary>
/// Gets a Coordinate from a address.
/// </summary>
/// <param name="address">An address.
/// <remarks>
/// <example>1600 Amphitheatre Parkway Mountain View, CA 94043</example>
/// </remarks>
/// </param>
/// <returns>A spatial coordinate that contains the latitude and longitude of the address.</returns>
public static Coordinate GetCoordinates(string address)
{
WebClient client = new WebClient();
Uri uri = GetGeocodeUri(address);
/* The first number is the status code,
* the second is the accuracy,
* the third is the latitude,
* the fourth one is the longitude.
*/
string[] geocodeInfo = client.DownloadString(uri).Split(',');
return new Coordinate(Convert.ToDecimal(geocodeInfo[2]), Convert.ToDecimal(geocodeInfo[3]));
}
}
}
+0
你会在哪里找到状态码值? – Rodney
相关问题
- 1. 从GPS坐标获取城市名称
- 2. 到街道名称的地理坐标
- 3. 将GPS坐标转换为Swift中的城市名称/地址
- 4. 如何执行谷歌地图搜索街道名称,城市?
- 5. 如何获得街道名称,城市,州和JavaScript中
- 6. 根据城市名称获取坐标谷歌地图
- 7. Andorid如何使用坐标获取当前城市的名称
- 8. 如何隐藏Bing地图中的标签(街道,道路,城市)名称和城市地图V8
- 9. 从城市名称获取经纬度
- 10. 从城市名称获取WOEID?
- 11. 从经纬度获取城市名称
- 12. 从CLLocationManager获取城市名称?
- 13. OSM - 提取街道名称,经纬度和城市
- 14. 获取基于城市,邮编或街道名称的经度和纬度
- 15. 如何获得坐标为IN JAVA的城市名称?
- 16. Swift通过名称获取城市坐标
- 17. 来自gps的城市名称
- 18. 获取城市名称和国家来电号码的名称?
- 19. 如何使用PHP从Google Geocoding API获取街道名称,电话号码,城市,州名?
- 20. 在MapKit中搜索街道名称,城市......的最佳方式?
- 21. Google Places JS API,特定城市的街道名称
- 22. 在Android和Ios中,如何使用或不使用GPS获取城市名称?
- 23. 需要解决方案获取城市名称w/o gps?
- 24. 城市名称到地理坐标PHP脚本?
- 25. 如何在iphone中获取地理位置城市名称?
- 26. 如何根据java中的IP地址获取城市名称?
- 27. 从Google地图中的街道地址获取区域名称
- 28. 如何获得时区名称的本地化城市和国家名称
- 29. 如何使用城市名称和国家/地区名称获得Microsoft Timzone?
- 30. 如何从任何城市或地名
谢谢。需要你的帮助。我如何通过街道名称,例如纽约,美国,并获得我需要做距离计算的数字格式的GPS结果?谢谢。如果您可以帮助使用BingMap,请致电 – MilkBottle