我正在尝试使用Google地方信息库来获取附近的搜索请求:https: //developers.google.com/maps/documentation/javascript/places#place_search_requests
我只想拉出json响应并将其放入html列表中,我现在想在地图上显示结果或其他内容.我根本不想使用地图.但在文档中它声明必须有一张地图
service = new google.maps.places.PlacesService(**map**);
Run Code Online (Sandbox Code Playgroud)
为了将它作为PlacesService函数中的参数传递.我现在做的是添加一个高度为0的地图但它仍然消耗了大量的内存(我开发了一个sencha touch 2应用程序,内存很重要).有没有地图使用附近的搜索请求的解决方法?我不想使用Google Places API,因为它不支持JSONP请求.
我正在使用它google.maps.places.AutocompleteService来获取场所搜索的建议,但我无法对一些预测进行地理编码.
这方面的一个例子:当我搜索" 风暴河口 "时,我得到的预测之一是" 南非风暴河口休息营 ",但这个地址无法进行地理编码以获得格子/经度,例如:http ://maps.googleapis.com/maps/api/geocode/json地址=风暴%20River%20Mouth%20Rest%20Camp,%20South%20Africa&传感器=真
有没有办法获得自动完成预测的纬度/经度值?
或者,我不明白为什么谷歌自动完成正在返回我无法进行地理编码的预测.
这是我正在使用的逻辑和代码的基本示例:
var geocoder = new google.maps.Geocoder();
var service = new google.maps.places.AutocompleteService(null, {
types: ['geocode']
});
service.getQueryPredictions({ input: query }, function(predictions, status) {
// Show the predictions in the UI
showInAutoComplete(predictions);
};
// When the user selects an address from the autcomplete list
function onSelectAddress(address) {
geocoder.geocode({ address: address }, function(results, status) {
if (status !== google.maps.GeocoderStatus.OK) {
// This shouldn't never happen, but it does
window.alert('Location was not …Run Code Online (Sandbox Code Playgroud)