将地址转换为经纬度 [英] Converting address to lat and lng

查看:155
本文介绍了将地址转换为经纬度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试将地址转换为lat和lng.
这是我所使用的,但出现此错误

Hi,

I am trying to converting an address to lat and lng.
This is what I used but I''m getting this error

public void GetCoOrdinates()
        {
            string serviceUri = string.Format("http://rpc.geocoder.us/service/rest?address={0},{1},{2}", street, city, state);
            XmlDocument serviceXmlDoc = new XmlDocument();
            serviceXmlDoc.Load(serviceUri);
            XmlNamespaceManager geoCoderManager = new XmlNamespaceManager(serviceXmlDoc.NameTable);
            geoCoderManager.AddNamespace("geoCoderService", @"http://www.w3.org/2003/01/geo/wgs84_pos#");
            string longitude = serviceXmlDoc.DocumentElement.SelectSingleNode(@"//geoCoderService:long", geoCoderManager).InnerText;
            string latitude = serviceXmlDoc.DocumentElement.SelectSingleNode(@"//geoCoderService:lat", geoCoderManager).InnerText;
            MessageBox.Show(String.Format("Latitude: {0} Latitude: {1}", latitude, longitude));
        }


错误:根级别的数据无效.第1行,位置1


ERROR: Data at the root level is invalid. Line 1, position 1

推荐答案

您将不得不就此与GeoCoder联系.我们不知道他们的服务需要什么.

另外,您确实知道您永远不会为任何给定IP获得完全准确的位置,对吗?您可能会得到超过100英里的结果.
You''re goingo to have to contact GeoCoder on this one. We have no idea what their service requires.

Also, you do know that you''re never going to get a completely accurate location for any given IP, correct?? You could get a result that''s off by upwards of 100 miles.


这篇关于将地址转换为经纬度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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