Changeset 932519
- Timestamp:
- 06/15/2014 03:41:41 AM (10 years ago)
- Location:
- wp-google-maps-shortcode/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-google-maps-shortcode/trunk/readme.txt
r898030 r932519 5 5 Tags: gmaps, google maps, short code, maps 6 6 Requires at least: 3.5 7 Tested up to: 3.9 8 Stable tag: 1. 07 Tested up to: 3.9 8 Stable tag: 1. 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 32 32 == Changelog == 33 33 34 35 36 37 34 38 = 1.0 = 35 39 -
wp-google-maps-shortcode/trunk/wp-gmaps-shortcode.php
r898030 r932519 4 4 Plugin URL: http://fadib.net/wp-google-maps-shortcode 5 5 Description: Insert Google Maps into your post or page using Shortcode 6 Version: 1. 06 Version: 1. 7 7 Author: Fahmi Adib 8 8 Author URI: http://fadib.net … … 12 12 function wp_gmaps_shortcode( $atts ) { 13 13 $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, 22 23 ), $atts ); 23 24 24 25 wp_print_scripts( 'wp-gmaps-api' ); 26 27 28 29 30 31 32 33 25 34 26 35 $map_id = uniqid( 'wp_gmaps_' ); … … 34 43 var map_<?php echo $map_id; ?>; 35 44 var marker_<?php echo $map_id; ?>; 45 36 46 var geocoder = new google.maps.Geocoder(); 37 47 function wp_gmaps_<?php echo $map_id; ?>() { … … 45 55 46 56 <?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 }); 52 61 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; ?> 65 70 <?php endif; ?> 66 71 } … … 74 79 75 80 /** 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 76 136 * Loads Google Map API 77 137 * 78 138 * @since 1.0 79 139 * @return void 80 */140 */ 81 141 function wp_gmaps_load_scripts() { 82 142 wp_register_script( 'wp-gmaps-api', '//maps.google.com/maps/api/js?sensor=false' );
Note: See TracChangeset
for help on using the changeset viewer.