谷歌地图api工作不正常 [英] Google maps api not working properly
问题描述
所以我正在使用
如果我把一个人放在路上,那么我得到:
近距离和个人的追踪者看起来完全是宽度和高度,但是远处的方向图是所有破碎....
任何人都知道为什么? 好点的!
即使我有同样的问题!
只有当div或window被调整大小时,才能调用它!
google.maps.event.trigger(map,'resize' )
现在我可以看到完整的渲染屏幕了!!
So I'm playing around with this example and our company has its own API key for google maps. a co-worker and I tried to get the maps to work - Well in full screen the following code worked - by that I mean we just let the map scale the full width of the browser, the code we used is:
<script>
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="map-canvas"></div>
Obviously their is no API key because that's loaded else where.
So I decided to add on to this, because I needed the map stored else where - and I added this extra jazz:
<style>
#map-canvas {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#Map{
height: 350px;
}
</style>
The first one is obvious, The second one is part of the jquery-ui tab which I basically, for this tab, set it's height to 350px
Moving on - the issue is this:
if I drop a person on to the road then I get:
the "up close and personal" stalker look goes full width and height but the far away directions map is all broken....
Anyone know why?
Good point praveen! Even I had same problem! You don't have to call it only when the div or window is resized! In my case I am calling it after the Map is rendered.
google.maps.event.trigger(map, 'resize')
Now I can see full rendered screen!!
这篇关于谷歌地图api工作不正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!