Plugin Directory

Changeset 932519

Timestamp:
06/15/2014 03:41:41 AM (10 years ago)
Author:
fahmiadib
Message:

Release 1.1 : Utilize Transient API for cached maps

Location:
wp-google-maps-shortcode/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-google-maps-shortcode/trunk/readme.txt

    r898030 r932519  
    55Tags: gmaps, google maps, short code, maps
    66Requires at least: 3.5
    7 Tested up to: 3.9
    8 Stable tag: 1.0
     7Tested up to: 3.9
     8Stable tag: 1.
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3232== Changelog ==
    3333
     34
     35
     36
     37
    3438= 1.0 =
    3539
  • wp-google-maps-shortcode/trunk/wp-gmaps-shortcode.php

    r898030 r932519  
    44Plugin URL: http://fadib.net/wp-google-maps-shortcode
    55Description: Insert Google Maps into your post or page using Shortcode
    6 Version: 1.0
     6Version: 1.
    77Author: Fahmi Adib
    88Author URI: http://fadib.net
     
    1212function wp_gmaps_shortcode( $atts ) {
    1313    $atts = shortcode_atts( array(
    14         'api_key'   => false,
    15         'address'   => false,
    16         'lat'       => false,
    17         'lng'       => false,
    18         'zoom'      => '10',
    19         'height'    => '350px',
    20         'width'     => '350px',
    21         'marker'    => 0,
     14        'api_key'       => false,
     15        'address'       => false,
     16        'lat'           => false,
     17        'lng'           => false,
     18        'zoom'          => '10',
     19        'height'        => '350px',
     20        'width'         => '350px',
     21        'marker'        => 0,
     22        'infowindow'    => false,
    2223    ), $atts );
    2324   
    2425    wp_print_scripts( 'wp-gmaps-api' );
     26
     27
     28
     29
     30
     31
     32
     33
    2534   
    2635    $map_id = uniqid( 'wp_gmaps_' );
     
    3443        var map_<?php echo $map_id; ?>;
    3544        var marker_<?php echo $map_id; ?>;
     45
    3646        var geocoder = new google.maps.Geocoder();
    3747        function wp_gmaps_<?php echo $map_id; ?>() {
     
    4555           
    4656            <?php if ( $atts['marker'] ): ?>
    47             marker_<?php echo $map_id ?> = new google.maps.Marker({
    48                 position: location,
    49                 map: map_<?php echo $map_id; ?>
    50             });
    51             <?php endif; ?>
     57                marker_<?php echo $map_id ?> = new google.maps.Marker({
     58                    position: location,
     59                    map: map_<?php echo $map_id; ?>
     60                });
    5261           
    53             <?php if ( $atts['address'] ): ?>
    54                 var address = "<?php echo esc_attr( $atts['address'] ) ?>";
    55                 geocoder.geocode( { 'address': address }, function(results, status) {
    56                     if (status == google.maps.GeocoderStatus.OK) {
    57                         map_<?php echo $map_id; ?>.setCenter(results[0].geometry.location);
    58                         if (marker_<?php echo $map_id ?>) {
    59                             marker_<?php echo $map_id ?>.setPosition(results[0].geometry.location);
    60                         }
    61                     } else {
    62                         alert('Address not found: ' + address);
    63                     }
    64                 });
     62                <?php if ( $atts['infowindow'] ): ?>
     63                    infowindow_<?php echo $map_id; ?> = new google.maps.InfoWindow({
     64                        content: '<?php echo esc_attr( $atts['infowindow'] ) ?>'
     65                    });
     66                    google.maps.event.addListener(marker_<?php echo $map_id ?>, 'click', function() {
     67                        infowindow_<?php echo $map_id; ?>.open(map_<?php echo $map_id; ?>, marker_<?php echo $map_id ?>);
     68                    });
     69                <?php endif; ?>
    6570            <?php endif; ?>
    6671        }
     
    7479
    7580/**
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
    76136 * Loads Google Map API
    77137 *
    78138 * @since       1.0
    79139 * @return      void
    80 */
     140*/
    81141function wp_gmaps_load_scripts() {
    82142    wp_register_script( 'wp-gmaps-api', '//maps.google.com/maps/api/js?sensor=false' );
Note: See TracChangeset for help on using the changeset viewer.