从谷歌地图v3中的地址查找纬度和经度 [英] find latitude and longitude from address in google map v3

查看:81
本文介绍了从谷歌地图v3中的地址查找纬度和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查找从数据库显示在datalist上的位置的纬度和经度。

点击datalist的linkbutton我正在获取位置,我想使用谷歌地图v3 API找到该位置的纬度和经度。我也有API。不希望javascrpt代码是否有其他方式?我正在尝试愚弄代码,但它失败了..

i want to find latitude and longitude of location which is displaying on datalist from database.
on click of linkbutton of datalist i am getting location and i want to find latitude and longitude of that location using google map v3 API. I have API also. dont want javascrpt code is any other way? i am trying foolowing code but it fails..

Label lblcountryHOout = (Label)DsListHOoutlet.Items[e.Item.ItemIndex].FindControl("LblCountryHOoutlet");
            string countryHOout = lblcountryHOout.Text;
            Label lblcityHOout = (Label)DsListHOoutlet.Items[e.Item.ItemIndex].FindControl("LblCityHOoutlet");
            string cityHOout = lblcityHOout.Text;
            Label lbladdressHOout = (Label)DsListHOoutlet.Items[e.Item.ItemIndex].FindControl("LblAddressHOoutlet");
            string addressHOout = lbladdressHOout.Text;

            string location = countryHOout + "," + cityHOout;

            string appId = "API Key";
            string url = string.Format("https://maps.googleapis.com/maps/api/xml?q={0}&key=key &sensor=TRUE OR FALSE", Server.UrlEncode(location), appId,false);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            try
           {
             WebResponse response = request.GetResponse();                
                XDocument xdoc = XDocument.Load(url);

                // Verify the GeocodeResponse status
                //string status = xdoc.Element("GeocodeResponse").Element("status").Value;
                //ValidateGeocodeResponseStatus(status, address);              

                XElement locationElement = xdoc.Element("GeocodeResponse").Element("result").Element("geometry").Element("location");
                latitude1 = (double)locationElement.Element("lat");
                longitude1 = (double)locationElement.Element("lng");


           }
           catch (System.Net.WebException exp)
          {

          }







XML文件未在URLhttp://maps.googleapis.com/maps/api/geocode/xml [ ^ ]



it正在退休,并且givivng消息如下:

此XML文件似乎没有与之关联的任何样式信息。文档树如下所示。




XML file is not retriving correct at the URL "http://maps.googleapis.com/maps/api/geocode/xml[^]"

it is retiving like and givivng messageas follows
This XML file does not appear to have any style information associated with it. The document tree is shown below.

<GeocodeResponse>
<status>REQUEST_DENIED</status>
</GeocodeResponse>





xml应该回溯纬度和经度该怎么办? plz help ..



the xml should retrive latitude and longitude what to do? plz help..

推荐答案

参见:

提取纬度和经度对的一 - 拖动针-通谷歌-MAPS-API-V3 [ ^ ]



祝你好运,

Edo
See:
Retrieve-latitude-and-longitude-of-a-draggable-pin-via-google-maps-api-v3[^]

Good luck,
Edo


你必须在客户端使用Javascript才能获得lat和long使用Google Maps API V3.0



据我所知, api调用使用ajax或其他东西来获取数据,



对象在下面,lat和long在几何位置



You have to use Javascript on the client side to get the lat and long using the Google Maps API V3.0

As far as I know, the api call uses ajax or something to fetch the data,

the object is below, and the lat and long is in the geometry location

 var vA =


('[id * =_ txt_JQuery_Google_Address_Destination]')。val();
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address':vA},function(results,status){
if(status!= google.maps.GeocoderStatus.OK){
//检查错误并进行必要的更正
alert(由于以下原因,初始地理编码请求未成功:+状态);
}
else {
//结果在arrray中低于
结果[0] .geometry.location
}
});
('[id*="_txt_JQuery_Google_Address_Destination"]').val(); var geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'address': vA }, function (results, status) { if (status != google.maps.GeocoderStatus.OK) { // Examine the error and make the needed corrections alert("Initial geocode request was not successful for the following reason: " + status); } else { // results are in the arrray below results[0].geometry.location } });









你可能需要寻找另一个地理编码来源,一个只支持定期调用网络服务,使用asp.net。



您必须对谷歌地图对象进行逆向工程,才能获取参数。



如果您只需要一个地理编码集,然后你调用页面加载中的地理编码和操作隐藏文本框,然后使用asp.net获取值。







现在考虑一下,你可以使用.on clientClick =fetch_GeoCode(address);返回false;



并运行Google Maps API以获取地理编码,并填充隐藏的文本框,您不必在技术上绘制地图。



似乎有很多东西可供它使用,它将是location.lat和location.long



https://www.google.com/search?q=acess+google+geocode+from+asp.net&ie=utf -8& oe = utf-8& aq = t& rls = org.mozilla:en-US:official& client = firefox -a [ ^ ]


这篇关于从谷歌地图v3中的地址查找纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆