获取已经在DOM上的google map实例
Get the instance of google map which is already on DOM
我有一个已经在DOM上的谷歌地图,上面有一些标记。我创建了它,并用SAP UI 5中的XML视图将其绑定到DOM。
<gmaps:Map id="map1" class="googleMap" height="600px" width="100%" zoom="4" lat ="100" lng = "80"></gmaps:Map>
现在我需要在JS中添加一些标记到已经存在的视图。但是我无法获得现有的地图对象。
我得到这个错误setMap: not an instance of Map; and not an instance of StreetViewPanorama
时,我试图得到这样的实例:
document.getElementById('mapContainer')
有什么解决方法吗?因为我是用XML创建地图的,所以Javascript中没有地图对象
如果映射div有一个名为id="map1"
的id,要获得您需要的元素
document.getElementById('map1')
请记住,一旦您将映射对象存储在窗口级别的变量中,您就可以使用该对象来引用映射。
<script>
var map
.....
map = new google.maps.Map(document.getElementById("map1"), mapOptions);
</script>
相关文章:
- 回调函数中传递参数的困难(Google Map API Markers)
- 使用API在我的网站Google-Map上显示搜索地址的纬度和经度
- 通过内部数组将JSON数据导入D3.js+Google Map
- 没有显示带有Infobox PHP/SQL的Google Map API v3
- 在javascript函数中访问Google map api
- Google Map API BackBoneJS 无法读取 null 的属性 'offsetWidth'
- Google Map KML层占位符点击事件返回ZERO_RESULTS
- Google Map JS API-加载地图分幅,但所有图像(标记、缩放控制等)都不加载;t负载2分钟
- Google MAP API 未捕获类型错误:无法读取 null 的属性“offsetWidth”
- jQuery在使用Bootstrap 3的Google Map v3的信息窗口中工作不完美
- 将Jquery拖放到Google Map V3
- Angular Google Map的自定义样式
- 样式化地图和地点库Google Map API v3
- 在Google Map API中定位画布外的输入字段
- Google Map API v3 在 Wordpress 中不起作用
- Google Map API use LatLng or Address
- SetTimeout on Directionservice route in google map javascrip
- Google Map API - foreach 循环中的信息窗口
- 将 MarkerClusterer 与数据库驱动的 Google Map V3 集成
- javascript google map setcenter and setzoom with animation