I’m trying to work out whether it is possible to change the icon based on whether the date associated with the marker matches todays
For example, I have a series of events for which I wish to show the location of on a google map (the data is loaded as a fusion-table). I wish to show all of these events but I wish to have a different icon for those events which match the date on which the map is loaded.
Does anyone know of any examples which demonstrate this? I’ve had a good search but can’t find anything.
Update:
I’ve come back to this after working on other stuff but still can’t get this to work well. The code posted above works well to create the current date string, but I am then not getting any query that tries to use this string/var to work. I think I must be missing something very obvious, as when I input a date manually into the query everything works as it should.
I’ve pasted my code snippet below…would be grateful if someone could point out what might be wrong.
var d = new Date();
var mon = d.getMonth() + 1;
var day = d.getDate();
var year = d.getFullYear();
var date_string = '';
if(mon < 10){
date_string += "0" + mon; }else{
date_string += mon; }
date_string += '/'; if(day < 10){
date_string += "0" + day; }else{
date_string += day; }
date_string += '/'; year -= 2000;
date_string += year;
alert(date_string);
layer = new google.maps.FusionTablesLayer({
query: {
select: 'Latitude',
from: '3xxxxxx'
},
styles: [{ markerOptions: { iconName: "measle_white" } },
{ where: "'Date' = 'date_string'",
markerOptions: { iconName: "wht_pushpin"} },
{where: "'Date' <= '05/07/12'",
markerOptions: { iconName: "measle_white" } }]
});
Well the question changed, see comment. But note that if you just want the current date, >= will work for the Fusion Table query, even if = does not.
}