WordPress.org

Ready to get started?Download WordPress

Forums

Google Calendar Widget
map link in "where" (6 posts)

  1. rodmusic
    Member
    Posted 2 years ago #

    How do I get the Google map link to show in an event location with this widget. It appears on a regular calendar embed, but not in the widget.

    Example: http://rodmusic.com/calendar

    I have the widget showing in both the page and the sidebar. Scroll down to the calendar grid and you'll see that it shows a map link in the location. This same map link doesn't show up in the widget feed. Any ideas?

    Thanks,
    Rod

    http://wordpress.org/extend/plugins/google-calendar-widget/

  2. Poco
    Member
    Plugin Author

    Posted 2 years ago #

    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;
    	}
  3. rodmusic
    Member
    Posted 2 years ago #

    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

  4. danielnichols
    Member
    Posted 2 years ago #

    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!

  5. danielnichols
    Member
    Posted 2 years ago #

    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!

  6. huubnl
    Member
    Posted 2 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic