我正在为我正在构建的应用程序编写地理编码组件,我决定使用Yahoo Maps.我编写了地理编码API包装器和一些单元测试,并称它为一天.第二天回来,跑了测试,发现经纬度发生了变化.请注意,这个变化很小,对我来说不重要,但它足以影响我在单元测试中用于比较结果的4位小数的四舍五入.
我以前从未听说过改变纬度和经度.这是我应该期待/占的吗?有谁能解释为什么?
我写了一个脚本来对某些点进行地理编码,这些点的结构基本上是这样的:
//get an unupdated record
$arr_record;
while(count($arr_record) > 0)
{
//strings are derived from $arr_record
geocode($string1);
geocode($string2);
geocode($string3);
array_pop($arr_record);
}
function geocode($string) {
//if successful
update($coords)
}
function update($coords) {
//update the database
header('Location:http://localhost/thisfile.php')
}
Run Code Online (Sandbox Code Playgroud)
麻烦的是,即使地理编码成功并且数据库已更新,并且标题重新发送,脚本仍会返回到while循环而不重新加载页面并重新开始新记录.
这是PHP的正常行为吗?我该如何避免它像这样?
我需要查找邮政编码以获取地址列表(包括城市/州).是否有可供下载的主邮政编码列表(免费)或是否有任何网络服务将返回地址的完整邮资信息.
即查询查询: 386 Bread&Cheese Hollow Rd,Northport,NY ====> 386 Bread And Cheese Hollow Rd,Northport,NY 11768
谢谢!
Rails有哪些邻近搜索选项?(也许各有利弊?)
(示例用法,企业可以列出的黄页类型应用程序,用户可以输入他们的邮政编码并查找靠近他们或在指定里程范围内的商家.)
更新:该应用程序与上面的示例应用程序非常相似 - 企业可以在应用程序中列出必不可少的目录(每个类型的业务都有类别),用户可以转到类别并按距离对结果进行排序(在输入他们的邮政编码后 - 所以最接近他们的企业首先被展示出来.没有按名称或其他标准搜索 - 这是一个简单的去'拳击手狗饲养员'页面并按距离排序.
postgresql geocoding ruby-on-rails proximity ruby-on-rails-3
我在我的Android应用程序中使用Geocoder将字符串解析为地址.以下代码片段通过Wifi正常工作,但不能通过3G.当超过3G时,它会抛出一个IOException: Unable to parse response from server.
在关于此的其他讨论中,一个常见的答案是可能的原因是Geocoder被使用了很多次/分钟,超过了阈值,并导致服务暂时抛出异常.我相信这不是我的情况,因为我从来没有得到过我的新手机(Nexus S,android 4.1)的服务,这是几个星期前我得到的.
这是片段:
Geocoder gc = new Geocoder(this);
List<Address> newAddresses = gc.getFromLocationName(arg0.toString(), 10);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我试图同时创建两个对象,但由于某种原因,我的第二个对象的字段是空白的.
模型是:
Users: id, name, last, email, password ...
Locations: address, longitude, latitude.
Run Code Online (Sandbox Code Playgroud)
关系如此:
User has_many location
Location belongs_to users
Run Code Online (Sandbox Code Playgroud)
事件控制器创建方法:
def create
@event = current_users.events.build(params[:event])
@location = @event.locations.build(params[:location])
@location.longitude = params[:longitude]
@location.latitude = params[:latitude]
respond_to do |format|
if @location.save
@location.longitude = params[:longitude]
@location.latitude = params[:latitude]
if @location.save
if @event.save
format.html { redirect_to @event, notice: 'Event was successfully created.' }
format.json { render json: @event, status: :created, location: @event }
else
format.html { render action: "new" }
format.json { render …Run Code Online (Sandbox Code Playgroud) 我想"http://maps.google.co.in/maps?q=canara+bank&hl=en&sll=12.953997,77.63094&sspn=1.069318,1.234589&hq=canara+bank&t=m&z=10"使用谷歌地图API实现从谷歌地图网址呈现的完全相同的结果 .
我尝试过使用geoCode API,但是有些人无法获得类似的结果.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html {
height: 100%
}
body {
height: 100%;
margin: 0;
padding: 0
}
#map_canvas {
height: 100%
}
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDjW1WmSDPUaziJY6DtwMtRLhsGrzy7YLA&sensor=false">
</script>
<script type="text/javascript">
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(populateData,showError);
}
else{alert("Geolocation is not supported by this browser.");}
}
function showError(error)
{
switch(error.code)
{
case error.PERMISSION_DENIED:
alert("User denied the request for Geolocation.");
break;
case error.POSITION_UNAVAILABLE:
alert("Location information is unavailable.");
break; …Run Code Online (Sandbox Code Playgroud) 如果我只使用一个单词,谷歌地理编码api的工作非常好
悉尼
但如果我使用:
悉尼,澳大利亚
它不起作用它说:
警告:file_get_contents(https://maps.google.com/maps/api/geocode/json?address=sydney,Australia&sensor = false):无法打开流:HTTP请求失败!HTTP/1.0 400错误请求
虽然我粘贴这个url时它在我的浏览器中有效,但是当我使用这个功能时却file_get_contents没有.
我的问题很简单,当我粘贴此结果时,为什么它在我的浏览器中有效,以及为什么它不能与下面的代码一起使用.当然,如何解决这个问题.
$a = file_get_contents("https://maps.google.com/maps/api/geocode/json?address=sydney, Australia&sensor=false");
Run Code Online (Sandbox Code Playgroud) 我一直在谷歌搜索这几个小时但到目前为止没有运气.
我想获取触摸/点击地图的位置的地址.
据我所知,为了获得地址,我需要反转地理编码坐标.但是我如何首先从地图中获取坐标?
geocoding ×10
geolocation ×3
php ×3
android ×2
google-maps ×2
ruby ×2
c# ×1
header ×1
lookup ×1
postgresql ×1
proximity ×1
while-loop ×1
zipcode ×1