Google map 地址解析 经度和纬度

chen365 2009-03-20 06:11:03
http://maps.google.com/maps/geo?q=北京朝阳区三里屯南路16号&output=csv&key=ABQIAAAApY6NQ62m5-TOY2lymdexQhTwkH9FLDCesjX1Zfj2T97eMNfzlRQyBVSw9MBQFWR4fsVtAj3nn47rHg


怎么批量获取经度和纬度.
我做了一个例子但不能实现;返回的结果都是602,0,0,0
但是单个在IE 里打开却能返回正确结果,
好像是编码问题,没有能解决,大家帮我看看..
代码如下



<%
dim Conn
dim Connstr
Connstr="driver={SQL Server};server=(local);uid=sa;pwd=sa;database=btd_2008"
set Conn=server.createobject("ADODB.ConnECTION")
Conn.Open Connstr

%>
<html>
<head>
<title>map point</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
dim rs,sql
Set rs=Server.CreateObject("ADODB.recordset")
dim rs2,sql2
Set rs2=Server.CreateObject("ADODB.recordset")

sql="select top 10 * from [chi] order by id desc"
rs.open sql,conn,1,1
do while not rs.eof
response.Write(rs("address"))
response.write("<br>")
Dim objXMLHTTP, xml ,url
url="http://maps.google.com/maps/geo?q="&rs("address")&"&output=csv&key=ABQIAAAApY6NQ62m5-TOY2lymdexQhRKJnXFZRSHqLJY8hfZWLGqzePaiBS094BmETWGgTSe1PWjqT-9nq5IWw"
response.write url
response.write "<br>"
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "get", url, False
xml.Send
Point=xml.responseText

response.Write(Point)

Set xml = Nothing

rs.movenext
loop
rs.close
set rs =nothing
set rs2 =nothing
set conn=nothing
%>

</body>
</html>





...全文
504 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yxljch11 2010-07-01
  • 打赏
  • 举报
回复
mark
davy1979 2010-06-11
  • 打赏
  • 举报
回复
我也正遇到这样问题,是否是IP限制?
chen365 2009-03-23
  • 打赏
  • 举报
回复

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
dim Conn
dim Connstr
Connstr="driver={SQL Server};server=(local);uid=sa;pwd=sa;database=btd_2008"
set Conn=server.createobject("ADODB.ConnECTION")
Conn.Open Connstr

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" lang="zh">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>map point</title>
</head>
<body >
<%
Function GetGeoinfo(address)
dim Url
Url="http://maps.google.com/maps/geo?q="+address+"&output=csv"
dim httpRequest
set httpRequest=Server.createobject("Microsoft.XMLHTTP")
httpRequest.open "GET",Url,false
httpRequest.send()
if httpRequest.readystate <>4 then
exit function
end If
dim pointxy,pointx,pointy
pointxy=httpRequest.responseText
pointxy=split(pointxy,",")
pointx=pointxy(2)
pointy=pointxy(3)
GetGeoinfo=pointx&"|"&pointy
set httpRequest=nothing
End Function

dim address
dim rs,sql
Set rs=Server.CreateObject("ADODB.recordset")
Dim objXMLHTTP, xml ,url
sql="select top 10 * from [point] order by id desc"
rs.open sql,conn,1,1
do while not rs.eof
address=rs("address")
response.write address
response.write "<br>"

response.write(GetGeoinfo(address))
response.write "<br>"


rs.movenext
loop
rs.close
set rs =nothing
set conn=nothing

%>
</body>
</html>

chen365 2009-03-23
  • 打赏
  • 举报
回复
为什么从数据库里读取出来的数据英文的出来的是正确的,中文的却是错误的?
chen365 2009-03-23
  • 打赏
  • 举报
回复
Shelly 我没有看懂你的代码.能用 asp vbscript 来写一个例子吗?
zb1999 2009-03-22
  • 打赏
  • 举报
回复
mrshelly 2009-03-20
  • 打赏
  • 举报
回复
>>> import urllib2
>>> url = 'http://maps.google.com/maps/geo?q=北京朝阳区三里屯南路16号&output=csv
&key=ABQIAAAApY6NQ62m5-TOY2lymdexQhTwkH9FLDCesjX1Zfj2T97eMNfzlRQyBVSw9MBQFWR4fsV
tAj3nn47rHg'
>>> req = urllib2.Request(url)
>>> fp = urllib2.build_opener()
>>> req.add_header('Accept', 'image/gif, image/x-xbitmap, image/jpeg, image/pjpe
g, application/x-shockwave-flash, application/msword, application/QVOD, */*')
>>> req.add_header('User-Agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; .NET CLR 2.0.50727)')
>>> req.add_header('Accept-Language', 'zh-cn')
>>> req.add_header('Connection', 'Keep-Alive')
>>> ns = fp.open(req)
>>> print ns.headers
Content-Type: text/plain; charset=UTF-8
Set-Cookie: PREF=ID=73504d15be806e14:NW=1:TM=1237557088:LM=1237557088:S=c5KWKhBq
zgOYyRak; expires=Sun, 20-Mar-2011 13:51:28 GMT; path=/; domain=.google.com
Date: Fri, 20 Mar 2009 13:51:28 GMT
Server: mfe
Cache-Control: private, x-gzip-ok=""
Transfer-Encoding: chunked
Expires: Fri, 20 Mar 2009 13:51:28 GMT
Connection: Close

>>> b = ns.read()
>>> b
'200,8,39.9277238,116.4560330'

没有问题呀. 特别要注意 加入 User-Agent 的 Header


  • 打赏
  • 举报
回复
呵呵,不是这么用的吧
街头小贩 2009-03-20
  • 打赏
  • 举报
回复

是不请求过于频繁

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧