简体   繁体   English

当我关闭并重新打开信息 window 时,如何确保内容保持不变

[英]How can I make sure the content stays intact when I close and reopen the info window

I am outputting the Google Map info window with id created in javascript, but when I close and reopen the info window, there is Disappear content in the info window. I am outputting the Google Map info window with id created in javascript, but when I close and reopen the info window, there is Disappear content in the info window. Tap the marker to display an info window with no contents Press the 'report' button to display the contents in the information window.点击标记以显示没有内容的信息 window 按“报告”按钮以显示信息 window 中的内容。 How can I make sure the content stays intact when I close and reopen the info window?当我关闭并重新打开信息 window 时,如何确保内容保持不变?

If continues to run in the background, I think it will be resolved.如果继续在后台运行,我想会解决的。

javascript code javascript码

function display_c(start){
        window.start = parseFloat(start);
        var end = 172800; // change this to stop the counter at a higher value
        var refresh=1000; // Refresh rate in milli seconds
        if(window.start >= end ){
            alert("Time Over ");
        } else {
            mytime=setTimeout('display_ct()',refresh)
        }
    }

    function display_ct() {
        // Calculate the number of days left
        var days=Math.floor(window.start / 86400);
        // After deducting the days calculate the number of hours left
        var hours = Math.floor((window.start - (days * 86400 ))/3600)
        // After days and hours , how many minutes are left
        var minutes = Math.floor((window.start - (days * 86400 ) - (hours *3600 ))/60)
        // Finally how many seconds left after removing days, hours and minutes.
        var seconds = Math.floor((window.start - (days * 86400 ) - (hours *3600 ) - (minutes*60)))

        var x = days + "day " + hours + "hour " + minutes + "minute " + seconds + "second";


        document.getElementById('ct').innerHTML = x;
        window.start= window.start+ 1;

        tt=display_c(window.start);
    }


// Handle Cordova Device Ready Event
$$(document).on('deviceready', function() {

    var markerCount=0;

    var mapOpts = {
        center: [37, 127],
        zoom: 7,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        mapTypeControl: true,
        mapTypeControlOptions: {
            style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
        },
        navigationControl: true,
        scrollwheel: true,
        disableDoubleClickZoom: true,
        streetViewControl: false,
        zoomControl:false,
        fullscreenControl:false,
        disableDefaultUI: true
    };

    function genId() {
        return '' + (new Date()).getTime();
    }

    function placeMarker(map, event) {
            $(this).gmap3({
                marker: {
                    latLng: event.latLng,
                    id:markerCount,
                    data:'<span id="ct"></span>',
                    options: {
                        draggable: true,
                        icon: "http://maps.google.com/mapfiles/marker_green.png"
                    },
                    events: {
                        click: function(marker, event, context){
                            console.log(marker);
                            var lat=marker.position.lat();
                            var lng=marker.position.lng();

                            var map = $(this).gmap3("get");

                            map.panTo(marker.position);

                            var map = $(this).gmap3("get"),
                                infowindow = $(this).gmap3({get:{name:"infowindow"}});
                            if (infowindow){
                                infowindow.open(map, marker);
                                infowindow.setContent(context.data);
                            } else {
                                $(this).gmap3({
                                    infowindow:{
                                        anchor:marker,
                                        options:{content: context.data}
                                    }
                                });
                            }

                        },

                    }

                }
            });
        }


    $('.map-object').gmap3({
        map: {
            options: mapOpts,
            events: {
                click: placeMarker
            }
        }
    });

    $('#report').click(function(){
        window.start= window.start+ 1;
    });
});

i got it我知道了

var timer = document.getElementsByClassName('ct');
for (var i = 0; i < timer.length ; i++){
    timer[i].innerHTML = x;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使缩小或放大,我如何确保它保持居中? - How can I make sure this stays centered, even when zoomed out or in? 我可以确保该元素保留在其他屏幕上吗? - Can I make sure that this element stays on other screens? 如何确保开/关按钮保持打开和关闭? - How do I make sure on/off button stays on and off? 如何将我的谷歌地图信息 window 内容居中? - How can I center my google maps info window content? 当我在其中添加“空格”时,如何确保文本保持在同一行 <li> 元件? - How do I make sure my text stays on same line when I add a 'space' inside <li> element? 如何在背景停留时使div内容滚动 - how do I make the div content to scroll while the background stays 如何在悬停在菜单上时将其保留在下拉菜单中? - How can I make it so the dropdown menu stays there when I'm hovering on it? 如何制作一个弹出窗口,允许用户单击链接,关闭窗口并在第一个窗口中打开链接? - How can I make a popup window that allows the user to click a link, close the window, and open the link in the first window? 当被固定内容包围时,如何使用浏览器窗口使iframe增长/缩小? - How can I make an iframe grow/shrink with the browser window, when surrounded by fixed content? 如何使我的页面可以关闭或重新加载,但当我再次打开页面时内容不会消失? - How do I make it so my page can close or reload but the content wont disappear when i open the page again?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM