我如何解决谷歌地图api v3显示为灰色框? [英] how do i fix google maps api v3 from showing up as a gray box?

查看:233
本文介绍了我如何解决谷歌地图api v3显示为灰色框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在网站上搜索附近的地点时,我正在将结果显示在列表中,但地图区域只是变灰,有时会回来但随后消失。

when i search for nearby locations on the site i am workign on the results show up in a list but the map area is just grayed out sometimes it comes back but then goes away.

任何帮助将不胜感激

any help would be greatly appreciated

推荐答案

这是对第一个答案的回答。他的想法是正确的,你需要在任何可见的东西之前用一个位置初始化它。另请注意,这是一个关于V3的问题,第一个答案解决了V2的语法。请使用与v2文章相同的想法尝试下面的代码。

This is a response to your question on the first answer. His idea is right that you need to initialize it with a location before anything can be visible. Also please note that this is a question about V3, the first answer addresses the syntax of V2. Please try the code below using the same idea as the v2 post.

在地图选项中将中心值设置为初始位置。

Set the center value in the map options with your initial location. You can also adjust the zoom here.

var mapOptions = {
      zoom: 12,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: new google.maps.LatLng(latitude, longitude)
    };
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

这篇关于我如何解决谷歌地图api v3显示为灰色框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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