谷歌地图在左上角 [英] Google map in top corner left

查看:161
本文介绍了谷歌地图在左上角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以100%的宽度显示Google地图。
但是我遇到了这个问题。它只显示在左上角

I want to display a google map in a 100% width. But I encounter this problem. It displays only in the top left corner

http:// imgur。 com / obphYag

我也使用jquery切换此地图。这是我的代码

I toggle this map with jquery too. Here's my code

    function initialize() {
        var latitude = 48.3592727;
        var longitude = -2.6350914;
        var zoom = 8;

        var LatLng = new google.maps.LatLng(latitude, longitude);

        var mapOptions = {
            zoom: zoom,
            center: LatLng,
            panControl: false,
            zoomControl: false,
            scaleControl: true,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }

        var map = new google.maps.Map(document.getElementById('map-nos-agences'), mapOptions);



google.maps.event.trigger(map, 'resize');

}

    $("#map-nos-agences").hide();

    if($j("#map-nos-agences").length>0) {
        initialize();
    }

    $("#hideshow").click(function(){

        $("#map-nos-agences").toggle('slow');

    }); 

当我没有切换它时,它显示正确。
感谢您的帮助!

When I'm not toggle it, it displays correctly. Thanks for the help !

推荐答案

尝试在地图上触发缩放大小 code> event:

Try triggering a resize on the map idle event:

google.maps.event.addListenerOnce(map, 'idle', function() {
  google.maps.event.trigger(map, 'resize');
});

这篇关于谷歌地图在左上角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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