Results 1 to 4 of 4

Thread: Make G Map infowindow appear on click, not automatically

  1. #1
    Thread Starter
    Member altor25's Avatar
    Join Date
    Jun 2011
    Location
    Canada
    Posts
    56
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question Make G Map infowindow appear on click, not automatically

    Hey, below is my gmap code. Does anyone know how to make the infowindow (and shadow) appear on click rather than automatically? Any help would be appreciated!

    PHP Code:
    <div id="gmap" class="mapblock">

        <?php
        
    // check to see if ad is legacy or not and then assemble the map address
        
    if ( get_post_meta($post->ID'location'true) )
            
    $make_address get_post_meta($post->ID'location'true);
        else
            
    $make_address get_post_meta($post->ID'cp_street'true) . '&nbsp;' get_post_meta($post->ID'cp_city'true) . '&nbsp;' get_post_meta($post->ID'cp_state'true) . '&nbsp;' get_post_meta($post->ID'cp_zipcode'true) . '&nbsp;' $text = ('Kingston, Ontario');
        
    ?>

        <script type="text/javascript">var address = "<?php echo esc_js($make_address); ?>";</script>

        <?php cp_google_maps_js(); ?>
        
        <!-- google map div -->
        <div id="map"></div>

    </div>


    <?php
    // Google map on single page
    function cp_google_maps_js() {
    ?>
     <script type="text/javascript">
    //<![CDATA[  
        jQuery(document).ready(function($) {
            $('#map').hide();
            load();
            $('#map').fadeIn(1000)
            codeAddress();
        });

        //var directionDisplay;
        //var directionsService = new google.maps.DirectionsService();
        var map = null;
        var geocoder = null;
        var fromAdd;
        var toAdd;
        var redFlag = "<?php echo get_bloginfo('template_directory'?>/images/red-flag.png";
        var noLuck = "<?php echo get_bloginfo('template_directory'?>/images/gmaps-no-result.gif";
        //var title = "<?php esc_js(the_title()); ?>";
        var contentString = '<div id="mcwrap"><span><?php esc_js(the_title()); ?></span><br />' + address + '</div>';
        
        function load() {
            geocoder = new google.maps.Geocoder();
            //directionsDisplay = new google.maps.DirectionsRenderer();
            var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
            var myOptions = {
                zoom: 14,
                center: newyork,
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                mapTypeControlOptions: {
                    style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                }
            }
            map = new google.maps.Map(document.getElementById('map'), myOptions);
            //directionsDisplay.setMap(map);   
        }
        
        
        function codeAddress() {
            geocoder.geocode( { 'address': address }, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
              //alert(results[0].geometry.location);
              // 37.8280985, -121.57125000000002
                map.setCenter();
                
                var marker = new google.maps.Marker({
                    map: map,
                    icon: redFlag,
                    //title: title,
                    animation: google.maps.Animation.DROP,
                    position: results[0].geometry.location
                });
                
                var infowindow = new google.maps.InfoWindow({
                    maxWidth: 270,
                    content: contentString,
                    disableAutoPan: false
                });
                
             infowindow.open(map, marker);
                  google.maps.event.addListener(marker, 'click', function() {
                  infowindow.open(map, marker); 
                });
               
              } else {
                //alert("Debug: " + status);
                (function($) {
                    $('#map').append('<div style="height:400px;background: url(' + noLuck + ') no-repeat center center;"><p style="padding:50px 0;text-align:center;"><?php _e('Sorry, the address could not be found.''appthemes'?></p></div>');
                    return false;
                })(jQuery);
              }
            });
          }

        function showAddress(fromAddress, toAddress) {
            calcRoute();
            calcRoute1();
        }
        function calcRoute() {
            var start = document.getElementById("fromAdd").value;
            var end = document.getElementById("toAdd").value;
            var request = {
                origin: start,
                destination: end,
                travelMode: google.maps.DirectionsTravelMode.DRIVING
            };
            directionsService.route(request, function(response, status) {
                if (status == google.maps.DirectionsStatus.OK) {
                    directionsDisplay.setDirections(response);
                }
            });
        }
    //]]>
    </script>


    <?php

    }

    ?>

  2. #2
    jomarkosabel's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    40,701
    Thanks
    166
    Thanked 3,390 Times in 3,261 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Please help our moderating team work more efficiently by not sending us support questions via PM. You can read more about how AppThemes support works here. However, you can send a PM to follow up and remind me if I missed your support request/thread.

    Thank you and have a nice day.

  3. #3
    Thread Starter
    Member altor25's Avatar
    Join Date
    Jun 2011
    Location
    Canada
    Posts
    56
    Thanks
    10
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  4. #4
    Thread Starter
    Member altor25's Avatar
    Join Date
    Jun 2011
    Location
    Canada
    Posts
    56
    Thanks
    10
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to make job ads automatically post to Twitter?
    By elleoh in forum Report ClassiPress Bugs
    Replies: 3
    Last Post: May 25th, 2011, 09:59 AM
  2. How do the categories do not appear automatically
    By dsrebelo in forum ClassiPress General Discussion
    Replies: 1
    Last Post: April 18th, 2011, 03:04 PM
  3. How to make job ads automatically post to Twitter?
    By elleoh in forum Report JobRoller Bugs
    Replies: 5
    Last Post: January 4th, 2011, 04:36 AM
  4. How to make the main ad picture click-able
    By maximillion in forum ClassiPress General Discussion
    Replies: 0
    Last Post: May 27th, 2010, 12:24 PM
  5. How to make the main ad picture click-able
    By maximillion in forum Help Using ClassiPress
    Replies: 0
    Last Post: December 31st, 1969, 06:00 PM