PluginProbe
Maps Plugin using Google Maps for WordPress – WP Google Map / 1.4.2
Maps Plugin using Google Maps for WordPress – WP Google Map v1.4.2
1.9.7 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 All 96 releases
gmap-embed / includes / shortcodes.php

shortcodes.php in Maps Plugin using Google Maps for WordPress – WP Google Map 1.4.2, at includes/shortcodes.php

184 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit;
3 // ************* Google Map SRM Shortcode***************
4 if (!function_exists('srm_gmap_embed_shortcode')) {
5
6 function srm_gmap_embed_shortcode($atts, $content)
7 {
8 static $count;
9 if (!$count) {
10 $count = 0;
11 }
12 $count++;
13
14 $wpgmap_title = esc_html(get_post_meta($atts['id'], 'wpgmap_title', true));
15 $wpgmap_show_heading = esc_html(get_post_meta($atts['id'], 'wpgmap_show_heading', true));
16 $wpgmap_heading_class = esc_html(get_post_meta($atts['id'], 'wpgmap_heading_class', true));
17 $wpgmap_latlng = esc_html(get_post_meta($atts['id'], 'wpgmap_latlng', true));
18 $wpgmap_disable_zoom_scroll = esc_html(get_post_meta($atts['id'], 'wpgmap_disable_zoom_scroll', true));
19 $wpgmap_map_zoom = esc_html(get_post_meta($atts['id'], 'wpgmap_map_zoom', true));
20 $wpgmap_map_width = esc_html(get_post_meta($atts['id'], 'wpgmap_map_width', true));
21 $wpgmap_map_height = esc_html(get_post_meta($atts['id'], 'wpgmap_map_height', true));
22 $wpgmap_map_type = esc_html(get_post_meta($atts['id'], 'wpgmap_map_type', true));
23 $wpgmap_map_address = esc_html(get_post_meta($atts['id'], 'wpgmap_map_address', true));
24 $wpgmap_show_infowindow = get_post_meta($atts['id'], 'wpgmap_show_infowindow', true);
25 $wpgmap_enable_direction = get_post_meta($atts['id'], 'wpgmap_enable_direction', true);
26
27 ob_start();
28
29 if (isset($wpgmap_show_heading) && $wpgmap_show_heading == 1) {
30 echo "<h1 class='$wpgmap_heading_class'>" . $wpgmap_title . "</h1>";
31 }
32 ?>
33 <script type="text/javascript">
34 google.maps.event.addDomListener(window, 'load', function () {
35 var map = new google.maps.Map(document.getElementById("srm_gmp_embed_<?php echo $count; ?>"), {
36 center: new google.maps.LatLng(<?php echo $wpgmap_latlng;?>),
37 zoom:<?php echo $wpgmap_map_zoom;?>,
38 mapTypeId: google.maps.MapTypeId.<?php echo $wpgmap_map_type;?>,
39 scrollwheel: '<?php echo $wpgmap_disable_zoom_scroll == 1 ? false : true;?>'
40 });
41
42 // To view directions form and data
43 <?php if($wpgmap_enable_direction and strlen(get_option('wpgmapembed_license'))==32 ){ ?>
44 var directionsDisplay = new google.maps.DirectionsRenderer();
45
46 directionsDisplay.setMap(map);
47 directionsDisplay.setPanel(document.getElementById("wp_gmap_directions_<?php echo $count; ?>"));
48
49 var btn = document.getElementById('wp_gmap_submit_<?php echo $count; ?>');
50 btn.addEventListener('click', function () {
51 var selectedMode = document.getElementById("mode").value,
52 start = document.getElementById("from_<?php echo $count; ?>").value,
53 end = document.getElementById("to_<?php echo $count; ?>").value;
54 if (start == '' || end == '') {
55 // cannot calculate route
56 document.getElementById("wp_gmap_results_<?php echo $count; ?>").style.display = 'none';
57 return false;
58 }
59 else {
60
61
62 document.getElementById('wp_gmap_loading_<?php echo $count; ?>').style.display = 'block';
63
64 var request = {
65 origin: start,
66 destination: end,
67 travelMode: google.maps.DirectionsTravelMode[selectedMode]
68 };
69 var directionsService = new google.maps.DirectionsService();
70 directionsService.route(request, function (response, status) {
71 document.getElementById('wp_gmap_loading_<?php echo $count; ?>').style.display = 'none';
72 if (status == google.maps.DirectionsStatus.OK) {
73 directionsDisplay.setDirections(response);
74 document.getElementById("wp_gmap_results_<?php echo $count; ?>").style.display = 'block';
75 }
76 else {
77 document.getElementById("wp_gmap_results_<?php echo $count; ?>").style.display = 'none';
78 }
79 });
80
81 }
82 });
83 <?php }?>
84 //=========Direction view end
85
86 var marker = new google.maps.Marker({
87 position: new google.maps.LatLng(<?php echo $wpgmap_latlng;?>),
88 map: map,
89 animation: google.maps.Animation.DROP
90 });
91 marker.setMap(map);
92 <?php
93 if($wpgmap_show_infowindow){
94 ?>
95 var infowindow = new google.maps.InfoWindow({
96 content: "<?php echo $wpgmap_map_address;?>"
97 });
98 infowindow.open(map, marker);
99 google.maps.event.addListener(marker, 'click', function () {
100 infowindow.open(map, marker);
101 });
102 <?php
103 }
104 ?>
105
106 });
107
108
109 </script>
110
111
112 <div id="srm_gmp_embed_<?php echo $count; ?>"
113 style="width:<?php echo $wpgmap_map_width . ' !important'; ?>;height:<?php echo $wpgmap_map_height; ?> !important;margin:5px 0; ">
114
115 </div>
116 <?php
117 if ($wpgmap_enable_direction == 1 and strlen(get_option('wpgmapembed_license'))==32) { ?>
118 <style type="text/css">
119 .wp_gmap_direction_box {
120 width: 100%;
121 height: auto;
122 float: left;
123 }
124
125 .wp_gmap_direction_box .fieldcontain {
126 margin: 8px 0;
127 }
128
129 #wp_gmap_submit {
130 background-color: #333;
131 border: 0;
132 color: #fff;
133 cursor: pointer;
134 font-family: "Noto Sans", sans-serif;
135 font-size: 12px;
136 font-weight: 700;
137 padding: 13px 24px;
138 text-transform: uppercase;
139 }
140
141 #wp_gmap_directions {
142 border: 1px #ddd solid;
143 }
144 </style>
145 <div class="wp_gmap_direction_box">
146 <div class="ui-bar-c ui-corner-all ui-shadow" style="padding:1em;">
147 <div data-role="fieldcontain" class="fieldcontain">
148 <label for="from"><?php _e('From','gmap-embed') ?></label>
149 <input type="text" id="from_<?php echo $count; ?>" value=""/>
150 </div>
151 <div data-role="fieldcontain" class="fieldcontain">
152 <label for="to"><?php _e('To','gmap-embed') ?></label>
153 <input type="text" id="to_<?php echo $count; ?>" value="<?php echo $wpgmap_map_address; ?>"/>
154 </div>
155 <div data-role="fieldcontain" class="fieldcontain">
156 <label for="mode" class="select"><?php _e('Transportation method','gmap-embed') ?>:</label>
157 <select name="select-choice-0" id="mode" style="padding: 5px;">
158 <option value="DRIVING"><?php _e('Driving','gmap-embed') ?></option>
159 <option value="WALKING"><?php _e('Walking','gmap-embed') ?></option>
160 <option value="BICYCLING"><?php _e('Bicycling','gmap-embed') ?></option>
161 </select>
162 </div>
163 <button type="button" data-icon="search" data-role="button" href="#"
164 id="wp_gmap_submit_<?php echo $count; ?>"><?php _e('Get Directions','gmap-embed') ?>
165 </button>
166 <span id="wp_gmap_loading_<?php echo $count; ?>" style="display: none;"><?php _e('Loading','gmap-embed') ?>...</span>
167 </div>
168
169 <!-- Directions will be listed here-->
170 <div id="wp_gmap_results_<?php echo $count; ?>"
171 style="display:none;max-height: 300px;overflow-y: scroll;">
172 <div id="wp_gmap_directions_<?php echo $count; ?>"></div>
173 </div>
174
175 </div>
176 <?php } ?>
177 <?php
178 return ob_get_clean();
179 }
180
181 }
182
183 //******* Defining Shortcode for Google Map SRM
184 add_shortcode('gmap-embed', 'srm_gmap_embed_shortcode');