Reputation: 11
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. How can I make sure the content stays intact when I close and reopen the info window?
If continues to run in the background, I think it will be resolved.
javascript code
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;
});
});
Upvotes: 0
Views: 19
Reputation: 11
i got it
var timer = document.getElementsByClassName('ct');
for (var i = 0; i < timer.length ; i++){
timer[i].innerHTML = x;
}
Upvotes: 0