I am designing a website which converts and stores longitude and latitude of the entered address.iused google geocoding api for this purpose and the code I used to convert address to longitude and latitude is

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Geocoding.Google;
using Geocoding;
public partial class test3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        IGeocoder geocoder = new GoogleGeocoder() {  };
        Address[] addresses = geocoder.Geocode(TextBox1.Text).ToArray();
        foreach (Address adrs in addresses)
        {
            Response.Write("address:"+adrs);
        }
    }
}

And for the input Delhi,India instead of getting the longitude and latitude values i am getting more specific address again

address:New Delhi, Delhi, India

please somebody who used google api before help me to modify my code.

有帮助吗?

解决方案

You can use Coordinates

Replace This:

Response.Write("address:"+adrs);

With This:

Response.Write("address:"+adrs.Coordinates);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top