Please give me a piece of advice.
I'm trying to create a map with multiple image overlays. I'd like to show/hide each overlays by checking the checkbox. I used GeoJason's code as a reference, but for some reason, it doesn't work properly for me: whether checked or unchecked, no layer appears. Please tell me what's wrong with my code.
This is script part.
<script>
var server = 'https://gbank.gsj.jp/seamless/tilemap/';
var geolMapType = 'basic';
var layer = 'glfn';
var opacity = 0.7;
var map;
function initialize() {
var mapOptions = {
zoom: 7,
center: new google.maps.LatLng(34.59, 135.67),
mapTypeId: google.maps.MapTypeId.ROADMAP,
minZoom: 5,
maxZoom: 13
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
overlayMaps = [
{ //sedTer
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //sedMar
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=_____AAAAAAAAAAAAAAAAAAAAAAwBAIEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //accSed
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAA______4AAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //accMaf
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAH-AAAAAAAAAAAAAAAgAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //volTep
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //volDeb
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //volInt
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAeAAAAAAAAAAAAAAAehwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //pluFel
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAAAAAAAAP_-AAAAAAgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //pluMaf
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAABAAAAAAAAAD_-AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //pluMig
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //all
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png';
},
tileSize: new google.maps.Size(256, 256),
isPng: true,
opacity: 0.2
}
];
$('.layer').click(function(){
var layerID = parseInt($(this).attr('id'));
if ($(this).attr('checked')){
var overlayMap = new google.maps.ImageMapType(overlayMaps[layerID]);
map.overlayMapTypes.setAt(layerID, overlayMap);
}
else {
if (map.overlayMapTypes.getLength() > 0){
map.overlayMapTypes.setAt(layerID, null);
}
}
});
for (i = 0; i < overlayMaps.length; i++){
map.overlayMapTypes.push(null);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
And this is HTML code.
<input type="checkbox" id="00" class="layer" name="sedTer" /><label for="00">Sedimentary Rocks, Terrace</label><br />
<input type="checkbox" id="01" class="layer" name="sedMar" /><label for="01">Sedimentary Rocks, Non-marine&Marine</label><br />
<input type="checkbox" id="02" class="layer" name="accSed" /><label for="02">Accretionary Complexes, Mainly sedimentary rocks</label><br />
<input type="checkbox" id="03" class="layer" name="accMaf" /><label for="03">Accretionary Complexes, Mafic</label><br />
<input type="checkbox" id="04" class="layer" name="volTep" /><label for="04">Volcanic Rocks, Tephra</label><br />
<input type="checkbox" id="05" class="layer" name="volDeb" /><label for="05">Volcanic Rocks, Debris</label><br />
<input type="checkbox" id="06" class="layer" name="volInt" /><label for="06">Volcanic Rocks, Intrusive</label><br />
<input type="checkbox" id="07" class="layer" name="pluFel" /><label for="07">Plutonic Rocks, Felsic</label><br />
<input type="checkbox" id="08" class="layer" name="pluMaf" /><label for="08">Plutonic Rocks, Mafic</label><br />
<input type="checkbox" id="09" class="layer" name="pluMig" /><label for="09">Plutonic Rocks, Migmatitic</label><br />
<input type="checkbox" id="10" class="layer" name="all" /><label for="10">All</label><br />
Please, no flames about my bad English. Thank you for your time.
The issue is this:
if ($(this).attr('checked'))
when you click a checkbox, the checked-attribute of a checkbox will not change.
But the checked-property will, use this instead:
if ($(this).prop('checked'))
Related
here, I'm using subgridOptions to expand all subgrid but the problem is subgrid columns hidden what is the solution of that.
expand problem in treejqgrid columns hide at the end and columns width is not set according to the treeview.
so, I want some concrete solution of this problem as soon as possible.
```
function showChildGridExtend(parentRowID, parentRowKey) {
debugger;
var formname = "B/s Group";
var childGridID = parentRowID + "_table";
var childGridPagerID = parentRowID + "_pager";
// send the parent row primary key to the server so that we know which grid to show
var childGridURL = parentRowKey + ".json";
// add a table and pager HTML elements to the parent grid row - we will render the child grid here
$('#' + parentRowID).append('<table id=' + childGridID + '></table><div id=' + childGridPagerID + ' class=scroll></div>');
$("#" + childGridID).jqGrid('GridUnload');
$("#" + childGridID).jqGrid({
autowidth: true,
shrinkToFit: true,
url: '../ChartofAccounts/GetTreeJqgrid',
mtype: "GET",
datatype: "json",
postData: { searchstr: parentRowID, TableName: globaltablename, formname: formname },
page: 1,
colNames: globalcolnames,
colModel: globalcolmodal,
subGridOptions: {
//expand all rows on load
"expandOnLoad": true
},
jsonReader: {
repeatitems: false,
id: "code",
root: function (obj) {
var data;
data = JSON.parse(obj["Data"]);
//alert(data);
const myJSON = JSON.stringify(data);
// alert(myJSON.length);
subGridlength = myJSON.length;
if (subGridlength == 2) {
// $($('#' + parentRowKey + ' td a span')[0]).addClass('safallast');
}
return JSON.parse(obj["Data"]);
},
},
gridComplete: function () {
if (subGridlength == 2) {
// $('.safallast').css('display', 'none');
}
var objRows = $("#" + parentRowID + "_table tr");
$("#" + parentRowID + "_table").addClass('table-responsive');
$("#" + parentRowID + "_table").css('overflow', 'visible');
var objHeader = $("#" + parentRowID + "_table .jqgfirstrow td");
var objLable = $("#gbox_" + parentRowID + "_table .ui-jqgrid-labels th");
$("#" + parentRowID + "_table").css("overflow-x", "hidden");
if (objRows.length > 1) {
var objFirstRowColumns = $(objRows[1]).children("td");
for (i = 0; i < objFirstRowColumns.length; i++) {
$(objFirstRowColumns[i]).css("width", $(objHeader[i]).css("width"));
var jqgridlblwidth = parseFloat(parseFloat($(objHeader[i]).css("width")));
$(objLable[i]).css("width", jqgridlblwidth + 'px');
}
}
if (objRows.length == 1) {
$("#gbox_" + parentRowID + "_table").css('display', 'none');
}
DropDownTreeView();
$('#' + parentRowID + '_table_subgrid').css('width', '35px').css('overflow-x', 'hidden');
$($('#' + parentRowID + '_table tr td')[0]).css('width', '35px');
$(".ui-jqgrid-htable").addClass("bg-primary-600");
$(".ui-jqgrid-bdiv").css("min-height", "auto").css('overflow-x', 'hidden');
//$('#jq-grid').children("ui-sgcollapsed sgexpanded").unbind().html("");
},
pgbuttons: false,
pginput: false,
pgtext: "",
//width: 500,
height: "auto",
subGrid: true, // set the subGrid property to true to show expand buttons for each row
subGridRowExpanded: showChildGridExtend, // javascript function that will take care of showing the child grid
// pager: "#" + childGridPagerID
});
$(".ui-jqgrid-bdiv").css("min-height", "auto");
$("#" + parentRowID + "_table").css('word-break', 'break-word');
$("#" + parentRowID + "_table").css('overflow-x', 'hidden');
// $($('#jqgh_jq-grid_GroupAlias span')[0]).css("display", "none");
jQuery("#" + parentRowID + "_table").removeClass('table-responsive');
}
```
When I try to print the fullCalendar in google chrome its border are not showing up.
I've placed the #media print query to set border color and width. below is my code for media query.
#media print {
#briefingCalendar { width: 9in; margin-left:0px !important;}
.fc-widget-header, .fc-widget-content{ border: 1px solid #ccc !important;}
}
attached is the snapshot of my calendar without borders.
Below is the code of print view for my fullCalendar.
<?php
$baseUrl = Yii::app()->baseUrl;
$cs = Yii::app()->getClientScript();
$cs->registerCssFile($baseUrl . '/css/jquery-ui-multiselect/jquery.multiselect.css', 'screen, projection');
$cs->registerCssFile($baseUrl . '/css/jquery-ui-multiselect/jquery.multiselect.filter.css', 'screen, projection');
$cs->registerCssFile($baseUrl . '/css/jquery-ui-multiselect/style.css', 'screen, projection');
$cssCoreUrl = $cs->getCoreScriptUrl();
$cs->registerCssFile($cssCoreUrl . '/jui/css/base/jquery-ui.css');
$cs->registerScriptFile($baseUrl . '/javascript/jquery-ui-multiselect/jquery.multiselect.js');
$cs->registerScriptFile($baseUrl . '/javascript/jquery-ui-multiselect/jquery.multiselect.filter.js');
$cs->registerScriptFile($baseUrl . '/javascript/fullcalendar/fullcalendar.js');
$cs->registerScriptFile($baseUrl . '/javascript/jquery.printelement.js');
$cs->registerCssFile($baseUrl . '/css/fullcalendar/fullcalendar.css');
$cs->registerCssFile($baseUrl . '/css/screen.css', 'print');
$cs->registerScriptFile($baseUrl . '/javascript/week_calendar/date.js');
$cs->registerScriptFile($baseUrl . '/javascript/sticky.js');
$cs->registerCss('calendar-print', '
#media print {
#briefingCalendar { width: 9in; margin-left:0px !important;}
.fc-widget-header, .fc-widget-content{ border: 1px solid #ccc !important;}
}
');
$date = DateTime::createFromFormat('Y-m-d', $_GET['startDate']);
$formatDate = "<h2>".$date->format('F Y')."</h2>";
?>
<div id="loading" style="margin-left: 0px; width: 9in;"></div>
<div id="briefingCalendar" style="margin-left: 0px; width: 9in;"></div>
<script type="text/javascript">
var isCurrentBriefingCenterForTitles = '<?php echo $this->isCurrentBriefingCenterForCustomEventsTitle(Yii::app()->user->currentBriefingCenterId); ?>';
$(document).ready(function () {
$('#briefingCalendar').fullCalendar('destroy').fullCalendar({
loading: function(bool) {
if (bool){
$('#loading').html("<div class='alert'><b> Loading calender data, please wait... </b></div>");
}
else{
$('#loading').hide();
setTimeout(function(){printCalendar();}, 1000);
}
},
year: '<?php echo date('Y', strtotime($startDate)) ?>',
month: '<?php echo date('m', strtotime($startDate)) - 1 ?>',
date: '<?php echo date('d', strtotime($startDate)) ?>',
defaultView: '<?php echo $view ?>',
timeFormat: {
'month': 'h(:mm)t{-h(:mm)t}',
'week': 'hh:mmtt{ - hh:mmtt}',
'day': 'hh:mmtt{ - hh:mmtt}'
},
header: {
right: '',
center: 'title',
left: ''
},
events: {
url: '<?php echo $this->createUrl('events') ?>' + '&type=mini&<?php echo $queryStr ?>',
borderColor: 'black'
},
eventRender: function (event, element) {
element.find('.fc-event-title').html(renderEvent(event));
},
viewDisplay: resizeCalendar,
lazyFetching: false,
disableResizing: false
});
});
$('.fc-header-right').css('vertical-align', 'middle').html($('div#calendarOptions div.options').html());
$('.fc-header-left').append($('div#fullCalendarOptions').html());
function renderEvent(event) {
var data = '';
if (!event.data.cn) {
var resultTime = "";
if (event.data.Time) {
var startFormat = "am";
var endFormat = "am";
var time = event.data.Time.split("-");
var startHours = parseFloat(time[0].substr(0, 3));
var startMinutes = parseFloat(time[0].substr(3, 2));
if (startHours >= 12) {
startHours -= 12;
startFormat = "pm";
}
if (startHours == 0)
startHours = 12;
var endHours = parseFloat(time[1].substr(0, 3));
var endMinutes = parseFloat(time[1].substr(4, 2));
if (endHours >= 12) {
endHours -= 12;
endFormat = "pm";
}
if (endHours == 0)
endHours = 12;
resultTime += startHours;
if (startMinutes != 0) {
if (startMinutes < 10) {
resultTime += ":0" + startMinutes;
}
else
resultTime += ":" + startMinutes;
}
if (startFormat != endFormat)
resultTime += startFormat;
resultTime += "-" + endHours;
if (endMinutes != 0) {
if (endMinutes < 10) {
resultTime += ":0" + endMinutes;
}
else
resultTime += ":" + endMinutes;
}
resultTime += endFormat;
}
if (isCurrentBriefingCenterForTitles) {
data = "<div class='cal-event'>" +
"<div class='head'>" +
"<img src='<?php echo $baseUrl ?>/images/briefing_status/" + event.data.statusIcon + "'>" +
"<span class='title'>" + event.title + "</span>" +
"</div>" +
"<div class='desc'>" +
"<label><i>Type: </i>" + event.data.visitType + "</label>" +
"<label><i>Eng: </i>" + event.data.techSupportEmail + "</label>" +
"<label><i>Loc: </i>" + event.data.briefingLoc + "</label>" +
"</div>" +
"</div>";
} else {
data = "<div class='cal-event'>" +
"<div class='head'>" +
"<img src='<?php echo $baseUrl ?>/images/briefing_status/" + event.data.statusIcon + "'>" +
"<span class='title'>" + event.title + "</span>" +
"</div>" +
"<div class='desc'>";
if (event.data.vesBriefingManager == null) {
data += "<label><i>Req: </i>" + event.data.RQ + "</label>";
}
if (event.data.briefingManager && event.data.briefingManager != '' && event.data.briefingManager.name != '') {
var briefingManager = "";
$.each(event.data.briefingManager, function(index, value ){
briefingManager += (value && value != "") ? value + ", " : "";
});
data += "<label><i><?php echo Yii::app()->settings->get("briefing", "customMgrField"); ?> </i>"
+ briefingManager.replace(/,(\s+)?$/, '')
+ "</label>";
}
if (event.data.vesBriefingManager != null) {
data += "<label><i>VES Mgr: </i>" + event.data.vesBriefingManager + "</label>";
}
data += "<label><i>Loc: </i>" + event.data.briefingLoc + "</label>";
if (event.data.tourTime != null) {
data += "<label><i>Tour Time: </i>" + event.data.tourTime + "</label>";
}
if (event.data.vicBriefingManager != null) {
data += "<label><i>Tour Host: </i>" + event.data.vicBriefingManager + "</label>";
}
data += "</div>" +
"</div>";
}
} else {
data = "<div class='cal-event'>" +
"<div class='head'>" +
"<img src='<?php echo $baseUrl ?>/images/calendar_note/" + event.data.noteType + "'>" +
"<span class='title'>" + event.title + "</span>" +
"</div>" +
"</div>";
}
return data;
}
function resizeCalendar() {
var currentView = $('#briefingCalendar').fullCalendar('getView');
if(currentView.name === 'agendaWeek' || currentView.name === 'agendaDay') {
currentView.setHeight(2000);
$(".fc-header-center").html('');
}else if(currentView.name === 'month'){
$(".fc-header-center").html('<?php echo $formatDate; ?>');
}
}
function printCalendar()
{
$("#briefingCalendar").printElement(
{
overrideElementCSS:[
{ href:'<?php echo $baseUrl . '/css/fullcalendar/fullcalendar.css'; ?>',media:'print'}
],
printMode:'iframe'
});
}
</script>
overrideElementCSS accepts 3 parameters and I was assigning only two parameters.
Below is the proper way to use overrideElementCSS.
$("selector").printElement(
{
overrideElementCSS:[
'thisWillBeTheCSSUsed.css',
{ href:'thisWillBeTheCSSUsedAsWell.css',media:'print'}]
});
Taken from [http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/]
Here my Code, on sucess i need to split (data.d) and stored in variable, but it not working, any idea where am wrong ?
$("#ckAddrow").click(function () {
var abcStr = null;
var taskName = $("#ctl00_ContentPlaceHolder1_txttaskname_").val();
var sdate = $("#ctl00_ContentPlaceHolder1_txtsdate_").val();
var edate = $("#ctl00_ContentPlaceHolder1_txtedate_").val();
var hdfieldid = $("#ctl00_ContentPlaceHolder1_hdid").val();
var dataString = 'taskname=' + taskName + '&sdate=' + sdate + '&edate=' + edate + '&hfid=' + hdfieldid;
// alert(dataString);
$.ajax({
type: "POST",
url: "AutoComWebservices.asmx/insertTasksRecord",
data: "{ 'prefix': '" + dataString + "'}",
dataType: "json",
contentType: "application/json; charset=utf-8",
cache: false,
async: true,
success: function (data) {
abcStr = data.d;
alert(abcStr);
BuildTable(data.d);
// var valSplit = abcStr.split('-');
// var taskname = valSplit[0];
// var startdate = valSplit[1];
// var enddate = valSplit[2];
// var pf = valSplit[3];
// var myscopeid = valSplit[4];
// alert(taskname + " - - - " + myscopeid);
// alert(data.d)
// var getId = myscopeid;
// var abc = "<tr id='" + getId + "' class='edit_tr'><td class='edit_td'><span ID='taskName_''" + getId + "' class='lblclass'>'" + taskName + "'</span><input id='taskName_txt_''" + getId + "' class='editbox' type='text' value='" + taskName + "' /></td><td class='edit_td'><span ID='startDate_''" + getId + "' class='lblclass'>'" + sdate + "'</span><input id='startDate_txt_''" + getId + "' class='editbox sdatedp' type='text' value='" + sdate + "' /></td><td class='edit_td'><span ID='endDate_''" + getId + "' class='lblclass'>'" + edate + "'</span><input id='endDate_txt_''" + getId + "' class='editbox edatedp' type='text' value='" + edate + "' /></td></tr>";
//"<tr id=9 class=\"edit_tr"><td class="edit_td"><span ID="taskName_9" class="lblclass">dummy</span><input id="taskName_txt_9" class="editbox" type="text" value=dummy /></td><td class="edit_td"><span ID="startDate_9" class="lblclass">03/14/2013</span><input id="startDate_txt_9" class="editbox sdatedp" type="text" value=03/14/2013 /></td><td class="edit_td"><span ID="endDate_9" class="lblclass">03/30/2013</span><input id="endDate_txt_9" class="editbox edatedp" type="text" value=03/30/2013 /></td></tr>"
}
});
});
On alert(abcStr);
is shows heloo-03/19/2013-03/20/2013-138-52
further i need to split('-') and save in variables;
My webmethod code:
[WebMethod]
public string[] insertTasksRecord(string prefix)
{ List<string> d = new List<string>();
string taskname, startdate, enddate,pf;
string datastr = prefix;
string myvalue = "";
string[] val = datastr.Split('&');
string[] tname = val[0].Split('=');
taskname = tname[1];
string[] sdate = val[1].Split('=');
startdate = sdate[1];
string[] edate= val[2].Split('=');
enddate = edate[1];
string[] planid = val[3].Split('=');
pf = planid[1];
DateTime mysdate = Convert.ToDateTime(startdate);
DateTime myedate = Convert.ToDateTime(enddate);
SqlCommand cmd = new SqlCommand(myQuery, connloc);
connloc.Open();
string myscopeid = cmd.ExecuteScalar().ToString();
connloc.Close();
d.Add(string.Format("{0}-{1}-{2}-{3}-{4}",taskname, startdate, enddate,pf,myscopeid));
return d.ToArray();
}
I have a createMarker() function that is used to place multiple markers on the google map. The following is the code:
function createMarker(point,custid,streetadd,city,state,zip,address,phone,website,co)
{
var infowindowHover,infowindowClick;
var marker = new google.maps.Marker({
position: point,
map: map,
icon: image,
});
var boxClickText = document.createElement("div");
boxClickText.className = "infoBackground";
var markerMarkup = "<div id='infobox'><TABLE class='test'><TR><TD colspan='2'><B class='title'>";
markerMarkup = markerMarkup + co + "</B></TD></TR><TR><TD colspan='2'>";
markerMarkup = markerMarkup + streetadd + "</TD></TR><TR><TD colspan='2'>";
markerMarkup = markerMarkup + city + "," + state + " " + zip + "</TD></TR><TR><TD colspan='2'>";
markerMarkup = markerMarkup + phone + "</TD></TR><TR><TD colspan='2'>";
if(website.indexOf("http://")>0) { markerMarkup = markerMarkup +"<a href="; }
else{ markerMarkup = markerMarkup +"<a href=http://"; }
markerMarkup = markerMarkup + website + " target=_blank>" + website + "</a></TD></TR><TR><TD class='availableStyle'>";
markerMarkup = markerMarkup +'see available styles';
//markerMarkup = markerMarkup + '<input type="button" value="see available styles" onclick="setstyles('+ custid +',\'' + streetadd + '\'' + ',\'' + city + '\'' + ',\'' + state + '\'' + ',\'' + zip + '\'' + ',\'' + address + '\''+ ',\'' + phone + '\''+ ',\'' + website + '\''+ ',\'' + co + '\'' + ')" />';
markerMarkup = markerMarkup + "</TD></TR></TABLE></div>";
boxClickText.innerHTML = markerMarkup;
var myOptions_click = {
content: boxClickText
//,disableAutoPan: true
,disableAutoPan: false
,maxWidth: 0
,pixelOffset: new google.maps.Size(-140, 0)
,zIndex: null
,boxStyle: {
//opacity: 0.75
//,width: "280px"
margin:"-58px 0px 0px 148px"
}
,closeBoxMargin: "10px 2px 2px 2px"
,closeBoxURL: "http://mansi:2525/pc-new/images/mapclosebutton.gif"
,infoBoxClearance: new google.maps.Size(1, 1)
,isHidden: false
,pane: "floatPane"
,id: "infoWindowClick"
,enableEventPropagation: false
};
var ib = new InfoBox();
google.maps.event.addListener(marker, "click", function (e) {
ib.close();
ib.setOptions(myOptions_click);
ib.open(map, this);
});
return marker;
}
I have referred similar question from Google Map V3 - Allow only one infobox to be displayed at a time and applied the code in the same way but I am not getting the desired result.
Google Map V3 - Allow only one infobox to be displayed at a time
You declare a new infobox every time you create a marker. So 'ib' refers to the infobox created for that marker and not the others.
You need to set the infobox variable outside the createMarker function scope. Then inside your event listener, close the old infobox and then create a new one.
var ib;
function createMarker(<params>) {
google.maps.event.addListener(marker, "click", function (e) {
if (typeof ib === 'object') {
ib.close();
}
ib = new Infobox();
ib.setOptions(myOptions_click);
ib.open(map, this);
});
}
If you need a new infobox for each marker, then you could store an array of infoboxes.
var ibs = [];
var closeInfoBox = function() {
for (var i in ibs) {
ibs[i].close();
}
}
function createMarker(<params>) {
var ibIndex = ibs.push(new Infobox()) - 1,
ib = ibs[ibIndex];
google.maps.event.addListener(marker, "click", function (e) {
closeInfoBox();
ib.setOptions(myOptions_click);
ib.open(map, this);
});
}
I was able to create a qtip2 on dayClick (fullcalendar) and it saves data for that event. Now I am trying to click on the event to have qtip2 load up again, but nothing happens. I have set editable to false (otherwise eventClick would never work).
I would like to be able to re-open a qtip2 event so it can be edited....thanks in advance
(NOTE: the DayClick qtip2 works great)
$('#calendar').fullCalendar({
// put your options and callbacks here
aspectRatio: 1.3,
editable: false,
draggable: true,
selectable: true,
selectHelper: true,
unselectAuto: false,
disableResizing:true,
header: {
right: 'today prev,next',
center: 'title',
left: 'agendaDay,agendaWeek,month'
},
events: "json_events.php",
eventClick: function(event, jsEvent, view) {
//alert(event.title);
$(this).qtip({
content: {
title: { text: event.title },
text: "<span class='title'>Start: </span>" + ($.fullCalendar.formatDate(event.start, 'hh:mmtt')) + "<br><span class='title'>Description: </span>" + event.description + "<br /><input type='button' value='Update' class='button' />"
},
position: {
at: 'top center',
// Position the tooltip above the link
my: 'bottom center',
adjust: {
y: -2,
resize: false // We'll handle it manually
},
viewport: calendar,
container: calendar
},
show: {
solo: true
},
style: {
width: 200,
padding: 5,
color: 'black',
textAlign: 'left',
border: {
width: 1,
radius: 3
},
tip: 'bottom-middle',
classes: 'daytooltip ui-tooltip-dark ui-tooltip-shadow',
tip: {
width: 20, height: 8
}
}
}); //element.qtip
},
dayClick: function(date, allDay, jsEvent, view) {
var month=new Array();
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
var monthNum=new Array();
monthNum[0]="01";
monthNum[1]="02";
monthNum[2]="03";
monthNum[3]="04";
monthNum[4]="05";
monthNum[5]="06";
monthNum[6]="07";
monthNum[7]="08";
monthNum[8]="09";
monthNum[9]="10";
monthNum[10]="11";
monthNum[11]="12";
var allday = "<label for='allday'><input type='checkbox' id='allday' onClick='enabledisable(this.checked)' /><span>All Day Event</span></label>"
var thisDay = month[date.getMonth()] + '/' + date.getDate() + '/' + date.getFullYear();
var thisDayDBFormat = date.getFullYear() + '-' + monthNum[date.getMonth()] + '-' + date.getDate();
var sHours = "<select id='startTimeHour' name='startTimeHour' class='dropdown-menu-time-qtip' >" +
"<option value='01'>01</option>" +
"<option value='02'>02</option>" +
"<option value='03'>03</option>" +
"<option value='04'>04</option>" +
"<option value='05'>05</option>" +
"<option value='06' selected>06</option>" +
"<option value='07'>07</option>" +
"<option value='08'>08</option>" +
"<option value='09'>09</option>" +
"<option value='10'>10</option>" +
"<option value='11'>11</option>" +
"<option value='12'>12</option>" +
"</select>";
var sMins = "<select id='startTimeMin' name='startTimeMin' class='dropdown-menu-time-qtip' >" +
"<option value='00' selected>00</option>" +
"<option value='15'>15</option>" +
"<option value='30'>30</option>" +
"<option value='45'>45</option>" +
"</select>";
var sAM_PM = "<select id='startTimeAMPM' name='startTimeAMPM' class='dropdown-menu-time-qtip' >" +
"<option value='AM'>AM</option>" +
"<option value='PM' selected>PM</option>" +
"</select>";
var eHours = "<select id='endTimeHour' name='endTimeHour' class='dropdown-menu-time-qtip' >" +
"<option value='01'>01</option>" +
"<option value='02'>02</option>" +
"<option value='03'>03</option>" +
"<option value='04'>04</option>" +
"<option value='05'>05</option>" +
"<option value='06'>06</option>" +
"<option value='07' selected>07</option>" +
"<option value='08'>08</option>" +
"<option value='09'>09</option>" +
"<option value='10'>10</option>" +
"<option value='11'>11</option>" +
"<option value='12'>12</option>" +
"</select>";
var eMins = "<select id='endTimeMin' name='endTimeMin' class='dropdown-menu-time-qtip' >" +
"<option value='00' selected>00</option>" +
"<option value='15'>15</option>" +
"<option value='30'>30</option>" +
"<option value='45'>45</option>" +
"</select>";
var eAM_PM = "<select id='endTimeAMPM' name='endTimeAMPM' class='dropdown-menu-time-qtip' >" +
"<option value='AM'>AM</option>" +
"<option value='PM' selected>PM</option>" +
"</select>";
$(this).qtip({
overwrite: true,
content: {
title: {
text: 'Create Event / Add Menu Item: ', // + month[date.getMonth()] + '/' + date.getDate() + '/' + date.getFullYear(),
button: true
},
//text: $('#fxx').html() // this html was on the form
//text: "<span id='event-create' ><ul><li><input type='checkbox' />All Day</li><li><input type='radio' />input:radio</li><li><select><option>Select</option><option>Foo</option><option>Bar</option></select></li><li></li><li><input type='text' value=" + month[date.getMonth()] + '/' + date.getDate() + '/' + date.getFullYear() + "/></li><li><textarea>textarea</textarea></li></ul><input type='button' class='button' value='Create Event' /></span>"
text: "<div id='event-create'>" +
"<fieldset>" +
"Create a Generic Event OR add a Menu (meal) Event from your Personal Menu!" +
"<br />" +
"<label>When:</label><span>" + thisDay + "</span>" +
"<br />" +
"<form action='.' method='post' name='create_event'>" +
"<input type='hidden' name='action' value='save_event' />" +
"<input type='hidden' name='eventDate' value='" + thisDayDBFormat + "' />" +
"<label for='eventName'>Name:</label><input type='text' name='eventName' value='' title='Letters, numbers, and underscore!' size='30' />" +
"<br />" +
"<label for='eventLocation'>Location:</label><input type='text' name='eventLocation' value='' title='Letters, numbers, and underscore!' size='30' />" +
"<div id='event-create-time'>" +
"<input type='checkbox' name='eventAllDay' onClick='enabledisable(this.checked)' /><span> All Day Event</span><br />" +
"Start: " + sHours + " " + sMins + " " + sAM_PM + "<br />" +
"End: " + eHours + " " + eMins + " " + eAM_PM +
"</div>" +
"<br />" +
"<input type='submit' id='event-button' name='btnSaveGenericEvent' class='button150' value='Create Generic Event' />" +
"<input type='submit' id='event-button' name='btnSaveMenuEvent' class='button150' value='Create Menu Event' />" +
"</form>" +
"</fieldset>" +
"</div>"
//"<a href='#' onclick=" + '"' + "document['my_personal_menu'].submit()" + '"' + " >My Personal Menu >></a>" +
},
position: {
at: 'top center',
// Position the tooltip above the link
my: 'bottom center',
adjust: {
y: -2,
resize: false // We'll handle it manually
},
viewport: calendar,
container: calendar
},
// NOTE: originally, tooltip opened as modal (gray background) and had to close with 'x' button
// Settings were "show: Modal: on: true AND hide: 'false'
//
// To have tooltip popup on each day click AND have any previous tooltip go away (like google calendar)
// Settings "show: modal: on: false AND hide: 'true'"
show: {
ready: true,
event: false,
modal: {
// 'true' = Make it modal (darken the rest of the page)...
on: false,
blur: false // ... but don't close the tooltip when clicked
}
},
// 'false' = does not hide when clicking outside
// 'unfocus' = will hide when clicking outside tooltip IF modal 'on: false' (above)
hide: 'unfocus',
style: {
classes: 'daytooltip ui-tooltip-dark ui-tooltip-shadow ui-tooltip-default width400',
tip: { width: 20, height: 8 }
}
})
.qtip('show');
}
I had the same problem and found a solution from Craig:
Try attaching a qTip with overwrite set to false, and update its content at the end of the call:
$('#calendar').fullCalendar({
eventClick: function(calEvent, jsEvent, view) {
$(this).qTip({
overwrite: false,
content: 'Loading...',
show: { ready: true }
})
.qtip('option', 'content.text', newContent);
}
});