I have a problem with calendar,I want to paint special days different color For example
On calendar
03.06.2011 Day--->blue
04.06.2011 day---->red
12.06.2011-04.07.2011 Days ----> yellow
More than one color I want to use selected day
You can use javascript to do that,
Refer to JSFiddle Here
You can add custom special day,
$(document).ready(function () {
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-07-04',
editable: true,
events: [{
title: 'All Day Event',
start: '2014-07-01'
}, {
title: 'Long Event',
start: '2014-07-07',
end: '2014-07-10'
}, {
id: 999,
title: 'Repeating Event',
start: '2014-07-09T16:00:00'
}, {
id: 999,
title: 'Repeating Event',
start: '2014-07-16T16:00:00'
}, {
title: 'Meeting',
start: '2014-07-12T10:30:00',
end: '2014-07-12T12:30:00'
}, {
title: 'Lunch',
start: '2014-07-12T12:00:00'
}, {
title: 'Birthday Party',
start: '2014-07-13T07:00:00'
}, {
title: 'Click for Google',
url: 'http://google.com/',
start: '2014-07-28'
}],
eventAfterAllRender: function (view) {
//Use view.intervalStart and view.intervalEnd to find date range of holidays
//Make ajax call to find holidays in range.
var fourthOfJuly = moment('2014-07-04','YYYY-MM-DD');
var holidays = [fourthOfJuly];
var holidayMoment;
for(var i = 0; i < holidays.length; i++) {
holidayMoment = holidays[i];
if (view.name == 'month') {
$("td[data-date=" + holidayMoment.format('YYYY-MM-DD') + "]").addClass('holiday');
} else if (view.name =='agendaWeek') {
var classNames = $("th:contains(' " + holidayMoment.format('M/D') + "')").attr("class");
if (classNames != null) {
var classNamesArray = classNames.split(" ");
for(var i = 0; i < classNamesArray.length; i++) {
if(classNamesArray[i].indexOf('fc-col') > -1) {
$("td." + classNamesArray[i]).addClass('holiday');
break;
}
}
}
} else if (view.name == 'agendaDay') {
if(holidayMoment.format('YYYY-MM-DD') == $('#calendar').fullCalendar('getDate').format('YYYY-MM-DD')) {
$("td.fc-col0").addClass('holiday');
};
}
}
}
});
});
For changing the colour, you can edit background on .holiday in css file
body {
margin: 0;
padding: 50px 0 0 0;
font-family:"Lucida Grande", Helvetica, Arial, Verdana, sans-serif;
font-size: 14px;
}
#calendar {
width: 100%;
}
.holiday {
background: lightgray;
}
Hope it can help you
Related
i created a new MVC asp.Net webpage and for testing i added Fullcalendar 5.1.
For testing i put all the stuff in index.html:
<!DOCTYPE html>
<html lang='en'>
<head>
<link rel="stylesheet" href="~/lib/fullcalendar/main.css" />
<script src="~/lib/fullcalendar/main.js"></script>
<meta charset='utf-8' />
<style>
.fc-sun {
background-color: blue;
}
.fc-sat {
background-color: red;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
initialDate: '2020-07-07',
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
events: [
{
title: 'All Day Event',
start: '2020-07-01'
},
{
title: 'Long Event',
start: '2020-07-07',
end: '2020-07-10'
},
{
groupId: '999',
title: 'Repeating Event',
start: '2020-07-09T16:00:00'
},
{
groupId: '999',
title: 'Repeating Event',
start: '2020-07-16T16:00:00'
},
{
title: 'Conference',
start: '2020-07-11',
end: '2020-07-13'
},
{
title: 'Meeting',
start: '2020-07-12T10:30:00',
end: '2020-07-12T12:30:00'
},
{
title: 'Lunch',
start: '2020-07-12T12:00:00'
},
{
title: 'Meeting',
start: '2020-07-12T14:30:00'
},
{
title: 'Birthday Party',
start: '2020-07-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2020-07-28'
}
]
});
calendar.render();
});
</script>
</head>
<body>
<div id='calendar'></div>
</body>
</html>
But the backcolor wont change :-(
if i put some other variables in like this:
.fc .fc-col-header-cell-cushion { /* needs to be same precedence */
padding-top: 10px; /* an override! */
padding-bottom: 21px; /* an override! */
}
the header padding changes.
What iam doing wrong?
the fiddle is the example: http://jsfiddle.net/rajesh13yadav/nf9whojL/1/
Can you please help me?
EDIT:
As a workaround i use this:
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
initialDate: '2020-07-07',
businessHours: {
// days of week. an array of zero-based day of week integers (0=Sunday)
dow: [1, 2, 3, 4, 5], // Monday - Friday
start: '00:00', // a start time (09am in this example)
end: '00:00', // an end time (6pm in this example)
},
and the style is:
<style>
.fc .fc-non-business {
color: red;
background: green;
opacity: 0.1;
}
</style>
But why i cant set the other properties?
In version 5.1 the classes are .fc-day-sat and fc-day-sun
Setting the background-color for those classes works fine.
I have a chart with daily values of the month of October.
Two buttons: week and month.
Week plotband has to be identical with month plotband: First 2 days are green, next 5 days are blue in month plotband. When selecting week, the range date 1-7 should be same colour green and blue.
Highcharts.chart('container', {
chart: {
type: 'column',
},
title: {
text: 'How long time a TR has been placed in stages longer than 48 hours'
},
legend: {
enabled: true
},
subtitle: {
text: 'Input - verify should max be 48 hours = green zone'
},
data: {
csv: document.getElementById('csv').innerHTML
},
plotOptions: {
column: {
},
series: {
dataLabels: {
enabled: false,
format: '{point.y}'
}
}
},
tooltip: {
},
rangeSelector: {
buttonSpacing: 10,
enabled: true,
inputEnabled: false,
selected: 1,
buttons: [{
type: 'week',
count: 1,
text: 'Week'
}, {
type: 'month',
count: 1,
text: 'Month'
}],
},
xAxis: [{
id: 'one',
type: 'datetime',
dateTimeLabelFormats: {
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'
},
plotBands: [{
from: 1538352000000,
to: 1538524800000,
color: '#E8F5E9'
}, {
from: 1538524800000,
to: 1538870400000,
color: '#E0ECEC'
}, {
from: 1538870400000,
to: 1539475200000,
color: "#FFFDE7"
}, {
from: 1539475200000,
to: 1540944000000,
color: "#FFEBEE"
}],
}, {
id: 'two',
type: 'datetime',
dateTimeLabelFormats: {
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'
},
plotBands: [{
from: 1538352000000,
to: 1538524800000,
color: '#E8F5E9'
}, {
from: 1538524800000,
to: 1538870400000,
color: '#E0ECEC'
}],
}],
yAxis: {
min: 0,
max: 100,
title: {
text: 'TRADING RECORDS',
}
}
});
Please see jsfiddle
Is there a way to toggle between two xaxis with different plotBands: when clicking on the 'week' button, one plotband will display and when clicking on the 'month' button another plotband will display. So the colours of the plotband is relative to the dates?
I assume I have to use event functions like setExtremes and afterSetExtremes, but not sure how to do it?
Thanks much appreciated for help.
I managed to simulate the output with this function:
events: {
afterSetExtremes: function (e) {
if (e.trigger == "rangeSelectorButton" &&
e.rangeSelectorButton.text == "Week") {
// it is your button that caused this,
// so setExtrememes to your custom
// have to do in timeout to let
// highcharts finish processing events...
setTimeout(function () {
Highcharts.charts[0].xAxis[0].setExtremes(1538352000000, 1538524800000)
}, 1);
}
},
}
But it only work when selecting specific: setExtremes(1538352000000, 1538524800000)
I think a scaleable solution for any 7 days would require some sort of exception functionality for remove current plotband on xaxis with addplotband
Updated fiddle
I added custom buttons instead: https://forum.highcharts.com/viewtopic.php?t=31649
<div class="btn-group" data-toggle="buttons">
<button class="btn btn-custom" id="one">48 hours</button>
<button class="btn btn-custom" id="two">7 days</button>
<button class="btn btn-custom" id="three">14 days</button>
<button class="btn btn-custom" id="four">31 days</button>
<button class="btn btn-custom" id="all">All</button>
</div>
<div id="containerbenchmark"></div>
$.get('bm.csv', function (bmcsv) {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'containerbenchmark',
type: 'areaspline',
},
title: {
text: ''
},
legend: {
enabled: true
},
subtitle: {
text: 'Input - verify - close should max be 48 hours = green zone'
},
data: {
csv: bmcsv,
},
plotOptions: {
areaspline: {
stacking: 'normal'
},
series: {
dataLabels: {
enabled: false,
format: '{point.y}'
}
}
},
tooltip: {
/*headerFormat: '<span style="font-size: 16px">{point.key}</span><br/>',
pointFormat: '<span style="font-size: 14px; color:{series.color}">{series.name}: <span style="font-size: 14px">{point.y} {point.total}</span><br/>',
footerFormat: '<span style="font-size: 16px">{point.total}</span><br/>',*/
shared: true,
useHTML: true,
formatter: function () {
var tooltip = '<table><span style="font-size: 16px">' + Highcharts.dateFormat('%e/%b/%Y',
new Date(this.x)) + '</span><br/><tbody>';
//loop each point in this.points
$.each(this.points, function (i, point) {
tooltip += '<tr><th style="font-size: 14px; color: ' + point.series.color + '">' + point.series.name + ': </th>' +
'<td style="font-size: 14px; text-align: right">' + point.y + '</td></tr>'
});
tooltip += '<tr><th style="font-size: 16px">Total: </th>' +
'<td style="font-size: 16px; text-align:right"><span>' + this.points[0].total + '</span></td></tr>' +
'</tbody></table>';
return tooltip;
}
},
rangeSelector: {
selected: 2,
enabled: true,
inputEnabled: true,
inputDateFormat: "%m/%d/%Y",
inputEditDateFormat: "%m/%d/%Y",
inputDateParser: function (s) {
return Date.UTC(
parseInt(s.substr(6, 4)),
parseInt(s.substr(0, 2) - 1),
parseInt(s.substr(3, 2)),
12
)
}
},
navigator: {
enabled: true
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'
},
plotBands: [{
from: 1538352000000,
to: 1538524800000,
color: '#cae8cc',
label: {
text: '> 48 hours',
style: {
color: 'black',
fontWeight: 'bold',
textTransform: 'uppercase',
fontSize: '14px'
}
}
}, {
from: 1538524800000,
to: 1538870400000,
color: '#d0e2e2',
label: {
text: '> 7 days',
style: {
color: 'black',
fontWeight: 'bold',
textTransform: 'uppercase',
fontSize: '14px'
}
}
}, {
from: 1538870400000,
to: 1539475200000,
color: "#fff9b3",
label: {
text: '> 14 days',
style: {
color: 'black',
fontWeight: 'bold',
textTransform: 'uppercase',
fontSize: '14px'
}
}
}, {
from: 1539475200000,
to: 1540944000000,
color: "#ffb3be",
label: {
text: '> 31 days',
style: {
color: 'black',
fontWeight: 'bold',
textTransform: 'uppercase',
fontSize: '14px'
}
}
}],
},
yAxis: {
min: 0,
title: {
text: 'TRADING RECORDS',
}
}
}, function (chart) {
// apply the date pickers
setTimeout(function () {
var rangeSelector = $('#containerbenchmark input.highcharts-range-selector');
rangeSelector.datepicker({
autoclose: true,
todayHighlight: true
}) /*.datepicker('update', new Date())*/ ;
var inputMin = rangeSelector.filter('[name=min]');
var inputMax = rangeSelector.filter('[name=max]');
inputMin.datepicker().on("changeDate", function (event) {
console.log(inputMin.datepicker("getDate"));
console.log(inputMin.datepicker("getUTCDate"));
});
}, 1000);
});
$('#one').click(function () {
toggleActiveState(false);
chart.xAxis[0].setExtremes(
1538352000000,
1538524800000
);
});
$('#two').click(function () {
toggleActiveState(false);
chart.xAxis[0].setExtremes(
1538524800000,
1538870400000
);
});
$('#three').click(function () {
toggleActiveState(false);
chart.xAxis[0].setExtremes(
1538870400000,
1539475200000
);
});
$('#four').click(function () {
toggleActiveState(false);
chart.xAxis[0].setExtremes(
1539475200000,
1540944000000
);
});
$('#all').click(function () {
chart.xAxis[0].setExtremes(
event.min,
event.max
);
});
});
how do I make the background of the main panel a certain color?
I have tried a few things and it looks like one of my components is in front of.
Its basically the background of MainDetailsPanel that I want to change color but it looks like every object is in front of and blocking.
Any thoughts?
Ext.define('ExtApplication1.view.clientdetails.clientdetails',{
extend: 'Ext.panel.Panel',
alias: 'widget.clientdetails',
itemId: 'clientDetailsItemID',
reference: 'clientDetailsPanel',
id: 'clientDetailsViewID',
requires: [
'ExtApplication1.view.clientdetails.clientdetailsController',
'ExtApplication1.view.clientdetails.clientdetailsModel'
],
controller: 'clientdetails-clientdetails',
viewModel: { type: 'clientdetails-clientdetails' },
//ui: 'dark',
//frame: true,
//bodyStyle: {
// 'background-image': 'linear-gradient(#3a3535, #333333)',
// padding: '10px'
//},
//ui: 'darkbackground',
bodyStyle: { "background-color": "yellow" },
layout: {
type: 'vbox',
pack: 'start',
align: 'stretch'
},
items: [{
layout: 'column',
height: 80,
bodyStyle: { "background-color": "red" },
items: [{
columnWidth: .4,
items: [{
layout: 'column',
defaults: {
layout: 'form',
xtype: 'container',
style: 'width: 50%;'
},
items: [{
items: [{
xtype: 'displayfield',
fieldLabel: 'Client',
bind: { value: '{selectedClientListModel.ClientName}'},
fieldStyle: 'padding: 0px; margin: 0px;',
labelStyle: 'padding: 0px; margin: 0px;'
//ui: 'dark'
},{
xtype: 'displayfield',
fieldLabel: 'Acct Desc',
itemId: 'textfieldAcctDesc',
bind: { value: '{selectedManager.AcctShortCode}' },
fieldStyle: 'padding: 0px; margin: 0px;',
labelStyle: 'padding: 0px; margin: 0px;'
},{
xtype: 'displayfield',
fieldLabel: 'Acct Num',
itemId: 'textfieldAcctNum',
bind: { value: '{selectedManager.AcctNum}' },
fieldStyle: 'padding: 0px; margin: 0px;',
labelStyle: 'padding: 0px; margin: 0px;'
}]
},{
items: [{
xtype: 'displayfield',
fieldLabel: 'Client P&L',
id: 'displayfieldClientPL',
itemId: 'displayfieldClientPLItemId',
fieldStyle: 'padding: 0px; margin: 0px;',
labelStyle: 'padding: 0px; margin: 0px;',
renderer: function (value) {
var newVal = Ext.util.Format.currency(value, '$ ', 0);
if (value > 0) {
newVal = '<span style="color:green">' + newVal + '</span>';
} else if (value < 0) {
newVal = '<span style="color:red">' + newVal + '</span>';
} else {
newVal = newVal;
}
return newVal;
}
},{
xtype: 'displayfield',
fieldLabel: 'Account P&L',
itemId: 'displayfieldAccountPL',
fieldStyle: 'padding: 0px; margin: 0px;',
labelStyle: 'padding: 0px; margin: 0px;',
renderer: function (value) {
var newVal = Ext.util.Format.currency(value, '$ ', 0);
if (value > 0) {
newVal = '<span style="color:green">' + newVal + '</span>';
} else if (value < 0) {
newVal = '<span style="color:red">' + newVal + '</span>';
} else {
newVal = newVal;
}
return newVal;
}
}]
}]
}]
}]
}]
})
I am trying to understand full calendar.. i don't know how to use methods like selection or colour. Could any one please give me a example for colour my each event day by different colour .and on clicking over the day tile a message should ask us to add a event.
I had read http://fullcalendar.io/docs/ but can't understand .how to change that.
<link href="~/Content/calendar/fullcalendar.css" rel="stylesheet" />
<link href="~/Content/calendar/fullcalendar.print.css" rel="stylesheet" media='print' />
<link href="~/Content/jquery-ui.min.css" rel="stylesheet" />
<style>
body {
margin: 40px 10px;
padding: 15px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
font-size: 14px;
}
#calendar {
max-width: 900px;
margin: 0 auto;
}
</style>
<div id='calendar'></div>
#section scripts{
<script src="~/Scripts/calendar/moment.min.js"></script>
<script src="~/Scripts/calendar/jquery.min.js"></script>
<script src="~/Scripts/calendar/fullcalendar.min.js"></script>
<script src="~/Scripts/calendar/jquery-ui.custom.min.js"></script>
<script>
$(document).ready(function () {
$('#calendar').fullCalendar(Duration,'00:30:00');
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2015-02-12',
selectable: true,
selectHelper: true,
select: function (start, end) {
var title = prompt('Event Title:');
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true
}
$('#calendar').fullCalendar('unselect');
},
slotDuration:'00:00:15',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2015-02-01'
},
{
title: 'Long Event',
start: '2015-02-07',
end: '2015-02-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2015-02-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2015-02-16T16:00:00'
},
{
title: 'Conference',
start: '2015-02-11',
end: '2015-02-13'
},
{
title: 'Meeting',
start: '2015-02-12T10:30:00',
end: '2015-02-12T12:30:00'
},
{
title: 'Lunch',
start: '2015-02-12T12:00:00'
},
{
title: 'Meeting',
start: '2015-02-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2015-02-12T17:30:00'
},
{
title: 'Dinner',
start: '2015-02-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2015-02-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2015-02-28'
}
]
});
});
</script>
}
The following code is used to give colors to different events in fullcalender.
{
title: 'All Day Event',
start: '2015-02-01',
backgroundColor: '#000'
},
{
title: 'Long Event',
start: '2015-02-07',
end: '2015-02-10',
backgroundColor: '#DDD'
},
{
id: 999,
title: 'Repeating Event',
start: '2015-02-09T16:00:00',
backgroundColor: '#CCC'
},
give a backgroundColor parameter with color code to particular event.
and following code is used, if you want to open a popup for a new event when you click on the event title.
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultView: '<?php echo $view; ?>',
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
$.ajax({
url:"<?php echo site_url("controller/function_name");?>/"+convert_date(start),
cache:false,
data:"event_name="+convert_date(start),
success:function(data){
//alert(data);
if(data=="holiday" || data=="no"){
$( ".modalbox" ).on( "click", function() {
});
//$("#day_"+convert_date(start)).css("background-color","#f00");
$("#event_date").val(start);
summary();
summary_change($("#reminder").val());
//$("#date_of_end").val(convert_date_mdy(start));
//$("#summary_date").val(convert_date_mdy(start));
}
else{
$( ".modalbox" ).on( "click", function() {
});
$( ".modalbox" ).trigger( "click" );
$("#event_date").val(start);
summary();
summary_change($("#reminder").val());
//$("#date_of_end").val(convert_date_mdy(start));
//$("#summary_date").val(convert_date_mdy(start));
}
}
});
$("#addSchedule").submit(function(){
title=$("#shift").val();
if (title!="") {
date=convert($("#event_date").val());
end_date=convert(end);
$("#event_date").val(date);
$("#end_date").val(end_date);
$("#allDay").val(allDay);
calendar.fullCalendar('renderEvent',
{
title: title,
start:$("#event_date").val(),
end: end,
allDay: allDay
},
);
}
$("#holder").hide();
//return false;
});
calendar.fullCalendar('unselect');
},
editable: true,
events: <?php echo $result;?>,
eventClick: function(event) {
$.ajax({
url:"<?php echo site_url("controller/function_name");?>/"+event.event_id,
cache:false,
data:"event_name="+event.title,
success:function(data){
$("#inline1").html(data);
$( ".modalbox1" ).on( "click", function() {
});
$( ".modalbox1" ).trigger( "click" );
}
});
},
});
eventClick parameter will be in act, when you click on particular event on fullcalender.
I've looked through a lot of the similar questions on here, but have not found anything that will answer my question. I am new to JS and GoogleMaps API v3, and have successfully followed their tutorials to get this far. However, I'd like to have an infowindow with custom content appear based on which marker is clicked, and I cannot figure out how to do this. I'd also like to have this be possible with around 100 markers, so I'd like to know the best way to do this as well without things getting too messy. To be clear, there are 3 types of icons, but there will eventually be many markers associated with each icon, so I will need content linked to each "feature". Hopefully I've got a good start here and am not way off base. I've included the code for the page. Thank you so much in advance for any help anyone can provide.
<!DOCTYPE html>
<html>
<head>
<style>
#map_canvas {
width: 800px;
height: 500px;
background-color:#CCC;
}
#legend {
font-family: Arial, sans-serif;
background: #fff;
padding: 10px;
margin: 10px;
border: 3px solid #000;
}
#legend img {
vertical-align: middle;
}
</style>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
function initialize() {
var map_canvas = document.getElementById('map_canvas');
var map_options = {
center: new google.maps.LatLng(33.137551,-0.703125),
zoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(map_canvas, map_options);
map.set('styles', [
{
featureType: 'road',
elementType: 'geometry',
stylers: [
{ color: '#888888' },
{ weight: 1.0 }
]
}, {
featureType: 'landscape',
elementType: 'geometry.fill',
stylers: [
{ hue: '#008f11' },
{ gamma: 1.0 },
{ saturation: 0 },
{ lightness: -10 }
]
}, {
featureType: 'water',
elementType: 'geometry.fill',
stylers: [
{ hue: '#054d8fd' },
{ gamma: 1.0 },
{ saturation: 0 },
{ lightness: -10 }
]
}, {
featureType: 'poi',
elementType: 'geometry',
stylers: [
{ visibility: 'off' }
]
}
]);
var iconBase = 'http://i1318.photobucket.com/albums/t658/greatergoodorg/';
var icons = {
people: {
name: 'People',
icon: iconBase + 'people_zps26d13009.png',
shadow: iconBase + 'shadow-people_zps4b39eced.png'
},
pets: {
name: 'Pets',
icon: iconBase + 'pets_zps15f549f2.png',
shadow: iconBase + 'shadow-pets_zps361068aa.png'
},
planet: {
name: 'Planet',
icon: iconBase + 'planet_zps2a8572ce.png',
shadow: iconBase + 'shadow-planet_zps9912e26b.png',
}
};
var data = ["This is the first one", "This is the second one", "This is the third one"];
function addMarker(feature) {
var marker = new google.maps.Marker({
position: feature.position,
icon: icons[feature.type].icon,
shadow: {
url: icons[feature.type].shadow,
anchor: new google.maps.Point(21, 32)
},
animation: google.maps.Animation.DROP,
map: map
});
/*...
google.maps.event.addListener(marker, "click", function () {
infowindow.open(map,marker);
});
...*/
/*...
google.maps.event.addListener(marker, 'click', function() {
map.setZoom(8);
map.setCenter(marker.getPosition());
});
...*/
}
var features = [
{
position: new google.maps.LatLng(33.137551,-0.703125),
type: 'planet'
},
{
position: new google.maps.LatLng(44.234234,-0.232233),
type: 'pets'
},
{
position: new google.maps.LatLng(54.234234,-0.032233),
type: 'people'
}
];
for (var i = 0, feature; feature = features[i]; i++) {
addMarker(feature);
}
var legend = document.getElementById('legend');
for (var key in icons) {
var type = icons[key];
var name = type.name;
var icon = type.icon;
var div = document.createElement('div');
div.innerHTML = '<img src="' + icon + '"> ' + name;
legend.appendChild(div);
}
map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(
document.getElementById('legend'));
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map_canvas"></div>
<div id="legend"><strong>Project Types</strong></div>
</body>
</html>
This will open an infowindow and display the "type" string in it
var infowindow = new google.maps.InfoWindow();
function addMarker(feature) {
var marker = new google.maps.Marker({
position: feature.position,
icon: icons[feature.type].icon,
shadow: {
url: icons[feature.type].shadow,
anchor: new google.maps.Point(21, 32)
},
animation: google.maps.Animation.DROP,
map: map
});
google.maps.event.addListener(marker, "click", function () {
infowindow.setContent(feature.type);
infowindow.open(map,marker);
});
}