WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Google Calendar Widget] map link in "where"

[Plugin: Google Calendar Widget] map link in "where"

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Poco
    Member

    @poco

    That’s a good question. There is no map link provided in the calendar API. We are getting the data accessible through the google.gdata.calendar.CalendarEntry object.

    However, it looks like all the calendar does is a standard Google Query with the location name.

    So with a name of “Kennedy Center”, the query is “http://maps.google.com/maps?hl=en&q=Kennedy%20Center”. It should be possible to create a (map) link in the location tag.

    The function buildLocation(entry) in ko-calendar.js is where the location string is compiled.

    Something like the following change might work, but I have not tested it. I may consider adding something like this in the future just to make it more consistent with the default calendar.

    function buildLocation(entry)
    	{
    		var locationDiv = document.createElement('div');
    		var locationString = entry.getLocations()[0].getValueString();
    		if (locationString != null)
    		{
    			locationDiv.appendChild(document.createTextNode(locationString));
    
    	//////
    	// Insert here
    	var link = document.createElement('a');
    	link.setAttribute('href', 'http://maps.google.com/maps?hl=en&q=' + locationString);
    	var map = document.createTextNode(' map');
    	link.appendChild(map);
    	locationDiv.appendChild(link);
    	//////
    
    			locationDiv.setAttribute('className','ko-calendar-entry-location-text');
    			locationDiv.setAttribute('class','ko-calendar-entry-location-text');
    		}
    
    		return locationDiv;
    	}

    Hi Poco,

    I tried this and it works fine! Thank you very much, and sorry for taking so long to get back to you.

    Rod

    danielnichols
    Participant

    @danielnichols

    this is great! thanks!

    how would i open the map link in a new tab or window?

    would i need something like …

    .setAttribute(‘target’, ‘_blank’);

    but how would this need altering etc to fit in?

    thanks!

    danielnichols
    Participant

    @danielnichols

    Have amended the code slightly to …

    locationDiv.appendChild(document.createTextNode(‘At ‘));

    //////
    // Insert here
    var link = document.createElement(‘a’);
    link.setAttribute(‘href’, ‘http://maps.google.com/maps?hl=en&q=’ + locationString);
    var map = document.createTextNode(locationString);
    link.appendChild(map);
    locationDiv.appendChild(link);
    //////

    This creates a line with “At ” and the adds the location string as the map link.

    Have a look at ‘http://waltonchurch.org/’!

    Would still like the new target though!

    Hi Daniel,

    I found out how to open it in a new window:

    //////
    	// Insert here
    	var link = document.createElement('a');
    	link.setAttribute('href', 'http://maps.google.com/maps?hl=en&q=' + locationString);
            link.setAttribute("target", "_blank");
    	var map = document.createTextNode(' map');
    	link.appendChild(map);
    	locationDiv.appendChild(link);
    	//////

    Good luck!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Google Calendar Widget] map link in "where"’ is closed to new replies.