【发布时间】:2013-12-28 09:23:13
【问题描述】:
我正在使用 JQM 和 PhoneGap 开发一个应用程序。
首页: - 用户可以通过输入地址来搜索街道或城市。输入字段应具有自动完成功能。 - 此外,搜索框下方应显示旧搜索(已使用的地址)
用户输入地址后,应该会打开第二个页面
第二页: - 此页面显示输入地址的谷歌地图。
我该怎么做?
我找到了这个帖子: PhoneGap + JQuery Mobile + Google Maps v3: map shows Top Left tiles? 我认为这可能是我的第二页: http://jsfiddle.net/Gajotres/GHZc8/
编辑:StackOverflow 说我应该通过代码伴随 jsfiddle.net。这是JS部分:
$(document).on('pageshow', '#map', function (event) {
max_height();
navigator.geolocation.getCurrentPosition(onSuccess, onError,{'enableHighAccuracy':true,'timeout':20000});
});
function max_height() {
var header = $.mobile.activePage.find("div[data-role='header']:visible");
var footer = $.mobile.activePage.find("div[data-role='footer']:visible");
var content = $.mobile.activePage.find("div[data-role='content']:visible:visible");
var viewport_height = $(window).height();
var content_height = viewport_height - header.outerHeight() - footer.outerHeight();
if((content.outerHeight() - header.outerHeight() - footer.outerHeight()) <= viewport_height) {
content_height -= (content.outerHeight() - content.height());
}
$.mobile.activePage.find('[data-role="content"]').height(content_height);
}
function onSuccess(position) {
var minZoomLevel = 15;
var map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: minZoomLevel,
center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
}
function onError() {
alert('Error');
}
但是,第一个带有自动填充功能的搜索页怎么可能呢?
在这个页面:http://jquery-ui-map.googlecode.com/svn../trunk/demos/jquery-google-maps-mobile.html Google Maps v3 有一些示例。但现在问题来了。我找不到使用自动完成功能进行正常搜索的解决方案。只有一个带有自动完成功能的地方搜索示例。那不可能吗?
【问题讨论】:
标签: javascript jquery google-maps jquery-mobile cordova