仅限Google路线,在弹出窗口中 [英] Google Directions Only, in pop-up window

查看:70
本文介绍了仅限Google路线,在弹出窗口中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到我是第一次使用Web开发人员,我的Google地图已经足够好并且可以运行行车路线等,对此我感到非常满意. 只是一个问题,当我向客户(老板)展示它时,他喜欢它,但希望说明按原样显示,但在弹出窗口中而不是单独的选项卡中. 基本上保持地图不变,并在按下显示路线"时在弹出窗口中显示路线信息 我设法掌握了所有路由信息并将其显示在可移动的div中,但这不是他想要的. 我认识的任何人也是如此,只包括指示 一个单独的弹出窗口中的内容?或有关该主题的教程? 他想尽快看到它,所以我有点反对它,对大家的帮助将不胜感激,谢谢大家.

Got my google maps stuff up and running driving direction etc was quite pleased with it given I am a first time web developer. Just one problem, when I showed it to the client (boss) he liked it but wanted the directions to appear as they are but in a pop-up not a separate tab. Basically keep the map as is and display the routing info in a pop up window when "show route" is pressed I've managed to get hold of all the routing info and display it in a moveable div but this isn’t what he wants. So do does anybody I know of away of including just the directions stuff in a separate pop up window? or a tutorial on the topic? He wants to see it ASAP so I'm kind of up against it and any help would be really appreciated thanks all.

更新:根据Molles博士的建议,隐藏了包含信息的原始div,并尝试将其添加到弹出窗口中

Update: As per dr Molles suggestions Have hidden the original div containing the information and tried to add it into the pop up

使用以下代码:

enter code herefunction directionsWindow () {
            // get the div containing the direction information from the google
            // maps direction service
            var divToShow=document.getElementById('directions');
            // store the returned div in a variable
            var htmlToDisplay = document.getElementById('directions').innerHTML
            // get the html contained in the div and store it in a variable

            win=window.open('about:blank','instructions','width=1000,height=1000');
            // open a new window
            doc=win.document;
            // create a new div
            var divToDisplay = doc.createElement('div');
            // set its id to directions
            divToDisplay.id = "directions";
            // set its html to that of the div in the parent document
            divToDisplay.innerHTML = htmlToDisplay;
            // append the div to the window
            doc.body.appendChild(divToDisplay);
            doc.open();
            doc.close();
        }

但是这似乎不起作用,因为htmlToDisplay为空,即使我知道div存在并且具有内容(我可以一开始就可以看到它). 谁能给我一些启示?

but this does'nt seem to work as htmlToDisplay is empty, even though i know the div exists and has content (I can see it for a start). Can anyone shed some light?

推荐答案

只是让人们知道我已经设法在单独的窗口"中获取路线. 我必须使用jquery来显示和隐藏我用来显示方向的div,然后使其再次可与jquery拖动. 现在可以很好地运行了,我可以在地图上查看每个航路点并显示备用根,而仅使用新的弹出窗口窗口就无法管理这些备用根.

Just to let people know I've managed to get my directions in a separate "window". I had to use jquery to show and hide the div i was using to display the directions and then make it draggable again with jquery. Works well now I can view each of the waypoints on the map and show alternate roots, which I couldn't manage using just a new pop up window window.

这篇关于仅限Google路线,在弹出窗口中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆