我試圖地址轉換爲經度和使用地理編碼APIC#轉換地址,經度和緯度
protected void Button1_Click(object sender, EventArgs e)
{
IGeocoder geocoder = new GoogleGeocoder() { };
Address[] addresses = geocoder.Geocode("#65/1 bangalore").ToArray();
foreach (Address adrs in addresses)
{
Response.Write("address:"+adrs);
}
}
緯度使用此代碼我得到的答案是更詳細的地址沒有經度和緯度。對於這個代碼的例子,我得到了
address:Hari Om Trust Tapovana, 1, Bangalore, Karnataka 562123, India
有人請告訴我什麼修改我必須這樣做,我可以得到經度和緯度?
爲googlegeocoder代碼
#region Assembly Geocoding.dll, v3.1.0.0
// C:\Users\Admin\Documents\Visual Studio 2012\WebSites\learn1\Bin\Geocoding.dll
#endregion
using Geocoding;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
namespace Geocoding.Google
{
public class GoogleGeocoder : IGeocoder, IAsyncGeocoder
{
public GoogleGeocoder();
public string ApiKey { get; set; }
public Bounds BoundsBias { get; set; }
public BusinessKey BusinessKey { get; set; }
public string Language { get; set; }
public WebProxy Proxy { get; set; }
public string RegionBias { get; set; }
public string ServiceUrl { get; }
public IEnumerable<GoogleAddress> Geocode(string address);
public Task<IEnumerable<GoogleAddress>> GeocodeAsync(string address);
public Task<IEnumerable<GoogleAddress>> GeocodeAsync(string address, CancellationToken cancellationToken);
public IEnumerable<GoogleAddress> ReverseGeocode(Location location);
public IEnumerable<GoogleAddress> ReverseGeocode(double latitude, double longitude);
public Task<IEnumerable<GoogleAddress>> ReverseGeocodeAsync(double latitude, double longitude);
public Task<IEnumerable<GoogleAddress>> ReverseGeocodeAsync(double latitude, double longitude, CancellationToken cancellationToken);
protected class RequestState
{
public readonly CancellationToken? cancellationToken;
public readonly HttpWebRequest request;
public RequestState(HttpWebRequest request, CancellationToken? cancellationToken);
}
}
}
請張貼GoogleGeocoder類的代碼。 – Christos
「#65/1班加羅爾」,這應該是一個實際的地址? –
我在哪裏發佈? – user2775241