Google Map does not display entirely when using ajax

I have a problem since three days about google map. I want to use jQuery to dynamically load the map in a page. Here is the code: In left side page, a script that loads the page into the right one: In the right side page: ' . "\n"; $content .= "\t" . 'function initialize() {' . "\n"; $content .= "\t" . 'var myLatlng = new google.maps.LatLng(6.125,1.154 );' . "\n"; $content .= "\t" . 'var myOptions = {' . "\n"; $content .= "\t\t" . 'zoom: 8,' . "\n"; $content .= "\t\t" . 'center: myLatlng,' . "\n"; $content .= "\t\t" . 'mapTypeId: google.maps.MapTypeId.' . $this->mapTypeId . "\n"; $content .= "\t" . '}' . "\n"; $content .= "\t" . 'map = new google.maps.Map(document.getElementById("map"), myOptions);' . "\n"; $content .= '}' . "\n"; $content .= "\t" . 'function loadMaps() {' . "\n"; $content .= "\t" . ' google.load("maps", "3", {"other_params":"sensor=false", "callback" : initialize});' . "\n"; $content .= "\t" . '}' . "\n"; $content .= "\t" . 'function initLoader() {' . "\n"; $content .= "\t" . 'var script = document . createElement("script");' . "\n"; $content .= "\t" . 'script.type = "text/javascript";' . "\n"; $content .= "\t" . 'script.src = "https://www.google.com/jsapi?async=2&callback=loadMaps";' . "\n"; $content .= "\t" . 'document.getElementsByTagName("head")[0].appendChild(script);' . "\n"; $content .= "\t" . '}' . "\n"; $content .= "\t" . 'window.onload=initLoader();' . "\n"; $content .= '' . "\n"; print $content; ?>
When I call the right page without ajax (by its url), i get the map entirely displayed but when using ajax, the map is not fully displayed. Please, I need your help! --- I apologize for the incomplete information provided. In fact, the map was posted in the second tab that was not the main. So, I do not understand how jquery did it but when I opened the tab of the map, the card was shown to one third. This morning, with the tab of the map in the foreground (that is opened by default), I realized that the map displayed entirely. I am now racking my brains to find this curious problem of jquery tabs! Thank you!

以上就是Google Map does not display entirely when using ajax的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏