有什么办法来实现这个在我的网站? (其中API服务,我应该使用?) [英] Is there any way to implement this on my website? (Which API service should I use?)

查看:116
本文介绍了有什么办法来实现这个在我的网站? (其中API服务,我应该使用?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我怎么想它的工作:

This is how I want it to work:


  • 有2个文本框。他们每个人都有自动完成。用户选择使用哪一个。

  • 在1文本框,自动完成的地址,像谷歌地图。

  • 在第二个文本框,自动完成的场馆名称。 (如咖啡​​厅米兰)

  • 当用户提交表单,我需要得到LAT / LONG无论是地址或会场。如果我得到纬度/长通过JSONP或在我的后端打谷歌的REST API我不在乎......我只想纬度/长

  • 这必须处理负载的人。它不应该超时由于太多的API请求。

  • There are 2 text boxes. Each one of them has "autocomplete". The user chooses which one to use.
  • On the 1st text box, the autocomplete is addresses, like Google Maps.
  • On the 2nd text box, the autocomplete is venue names. (eg. Cafe Milano)
  • When the user Submits the form, I need to get the LAT/LONG of either the address or the venue. I don't care if I get the lat/long via JSONP or in my backend hitting Google's REST API...I just want the lat/long
  • This must handle loads of people. It should not "time out" due to too many API requests.

什么是最好的服务/ API,可以给我吗?可以谷歌地方/谷歌地图API的支持呢?

What is the best service/API that can give me this? Can Google Places/Google Maps API support this?

推荐答案

要回答你的<一个href=\"http://stackoverflow.com/questions/4296091/is-there-a-way-to-use-google-maps-to-autocomplete-a-users-location/4296295#4296295\">$p$pvious questio ñ我最好设置一个演示这表明城市的建议,可通过游离碱插件来实现jQuery的。如果要添加第二个文本框说 ID ='地方'显示场地,那么你需要添加以下code实现的建议。

To answer your previous question I'd setup a demo which showed city suggestions could be implemented via the freebase plugin for jQuery. If you are adding a second text box say id='place' for displaying venues, then you need to add following code to implement suggestions.

<script type="text/javascript">
$(document).ready(function(){
mylocation=$("#address").val();
$("#address").change(function(){
    mylocation=this.val();
});

$(function() {
  $("#address").suggest({type:'/location/citytown'});
});

  $("#place").suggest({
    "type":'/dining/restaurant',
     "name":null,
     "/location/location/near":{
            "location":mylocation,
            "unit":"miles",
            "distance":null
       },
    "limit":50,
    "sort":"/location/location/near.distance"
    });
});
</script>

下面的城市,从它作为在第二个框的建议搜索参数的第一个文本框获得。

Here the city is obtained from the first text box which serves as the search parameter for the suggestions in the second box.

既然你打算实行这个制度了大量用户,并实时显示的,最好用的,而不是正常的 =HTTP://$c$c.google.com/apis/maps/documentation/geocoding /#限制相对=nofollow>谷歌地理codeR API 其中谷歌节流至2500请求的一天。

Since you are planning to implement this system for a large number of users and real time display, it's best to use Google Maps V3 API as opposed to the normal Google Geocoder API which Google throttles to 2500 requests a day.

编辑:虽然更适合于实时地址解析请求,谷歌地图API V3施加相同的2500个要求每天的限制。你需要去为一个 premier帐户如果您需要支持超过了V3 API施加的限制要求。

Albeit more suited for real time Geocoding Requests, the Google Maps V3 API imposes the same 2500 requests a day restriction. You'll need to go in for a premier account if you need to support requests in excess of the restrictions imposed by the V3 API.

这篇关于有什么办法来实现这个在我的网站? (其中API服务,我应该使用?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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