如何在谷歌可视化地图api中设置zoomLevel? [英] How to set zoomLevel in google Visualization Map api?
问题描述
我正在尝试实现可视化地图api,在此链接 https:// developers.google.com/chart/interactive/docs/gallery/map
我成功在Google地图上绘制点,但无法设置缩放级别。
对于单点,缩放级别自动设置为19(最大级别)。
我的代码: -
var map = new google.visualization.Map(document.getElementById('map_div'));
$ b $ map.draw(data,{showTip:true,zoom:14,mapType:'normal',useMapTypeControl:true,enableScrollWheel:false});
我试过这个 map.setZoom(12)
但它不工作。 不是 缩放
,
code> zoomLevel (有趣的是,您的问题的标题包含正确的答案^^)
$ hr
然而,很奇怪可视化API不提供访问底层 google.maps.Map
-instance的方法。
您可以添加此类方法(根据您自己的风险),将其添加到onload回调函数中:
google.visualization.Map.prototype.getMap = function(){
for(var k in this){
if(this [k] .constructor == google.maps .Map)返回这个[k];
您现在可以访问 I am trying to implement visualization map api,following this link https://developers.google.com/chart/interactive/docs/gallery/map i am successfully drawing the point on the google map but not able to set the zoomlevel.
For single point the zoomlevel automatic set to 19(max level). my code:- I have tried this The name of the property that defines the zoom-level in it's called However, it's curious that the visualization-API does not provide a method to access the underlying You may add such a method (on your own risk), add this to the onload-callback: you now may access the Example:
这篇关于如何在谷歌可视化地图api中设置zoomLevel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! google.maps.Map
-instance通过调用 google.visualization.Map $ c $>的方法
getMap
$ p $ map.getMap( ).setZoom(12);
var map = new google.visualization.Map(document.getElementById('map_div'));
map.draw(data, {showTip: true, zoom:14, mapType: 'normal', useMapTypeControl:true, enableScrollWheel:false});
map.setZoom(12)
but its not working. google.visualization.Map
is not zoom
,zoomLevel
(funny, the title of your question contains the correct answer^^)
google.maps.Map
-instance.google.visualization.Map.prototype.getMap=function(){
for(var k in this){
if(this[k].constructor==google.maps.Map)return this[k];
}
}
google.maps.Map
-instance by calling the method getMap
of the google.visualization.Map
-instance.map.getMap().setZoom(12);