Windows phone 7 如何从街道名称、地名或城市名称获取GPS坐标
是否可以从街道名称、地名或城市名称中获取GPS坐标?我的问题是我知道我现在的GPS在Lat/Lon,但我不知道我想去的街道名称的GPS Lat/Lon。如何使用Bing地图服务进行此操作?非常感谢您的帮助。添加:-Windows phone 7 如何从街道名称、地名或城市名称获取GPS坐标,windows-phone-7,Windows Phone 7,是否可以从街道名称、地名或城市名称中获取GPS坐标?我的问题是我知道我现在的GPS在Lat/Lon,但我不知道我想去的街道名称的GPS Lat/Lon。如何使用Bing地图服务进行此操作?非常感谢您的帮助。添加:- public void获得结果() { 尝试 { if(位置==null) 返回; ReverseGeocodeRequest ReverseGeocodeRequest=新的ReverseGeocodeRequest(); //使用有效的Bing映射密钥设置凭据 reverseGe
public void获得结果()
{
尝试
{
if(位置==null)
返回;
ReverseGeocodeRequest ReverseGeocodeRequest=新的ReverseGeocodeRequest();
//使用有效的Bing映射密钥设置凭据
reverseGeocodeRequest.Credentials=新的GeocodeService.Credentials();
reverseGeocodeRequest.Credentials.ApplicationId=“您的Bing地图密钥”
//设置用于查找匹配地址的点
GeocodeService.Location point1=新的GeocodeService.Location();
点1.纬度=位置.纬度;
点1.经度=位置.经度;
reverseGeocodeRequest.Location=point1;
//发出反向地理编码请求
GeocodeServiceClient geocodeService=新的GeocodeServiceClient(“BasicHttpBinding_IgeocDeservice”);
geocodeService.reversegecodecompleted+=新事件处理程序(geocodeService\u reversegecodecompleted);
geocodeService.ReverseGeocodeAsync(reverseGeocodeRequest);
}
捕获(例外情况除外)
{
MessageBox.Show(例如Message);
}
}
void geocodeService_reversegecodecompleted(对象发送方,reversegecodecompletedventargs e)
{
尝试
{
//结果是一个GeocodeResponse对象
GeocodeResponse GeocodeResponse=e.结果;
if(geocodeResponse.Results!=null)
{
var yourresult=geocodeResponse.Results;
}
}
捕获(例外情况除外)
{
MessageBox.Show(例如Message);
}
}
如果您有问题,请告诉我:)
干杯:)添加:-
public void获得结果()
{
尝试
{
if(位置==null)
返回;
ReverseGeocodeRequest ReverseGeocodeRequest=新的ReverseGeocodeRequest();
//使用有效的Bing映射密钥设置凭据
reverseGeocodeRequest.Credentials=新的GeocodeService.Credentials();
reverseGeocodeRequest.Credentials.ApplicationId=“您的Bing地图密钥”
//设置用于查找匹配地址的点
GeocodeService.Location point1=新的GeocodeService.Location();
点1.纬度=位置.纬度;
点1.经度=位置.经度;
reverseGeocodeRequest.Location=point1;
//发出反向地理编码请求
GeocodeServiceClient geocodeService=新的GeocodeServiceClient(“BasicHttpBinding_IgeocDeservice”);
geocodeService.reversegecodecompleted+=新事件处理程序(geocodeService\u reversegecodecompleted);
geocodeService.ReverseGeocodeAsync(reverseGeocodeRequest);
}
捕获(例外情况除外)
{
MessageBox.Show(例如Message);
}
}
void geocodeService_reversegecodecompleted(对象发送方,reversegecodecompletedventargs e)
{
尝试
{
//结果是一个GeocodeResponse对象
GeocodeResponse GeocodeResponse=e.结果;
if(geocodeResponse.Results!=null)
{
var yourresult=geocodeResponse.Results;
}
}
捕获(例外情况除外)
{
MessageBox.Show(例如Message);
}
}
如果您有问题,请告诉我:)
干杯:)这里有一个使用Yahoo API的示例:
可能看起来像您可以使用的东西。这里有一个使用Yahoo API的示例:
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]));
}
}
}
可能看起来像您可以使用的东西。使用系统;
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]));
}
}
}
使用System.Collections.Generic;
使用系统文本;
使用System.Web;
Net系统;
使用System.Web.UI;
名称空间谷歌地理编码器
{
公共接口空间坐标
{
十进制纬度{get;set;}
十进制经度{get;set;}
}
///
///坐标结构。保持纬度和经度。
///
公共结构坐标:ISpatialCoordinate
{
私有十进制纬度;
私有十进制经度;
公共坐标(十进制纬度、十进制经度)
{
_纬度=纬度;
_经度=经度;
}
#区域空间坐标成员
公共十进制纬度
{
得到
{
返回纬度;
}
设置
{
这个._纬度=数值;
}
}
公共十进制经度
{
得到
{
返回经度;
}
设置
{
这是经度=数值;
}
}
#端区
}
公共类地理编码
{
私有常量字符串_googleUri=”http://maps.google.com/maps/geo?q=";
private const string\u googleKey=“yourkey”//从以下位置获取密钥:http://www.google.com/apis/maps/signup.html
私有常量字符串_outputType=“csv”//可用选项:csv、xml、kml、json
私有静态Uri GetGeocodeUri(字符串地址)
{
地址=HttpUtility.UrlEncode(地址);
返回新的Uri(String.Format(“{0}{1}&output={2}&key={3}”,_googleUri,address,_outputType,_googleKey));
}
///
///从地址获取坐标。
///
///地址。
///
///1600圆形剧场公园道山景,加利福尼亚州94043
///
///
///包含