谷歌地图没有在地图上显示地图和标记
Google Map not displaying map and marker on the map
我正试图在谷歌地图上显示纬度和经度。用我的代码,我得到了空框与谷歌地图。
这是我显示数据的div标记。
<div id="map"></div>
这是调用html页面上定位功能的按钮
<td><button type="button" class="btn btn-primary" ng-click="MyMap(record.id ,record.coordinates)">{{record.coordinates}} </button>
这是我试图在谷歌地图上显示标记的函数throught。
$scope.MyMap=function(id,coordinates)
{
console.log(id,coordinates);
locate(coordinates);
}
function locate(coordinates) {
console.log(coordinates);
var myLatlng = new google.maps.LatLng(coordinates[1], coordinates[0]);
var map = new google.maps.Map(
document.getElementById("map"), {
center: myLatlng,
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map
})
}
当我点击按钮时,我在地图分区中得到了一个空的灰色框。问题在哪里
可能是您没有为地图div分配维度(这在谷歌地图中是强制性的)
试试这种方式
<div id="map" style="height: 400px; width: 400px;"></div>
相关文章:
- 张贴到地图显示的限制
- 谷歌地图显示灰色方框
- 无法让谷歌地图显示在我的网站上
- Google Maps Javascript API v3 地图显示在桌面浏览器上,但不会显示在移动浏览器上
- 双击谷歌地图显示提示框不起作用
- 谷歌地图显示钦奈(印度)使用javascript
- 使用 IMG 地图显示更大的图像
- 当缩放级别为 1 时,谷歌地图显示 kml(内部是图像 URL)不正确
- 无法让我的 openlayers 地图显示在网页上
- 谷歌地图显示没有jQuery
- 谷歌地图显示问题
- 谷歌/必应地图显示所有城市
- Esri 地图显示信息窗口,无需单击地图
- 必应地图显示地图的左上角的北美
- 谷歌地图显示KML数据
- 谷歌地图显示新请求后的旧方向
- 谷歌地图显示什么,直到我最小化屏幕
- 谷歌地图显示多个地图而不是一个
- 为什么谷歌地图显示灰色,而没有初始化缩放&当使用jQuery按钮更改缩放时,居中,地图上的居中效果非常好
- 谷歌地图显示标题的信息框