WordPress.org

Ready to get started?Download WordPress

Forums

CGM Event Calendar
Google map (2 posts)

  1. vampireprincess
    Member
    Posted 3 years ago #

    Hi this is a fantastic plugin ... I wandering have a chance to add google map with the events
    and can you add Event Link (Optional) option if I want to join an event to the external link

    thank you very much

    http://wordpress.org/extend/plugins/cgm-event-calendar/

  2. tugbucket
    Member
    Posted 3 years ago #

    This is from a text file I have, more notes to self.

    Hope it helps.

    ____________________________________________

    Of course I had to add the gmap column to the DB but that's pretty straight forward.

    I changed the location section on the page display to:
    _______________________________________________________

    if (isset($entry['location']) && $entry['location'] != '') {
    				echo '<p><strong>'.__('Location', 'cgm_event_calendar').'</strong><br />';
    				echo $entry['location'];
    			}
    			if (isset($entry['gmap']) && $entry['gmap'] != '') {
    				echo ' | <small><a href="'.$entry['gmap'].'" target="_blank">View Map</a></small>';
    			}
    			if (isset($entry['location']) && $entry['location'] != '') {
    				echo '</p>';
    			}

    I added this hook to the very end:
    ___________________________________

    // tugbucket gmap addition
    	add_action('admin_footer', 'gmap_functionality');
    	function gmap_functionality(){
    		include('gmap.php');
    	}

    below is the gmap.php:
    __________________________________

    <?php echo "\n\n"; ?>
    <!-- tugbucket gmap function -->
    <script src="http://maps.google.com/maps?file=api&v=2&key=" type="text/javascript"></script>
    <script src="http://www.google.com/uds/api?file=uds.js&v=1.0" type="text/javascript"></script>
    <script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js" type="text/javascript"></script>
    
    <style type="text/css">
    @import url("http://www.google.com/uds/css/gsearch.css");
    @import url("http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
    .gmls-more-results, .gmls-result-wrapper .gs-result .gs-directions-to-from { display: none; }
    </style>
    
    <div id="gmapHolder" style="border: 1px solid #000; background: #fff; width: 750px; position: absolute; z-index: 9999; top: -700px; left: 50%; margin-left: -376px;">
    <div id="map_canvas" style="width: 750px; height: 470px;"></div>
        <p style="text-align: center; padding: 2px 0 10px 0;">If the location in the bubble above is correct <a href="#x" id="linkGetter" onclick="return false;">click here</a>. You may aslo <a href="#x" id="linkGetterCancel" onclick="return false;">cancel the map</a>.</p>
    </div>
    
    <script type="text/javascript">
    //<![CDATA[
    jQuery(document).ready(function() {
    	var mapLink = "<a href='#x' id='gmapCreate' onclick='return false;'><img src='<?php echo get_bloginfo('siteurl')?>/wp-content/plugins/cgm-event-calendar/images/gmap.gif' border='0' width='30' height='24' /></a><input type='hidden' name='gmapURL' id='gmapURL' />";
    	jQuery("#gmapCreate").live("click", function(){
    		jQuery("#gmapHolder").animate({top: "40"}, 1000);
    	});
    	jQuery("#entry_location").parent("td").append(mapLink);
    	jQuery("#linkGetter").click(function(){
    		gmapLinkValue = jQuery('#gmapHolder #map_canvas a.gs-title').attr('href');
    		jQuery("input#gmapURL").val(gmapLinkValue.replace("/place", ""));
    		jQuery("#gmapHolder").animate({top: "-700"}, 1000);
    		if(jQuery(".mapAdded").length){
    			jQuery(".mapAdded").text("Map Updated!");
    		} else {
    			jQuery("#entry_location").parent("td").append("<span class='mapAdded'> Map Added!</span>");
    		}
    	});
    	jQuery("#linkGetterCancel").click(function(){
    		jQuery("input#gmapURL").val('');
    		jQuery("#gmapHolder").animate({top: "-700"}, 1000);
    	});
    });
    
    function initialize() {
      if (GBrowserIsCompatible()) {
    
        // Create and Center a Map
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(35.14, -89.95), 11);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
    
        // bind a search control to the map, suppress result list
        map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));
      }
    }
    GSearch.setOnLoadCallback(initialize);
    
    initialize()
    
    //]]>
    </script>
    
    <?php echo "\n\n"; ?>

    The manual additon is the starting point:
    ___________________________________________

    map.setCenter(new GLatLng(35.14, -89.95), 11);

    Since I am in Memphis and the site I am using this on is based in Memphis as well, the lat/lon is hardcoded for Memphis.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic