[英]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.