0
太奇怪了這個bug ......jQuery的用戶界面對話框不GMAP工作在ipad
我的網站是https://www.merchantsbar.com/index.php 如果單擊「聯繫人」頁面的底部,或者「註冊」在左邊,一個jquery ui對話框shd彈出。 它適用於我測試過的所有瀏覽器,除了ipad。對話框在動畫之後隱藏。如果你有ipad,請去測試一下。
我追捕問題&實現其谷歌地圖造成問題的原因。一旦這個函數被觸發,對話框就會丟失(請記住,迄今爲止,ipad是唯一一個給我帶來問題的,即使iphone也能工作!)。
在此先感謝!
function initialize(canvas, AC, field_Lat, field_Lng, readonly, search_area){
var Lat = Number($("#"+field_Lat).val()) == NaN ? $("#"+field_Lat).val() : 40.7399709 ;
var Lng = Number($("#"+field_Lng).val()) == NaN ? $("#"+field_Lng).val() : -73.6135758 ;
var latlng = new google.maps.LatLng(Lat, Lng); // LatLng
var options = {
zoom: 11,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById(canvas), options); // MAP
geocoder = new google.maps.Geocoder(); //GEOCODER
if (readonly==true){ marker = new google.maps.Marker({ map: map }); } // readonly
else{
if (search_area==true){ var distanceWidget = new DistanceWidget(map); } // SEARCH_AREA
else{ marker = new google.maps.Marker({ map: map, draggable: true }); } // non-search_area
autocomplete(AC, field_Lat, field_Lng);
geocodeReverse(AC, field_Lat, field_Lng);
}
marker.setPosition(latlng);
}
function autocomplete(AC, field_Lat, field_Lng){
$("#"+AC).autocomplete({
//This bit uses the geocoder to fetch address values
source: function(request, response){
geocoder.geocode({'address': request.term }, function(results, status){
response($.map(results, function(item){
return {
label: item.formatted_address,
value: item.formatted_address,
latitude: item.geometry.location.lat(),
longitude: item.geometry.location.lng()
}
}));
})
},
//This bit is executed upon selection of an address
select: function(event, ui){
$("#"+field_Lat).val(ui.item.latitude);
$("#"+field_Lng).val(ui.item.longitude);
var location = new google.maps.LatLng(ui.item.latitude, ui.item.longitude);
marker.setPosition(location);
map.setCenter(location);
}
});
}
function geocodeReverse(AC, field_Lat, field_Lng){
google.maps.event.addListener(marker, 'dragend', function(){
geocoder.geocode({'latLng' : marker.getPosition()}, function(results, status){
if (status == google.maps.GeocoderStatus.OK){
if (results[0]){
$('#'+field_Lat).val(marker.getPosition().lat());
$('#'+field_Lng).val(marker.getPosition().lng());
$('#'+AC).val(results[0].formatted_address);
$("#Se_latitude, #Se_longitude").focus(); // inter-linked to validateField();
$("#"+field_Lat+", #"+field_Lng+", #"+AC).blur();
}
}
});
});
}
...後...
$(".dialog").each(function(){
var this_ID = this.id;
$(this).dialog({
autoOpen: false,
modal: true,
width: "auto",
show: {
effect: "slide",
duration: 400
},
hide: {
effect: "slide",
duration: 400
},
open: function(){ $('.ui-widget-overlay').on('click', function(){ $("#"+this_ID).dialog('close'); }); }
});
});