Google maps 谷歌Api没有给出位置

Google maps 谷歌Api没有给出位置,google-maps,google-api,geolocation,google-location-services,Google Maps,Google Api,Geolocation,Google Location Services,我正在使用GoogleAPI获取项目中的位置。它有时给出位置,但大多数情况下不给出任何位置。从今天起,它将给服务器返回一个错误403。 当我在浏览器中点击URL时,它给出了位置。 我没有为我的API使用任何密钥,这可能会导致此问题 只想补充一点- 我从api中获取lat和long,然后从google api中获取位置并将其存储在数据库中 我正在做的是:- public static string getGoogleLocationByLogLat(string log, string lat)

我正在使用GoogleAPI获取项目中的位置。它有时给出位置,但大多数情况下不给出任何位置。从今天起,它将给服务器返回一个错误403。 当我在浏览器中点击URL时,它给出了位置。 我没有为我的API使用任何密钥,这可能会导致此问题

只想补充一点- 我从api中获取lat和long,然后从google api中获取位置并将其存储在数据库中

我正在做的是:-

public static string getGoogleLocationByLogLat(string log, string lat)
{

    try
    {
         if (log == "")
    {
        log = "0.0";
    }
    if (lat == "")
    {
        lat = "0.0";
    }

    XmlTextReader xReader;
    bool element = false;
    string location = "", time, GL, parentEmail, respDateTime;
    string parentElementName = "";
    string childElementName = "";
    string childElementValue = "", prmryCntact = "";

    string url = "http://maps.google.com/maps/api/geocode/xml?latlng=" + lat + "," + log + "&sensor=true";

    xReader = new XmlTextReader(url);

        while (xReader.Read())
        {

            if (xReader.NodeType == XmlNodeType.Element)
            {

                if (element)
                {
                    parentElementName = parentElementName + childElementName + "<br>";
                }

                element = true;

                childElementName = xReader.Name;

            }

            else if (xReader.NodeType == XmlNodeType.Text | xReader.NodeType == XmlNodeType.CDATA)
            {

                element = false;

                childElementValue = xReader.Value;

                if (childElementName == "formatted_address")
                {
                    location = childElementValue;
                    break;
                }
            }

        }

    if (location.Trim() == "")
    {
        location = "Location not found";
    }

    return location;
    }
    catch (Exception ex)
    {
        return "LOCATION NOT FOUND";
    }
}
public静态字符串getGoogleLocationByLogLat(字符串日志,字符串lat)
{
尝试
{
如果(日志==“”)
{
log=“0.0”;
}
如果(纬度==“”)
{
lat=“0.0”;
}
XmlTextReader;
布尔元素=假;
字符串位置=”,时间,总账,parentEmail,respDateTime;
字符串parentElementName=“”;
字符串childElementName=“”;
字符串childElementValue=“”,prmrycontact=“”;
字符串url=”http://maps.google.com/maps/api/geocode/xml?latlng=“+lat+”、“+log+”&传感器=真”;
xReader=新的XmlTextReader(url);
while(xReader.Read())
{
if(xReader.NodeType==XmlNodeType.Element)
{
if(元素)
{
parentElementName=parentElementName+childElementName+“
”; } 元素=真; childElementName=xReader.Name; } else if(xReader.NodeType==XmlNodeType.Text | xReader.NodeType==XmlNodeType.CDATA) { 元素=假; childElementValue=xReader.Value; if(childElementName==“格式化的地址”) { 位置=子元素值; 打破 } } } 如果(location.Trim()==“”) { location=“未找到位置”; } 返回位置; } 捕获(例外情况除外) { 返回“未找到位置”; } }
添加API密钥

&key=yourkey
随着地图api的最新政策更新,我相信这一定是您遇到的情况


也使用https。。。只允许通过https进行访问。

如前所述,您需要一个api密钥。@ThomasS.E。我读了一个api密钥尝试,但在一次点击后,它是要求计费帐户。有时,我也会在没有api密钥的情况下获取位置*(大多数情况下,我没有获取位置)。我想说的是,没有添加api密钥,有没有解决我的问题的方法。我添加了一个api密钥,点击一次后,它会说“您已经超过了此api的每日请求配额。如果您没有设置自定义每日请求配额,请验证您的项目是否有活动的计费帐户:”。我必须为使用谷歌api付费吗?谷歌已经改变了它的配额政策,你现在必须激活一个账单账户,而不是免费请求,并且你每个月可以获得200美元的积分。超过此金额时,将记入您的账单账户。你也可以看看:你需要一个活跃的账单帐户。。。您每月将获得200美元,您的请求将从此信用卡中使用。。。只有当你用尽这一点,你会得到充电检查的链接provided@ThomasS.E. 我的委托人要求提供一个适当的事实。你能给我提供谷歌文档以外的任何链接吗?它清楚地写着,没有API密钥会导致此类问题。