我不想在jquery ui模式对话框中显示谷歌地图。我打开对话框但是地图不可见。然而它存在于那里它只是不可见。
这是页面来源:
<div class="dialog ui-dialog-content ui-widget-content" id="photoLocation" style="padding: 0px; background-color: rgb(255, 255, 255); overflow: hidden; width: auto; min-height: 0px; height: 390px; background-position: initial initial; background-repeat: initial initial; " scrolltop="0" scrollleft="0">
<div id="map" style="width: 300px; height: 300px;"></div>
</div>
它以某种方式接触z-index是错误的,但我试图在地图div上改变它,但这没有帮助。 当我打开模态对话框时,这里的代码应该显示地图。
<script>
var map;
var styleArray = [
{
featureType: "all",
stylers: [
{ visibility: "off" }
]
},
{
featureType: "road",
stylers: [
{ visibility: "on" }
]
},
{
featureType: "administrative",
stylers: [
{ visibility: "on" }
]
}
];
(function () {
window.onload = function() {
var mapDiv = document.getElementById('map');
var latlng = new google.maps.LatLng('44.339565', '-114.960937');
var options = { styles: styleArray,
center: latlng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
};
map = new google.maps.Map(mapDiv, options);
var marker = new google.maps.Marker({
position: latlng,
icon: '../Content/Pointer.png',
map: map,
draggable: true
});
};
})();
</script>
<div id="map" style="width: 300px; height: 300px;"></div>
这就是我提出模态对话框的方式:
$(".openDialog").live("click", function (e) {
e.preventDefault();
$("<div></div>")
.addClass("dialog")
.attr("id", $(this).attr("data-dialog-id"))
.appendTo("body")
.dialog({
title: $(this).attr("data-dialog-title"),
close: function () { $(this).remove() },
modal: true,
resizable: false,
show: 'fade',
width: 460,
height: 390,
create: function (event, ui) {
$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").css("display", "none");
$(this).parents(".ui-dialog").css("padding", 0);
$(this).parents(".ui-dialog").css("border", 4);
$(this).parents(".ui-dialog:first").find(".ui-dialog-content").css("padding", 0);
$(this).parents(".ui-dialog:first").find(".ui-dialog-content").css("background", "#ffffff");
$(this).parents(".ui-dialog:first").find(".ui-dialog-content").css("overflow", "hidden");
}
})
.load(this.href);
});
@Html.ActionLink("Title", "Method", "Controller", new {imageId = @Model.ItemId}, new {data_dialog_id = "plid", @class = "openDialog button"})
答案 0 :(得分:3)
试试这个
<强> HTML:强>
<div id="mymodal">
<div id="map" style="width: 300px; height: 300px;"></div>
</div>
<强> JS:强>
$(function(){
var map;
var elevator;
var latlng=new google.maps.LatLng('44.339565', '-114.960937');
var styleArray = [
{featureType: "all", stylers: [{ visibility: "off" }]},
{featureType: "road", stylers: [{ visibility: "on" }]},
{featureType: "administrative", stylers: [{ visibility: "on" }]}
];
var myOptions = {
styles: styleArray,
zoom: 6,
center: latlng,
mapTypeId: 'terrain'
};
map = new google.maps.Map($('#map')[0], myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
icon: 'http://google-maps-icons.googlecode.com/files/walking-tour.png',
draggable: true
});
$('#mymodal').dialog({width:335, height:355});
});