Version Description
- Map Center position auto detection on drag-drop and re-centering by user.
- LIVE zoom updating and rendering once zoom level changed by user.
Download this release
Release Info
Developer | milonfci |
Plugin | WP Google Map |
Version | 1.7.2 |
Comparing to | |
See all releases |
Code changes from version 1.7.1 to 1.7.2
- assets/js/custom.js +3 -1
- assets/js/geo_based_map_create.js +33 -7
- assets/js/geo_based_map_edit.js +22 -3
- assets/js/localized_script.js +1 -0
- includes/helper.php +11 -1
- includes/shortcodes.php +6 -5
- includes/widget.php +2 -2
- includes/wpgmap_create.php +6 -6
- includes/wpgmap_edit.php +6 -5
- includes/wpgmap_settings.php +3 -3
- readme.txt +5 -1
- srm_gmap_embed.php +38 -16
assets/js/custom.js
CHANGED
@@ -127,6 +127,7 @@
|
|
127 |
var wpgmap_map_type = parent.find("#wpgmap_map_type").val();
|
128 |
var wpgmap_map_address = parent.find("#wpgmap_map_address").val();
|
129 |
var wpgmap_marker_icon = parent.find("#wpgmap_upload_hidden").val();
|
|
|
130 |
|
131 |
var map_data = {
|
132 |
wpgmap_title: wpgmap_title,
|
@@ -141,7 +142,8 @@
|
|
141 |
wpgmap_map_address: wpgmap_map_address,
|
142 |
wpgmap_show_infowindow: wpgmap_show_infowindow,
|
143 |
wpgmap_enable_direction: wpgmap_enable_direction,
|
144 |
-
wpgmap_marker_icon: wpgmap_marker_icon
|
|
|
145 |
};
|
146 |
|
147 |
if (btn_id == 'wp-gmap-embed-save') {
|
127 |
var wpgmap_map_type = parent.find("#wpgmap_map_type").val();
|
128 |
var wpgmap_map_address = parent.find("#wpgmap_map_address").val();
|
129 |
var wpgmap_marker_icon = parent.find("#wpgmap_upload_hidden").val();
|
130 |
+
var wpgmap_center_lat_lng = parent.find("#wpgmap_center_lat_lng").val();
|
131 |
|
132 |
var map_data = {
|
133 |
wpgmap_title: wpgmap_title,
|
142 |
wpgmap_map_address: wpgmap_map_address,
|
143 |
wpgmap_show_infowindow: wpgmap_show_infowindow,
|
144 |
wpgmap_enable_direction: wpgmap_enable_direction,
|
145 |
+
wpgmap_marker_icon: wpgmap_marker_icon,
|
146 |
+
wpgmap_center_lat_lng:wpgmap_center_lat_lng
|
147 |
};
|
148 |
|
149 |
if (btn_id == 'wp-gmap-embed-save') {
|
assets/js/geo_based_map_create.js
CHANGED
@@ -71,11 +71,30 @@ function addMarkerDragendListener(marker) {
|
|
71 |
});
|
72 |
}
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
// To render Google Map
|
75 |
function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
76 |
|
77 |
// Set address by Lat Lng
|
78 |
_e("wpgmap_latlng").value = center_lat + "," + center_lng;
|
|
|
79 |
wpgmapSetAddressByLatLng(center_lat, center_lng);
|
80 |
|
81 |
// In acse of already initiated map
|
@@ -97,7 +116,7 @@ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
|
97 |
// Add dragend event listener
|
98 |
addMarkerDragendListener(marker1);
|
99 |
marker1.setMap(map);
|
100 |
-
|
101 |
// Create the search box and link it to the UI element.
|
102 |
input = document.getElementById(input);
|
103 |
var searchBox = new google.maps.places.SearchBox(input);
|
@@ -188,13 +207,20 @@ function initWpGmap(lat, lng, map_type) {
|
|
188 |
|
189 |
|
190 |
var tryAPIGeolocation = function () {
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
|
|
197 |
});
|
|
|
|
|
|
|
198 |
};
|
199 |
var browserGeolocationSuccess = function (position) {
|
200 |
initWpGmap(position.coords.latitude, position.coords.longitude, 'ROADMAP');
|
71 |
});
|
72 |
}
|
73 |
|
74 |
+
/**
|
75 |
+
* Invoking required map event listeners
|
76 |
+
* @param map object
|
77 |
+
*/
|
78 |
+
function addMapListeners(map) {
|
79 |
+
|
80 |
+
// On map center changed
|
81 |
+
map.addListener("center_changed", function () {
|
82 |
+
jQuery('#wpgmap_center_lat_lng').val(map.center.lat() + ',' + map.center.lng());
|
83 |
+
});
|
84 |
+
|
85 |
+
// On map zoom level changed
|
86 |
+
map.addListener("zoom_changed", function () {
|
87 |
+
console.log(map.zoom);
|
88 |
+
jQuery('#wpgmap_map_zoom').val(map.zoom);
|
89 |
+
});
|
90 |
+
}
|
91 |
+
|
92 |
// To render Google Map
|
93 |
function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
94 |
|
95 |
// Set address by Lat Lng
|
96 |
_e("wpgmap_latlng").value = center_lat + "," + center_lng;
|
97 |
+
_e("wpgmap_center_lat_lng").value = center_lat + "," + center_lng;
|
98 |
wpgmapSetAddressByLatLng(center_lat, center_lng);
|
99 |
|
100 |
// In acse of already initiated map
|
116 |
// Add dragend event listener
|
117 |
addMarkerDragendListener(marker1);
|
118 |
marker1.setMap(map);
|
119 |
+
addMapListeners(map);
|
120 |
// Create the search box and link it to the UI element.
|
121 |
input = document.getElementById(input);
|
122 |
var searchBox = new google.maps.places.SearchBox(input);
|
207 |
|
208 |
|
209 |
var tryAPIGeolocation = function () {
|
210 |
+
try {
|
211 |
+
jQuery.ajax({
|
212 |
+
type: 'POST',
|
213 |
+
url: 'https://www.googleapis.com/geolocation/v1/geolocate?key=' + wp_gmap_api_key,
|
214 |
+
success: function (data) {
|
215 |
+
initWpGmap(success.location.lat, success.location.lng, 'ROADMAP');
|
216 |
+
},
|
217 |
+
error: function (xhr, textStatus, error) {
|
218 |
+
initWpGmap(40.73359922990751, -74.02791395625002, 'ROADMAP');
|
219 |
+
}
|
220 |
});
|
221 |
+
} catch (error) {
|
222 |
+
initWpGmap(40.73359922990751, -74.02791395625002, 'ROADMAP');
|
223 |
+
}
|
224 |
};
|
225 |
var browserGeolocationSuccess = function (position) {
|
226 |
initWpGmap(position.coords.latitude, position.coords.longitude, 'ROADMAP');
|
assets/js/geo_based_map_edit.js
CHANGED
@@ -20,6 +20,23 @@ function wpgmapSetAddressByLatLng(lat, lng, id) {
|
|
20 |
});
|
21 |
|
22 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
// Generating already initialized map
|
25 |
function generateAlreadyInitiztedMap(map_type, center_lat, center_lng) {
|
@@ -41,6 +58,7 @@ function generateAlreadyInitiztedMap(map_type, center_lat, center_lng) {
|
|
41 |
animation: google.maps.Animation.DROP
|
42 |
});
|
43 |
marker1.setMap(map);
|
|
|
44 |
// Adding dragend Event Listener
|
45 |
addMarkerDragendListener(marker1);
|
46 |
}
|
@@ -75,7 +93,7 @@ function addMarkerDragendListener(marker) {
|
|
75 |
// to render Google Map
|
76 |
function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
77 |
//wpgmapSetAddressByLatLng(center_lat, center_lng);
|
78 |
-
document.getElementById("wpgmap_latlng").value = center_lat + "," + center_lng;
|
79 |
// In acse of already initiated
|
80 |
if (typeof map === 'object') {
|
81 |
generateAlreadyInitiztedMap(map_type, center_lat, center_lng);
|
@@ -87,7 +105,7 @@ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
|
87 |
|
88 |
map = new google.maps.Map(_e(id), gmap_settings);
|
89 |
marker1 = new google.maps.Marker({
|
90 |
-
position: new google.maps.LatLng(
|
91 |
title: "",
|
92 |
draggable: true,
|
93 |
animation: google.maps.Animation.DROP,
|
@@ -96,6 +114,7 @@ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
|
96 |
// Add dragend event listener
|
97 |
addMarkerDragendListener(marker1);
|
98 |
marker1.setMap(map);
|
|
|
99 |
|
100 |
// // Create the search box and link it to the UI element.
|
101 |
input = document.getElementById(input);
|
@@ -240,4 +259,4 @@ jQuery(document).ready(function ($) {
|
|
240 |
};
|
241 |
return false;
|
242 |
});
|
243 |
-
});
|
20 |
});
|
21 |
|
22 |
}
|
23 |
+
/**
|
24 |
+
* Invoking required map event listeners
|
25 |
+
* @param map object
|
26 |
+
*/
|
27 |
+
function addMapListeners(map) {
|
28 |
+
|
29 |
+
// On map center changed
|
30 |
+
map.addListener("center_changed", function () {
|
31 |
+
jQuery('#wpgmap_center_lat_lng').val(map.center.lat() + ',' + map.center.lng());
|
32 |
+
});
|
33 |
+
|
34 |
+
// On map zoom level changed
|
35 |
+
map.addListener("zoom_changed", function () {
|
36 |
+
console.log(map.zoom);
|
37 |
+
jQuery('#wpgmap_map_zoom').val(map.zoom);
|
38 |
+
});
|
39 |
+
}
|
40 |
|
41 |
// Generating already initialized map
|
42 |
function generateAlreadyInitiztedMap(map_type, center_lat, center_lng) {
|
58 |
animation: google.maps.Animation.DROP
|
59 |
});
|
60 |
marker1.setMap(map);
|
61 |
+
addMapListeners(map);
|
62 |
// Adding dragend Event Listener
|
63 |
addMarkerDragendListener(marker1);
|
64 |
}
|
93 |
// to render Google Map
|
94 |
function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
95 |
//wpgmapSetAddressByLatLng(center_lat, center_lng);
|
96 |
+
//document.getElementById("wpgmap_latlng").value = center_lat + "," + center_lng;
|
97 |
// In acse of already initiated
|
98 |
if (typeof map === 'object') {
|
99 |
generateAlreadyInitiztedMap(map_type, center_lat, center_lng);
|
105 |
|
106 |
map = new google.maps.Map(_e(id), gmap_settings);
|
107 |
marker1 = new google.maps.Marker({
|
108 |
+
position: new google.maps.LatLng(gmap_object.current_map_marker_lat, gmap_object.current_map_marker_lng),
|
109 |
title: "",
|
110 |
draggable: true,
|
111 |
animation: google.maps.Animation.DROP,
|
114 |
// Add dragend event listener
|
115 |
addMarkerDragendListener(marker1);
|
116 |
marker1.setMap(map);
|
117 |
+
addMapListeners(map);
|
118 |
|
119 |
// // Create the search box and link it to the UI element.
|
120 |
input = document.getElementById(input);
|
259 |
};
|
260 |
return false;
|
261 |
});
|
262 |
+
});
|
assets/js/localized_script.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
//console.log(test_object);
|
includes/helper.php
CHANGED
@@ -10,6 +10,16 @@ function gmap_embed_is_using_premium_version() {
|
|
10 |
return gmap_embed_no_of_post() == 0 or strlen( trim( get_option( 'wpgmapembed_license' ) ) ) == 32;
|
11 |
}
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
function gmap_embed_get_languages() {
|
14 |
return array(
|
15 |
"af" => "AFRIKAANS",
|
@@ -348,4 +358,4 @@ function gmap_embed_get_regions() {
|
|
348 |
"ZM" => "Zambia",
|
349 |
"ZW" => "Zimbabwe"
|
350 |
);
|
351 |
-
}
|
10 |
return gmap_embed_no_of_post() == 0 or strlen( trim( get_option( 'wpgmapembed_license' ) ) ) == 32;
|
11 |
}
|
12 |
|
13 |
+
function get_center_lat_lng_by_map_id($map_id=0){
|
14 |
+
$wpgmap_center_lat_lng= get_post_meta( $map_id, 'wpgmap_center_lat_lng', true );
|
15 |
+
$wpgmap_latlng = get_post_meta( $map_id, 'wpgmap_latlng', true );
|
16 |
+
if($wpgmap_center_lat_lng=='' or $wpgmap_center_lat_lng==null or strlen($wpgmap_center_lat_lng)==0){
|
17 |
+
add_post_meta( $map_id, 'wpgmap_center_lat_lng', $wpgmap_latlng );
|
18 |
+
$wpgmap_center_lat_lng = $wpgmap_latlng;
|
19 |
+
}
|
20 |
+
return $wpgmap_center_lat_lng;
|
21 |
+
}
|
22 |
+
|
23 |
function gmap_embed_get_languages() {
|
24 |
return array(
|
25 |
"af" => "AFRIKAANS",
|
358 |
"ZM" => "Zambia",
|
359 |
"ZW" => "Zimbabwe"
|
360 |
);
|
361 |
+
}
|
includes/shortcodes.php
CHANGED
@@ -25,6 +25,7 @@ if ( ! function_exists( 'srm_gmap_embed_shortcode' ) ) {
|
|
25 |
$wpgmap_show_infowindow = get_post_meta( $atts['id'], 'wpgmap_show_infowindow', true );
|
26 |
$wpgmap_enable_direction = get_post_meta( $atts['id'], 'wpgmap_enable_direction', true );
|
27 |
$wpgmap_marker_icon = get_post_meta( $atts['id'], 'wpgmap_marker_icon', true );
|
|
|
28 |
|
29 |
ob_start();
|
30 |
|
@@ -35,7 +36,7 @@ if ( ! function_exists( 'srm_gmap_embed_shortcode' ) ) {
|
|
35 |
<script type="text/javascript">
|
36 |
google.maps.event.addDomListener(window, 'load', function () {
|
37 |
var map = new google.maps.Map(document.getElementById("srm_gmp_embed_<?php echo $count; ?>"), {
|
38 |
-
center: new google.maps.LatLng(<?php echo $
|
39 |
zoom:<?php echo $wpgmap_map_zoom;?>,
|
40 |
mapTypeId: google.maps.MapTypeId.<?php echo $wpgmap_map_type;?>,
|
41 |
scrollwheel: '<?php echo $wpgmap_disable_zoom_scroll == 1 ? false : true;?>'
|
@@ -113,7 +114,7 @@ if ( ! function_exists( 'srm_gmap_embed_shortcode' ) ) {
|
|
113 |
|
114 |
|
115 |
<div id="srm_gmp_embed_<?php echo $count; ?>"
|
116 |
-
style="width:<?php echo $wpgmap_map_width . ' !important'; ?>;height:<?php echo $wpgmap_map_height; ?> !important;
|
117 |
|
118 |
</div>
|
119 |
<?php
|
@@ -122,10 +123,10 @@ if ( ! function_exists( 'srm_gmap_embed_shortcode' ) ) {
|
|
122 |
.wp_gmap_direction_box {
|
123 |
width: 100%;
|
124 |
height: auto;
|
125 |
-
float: left
|
126 |
}
|
127 |
|
128 |
-
.
|
129 |
margin: 8px 0;
|
130 |
}
|
131 |
|
@@ -153,7 +154,7 @@ if ( ! function_exists( 'srm_gmap_embed_shortcode' ) ) {
|
|
153 |
</div>
|
154 |
<div data-role="fieldcontain" class="fieldcontain">
|
155 |
<label for="to"><?php _e( 'To', 'gmap-embed' ) ?></label>
|
156 |
-
<input type="text" id="to_<?php echo $count; ?>" value="<?php echo $wpgmap_map_address; ?>"/>
|
157 |
</div>
|
158 |
<div data-role="fieldcontain" class="fieldcontain">
|
159 |
<label for="mode" class="select"><?php _e( 'Transportation method', 'gmap-embed' ) ?>:</label>
|
25 |
$wpgmap_show_infowindow = get_post_meta( $atts['id'], 'wpgmap_show_infowindow', true );
|
26 |
$wpgmap_enable_direction = get_post_meta( $atts['id'], 'wpgmap_enable_direction', true );
|
27 |
$wpgmap_marker_icon = get_post_meta( $atts['id'], 'wpgmap_marker_icon', true );
|
28 |
+
$wpgmap_center_lat_lng = get_center_lat_lng_by_map_id($atts['id']);
|
29 |
|
30 |
ob_start();
|
31 |
|
36 |
<script type="text/javascript">
|
37 |
google.maps.event.addDomListener(window, 'load', function () {
|
38 |
var map = new google.maps.Map(document.getElementById("srm_gmp_embed_<?php echo $count; ?>"), {
|
39 |
+
center: new google.maps.LatLng(<?php echo $wpgmap_center_lat_lng;?>),
|
40 |
zoom:<?php echo $wpgmap_map_zoom;?>,
|
41 |
mapTypeId: google.maps.MapTypeId.<?php echo $wpgmap_map_type;?>,
|
42 |
scrollwheel: '<?php echo $wpgmap_disable_zoom_scroll == 1 ? false : true;?>'
|
114 |
|
115 |
|
116 |
<div id="srm_gmp_embed_<?php echo $count; ?>"
|
117 |
+
style="width:<?php echo $wpgmap_map_width . ' !important'; ?>;height:<?php echo $wpgmap_map_height; ?> !important; ">
|
118 |
|
119 |
</div>
|
120 |
<?php
|
123 |
.wp_gmap_direction_box {
|
124 |
width: 100%;
|
125 |
height: auto;
|
126 |
+
/*float: left;*/
|
127 |
}
|
128 |
|
129 |
+
.fieldcontain {
|
130 |
margin: 8px 0;
|
131 |
}
|
132 |
|
154 |
</div>
|
155 |
<div data-role="fieldcontain" class="fieldcontain">
|
156 |
<label for="to"><?php _e( 'To', 'gmap-embed' ) ?></label>
|
157 |
+
<input type="text" id="to_<?php echo $count; ?>" value="<?php echo strip_tags(html_entity_decode($wpgmap_map_address)); ?>"/>
|
158 |
</div>
|
159 |
<div data-role="fieldcontain" class="fieldcontain">
|
160 |
<label for="mode" class="select"><?php _e( 'Transportation method', 'gmap-embed' ) ?>:</label>
|
includes/widget.php
CHANGED
@@ -57,8 +57,8 @@ class srmgmap_widget extends WP_Widget
|
|
57 |
$mapsList->the_post();
|
58 |
$gmap_title = get_post_meta( get_the_ID(), 'wpgmap_title', true );
|
59 |
if($gmap_title==''){
|
60 |
-
|
61 |
-
|
62 |
$option_value = esc_attr( '[gmap-embed id="' . get_the_ID() . '"]' );
|
63 |
$map_shortcodes_list .= '<option value="' . $option_value . '" '.(($instance['srmgmap_shortcode']==html_entity_decode($option_value))?'selected':'').'>' . $gmap_title.' '.esc_attr( '[gmap-embed id="' . get_the_ID() . '"]' ).'</option>';
|
64 |
}
|
57 |
$mapsList->the_post();
|
58 |
$gmap_title = get_post_meta( get_the_ID(), 'wpgmap_title', true );
|
59 |
if($gmap_title==''){
|
60 |
+
$gmap_title = 'No title';
|
61 |
+
}
|
62 |
$option_value = esc_attr( '[gmap-embed id="' . get_the_ID() . '"]' );
|
63 |
$map_shortcodes_list .= '<option value="' . $option_value . '" '.(($instance['srmgmap_shortcode']==html_entity_decode($option_value))?'selected':'').'>' . $gmap_title.' '.esc_attr( '[gmap-embed id="' . get_the_ID() . '"]' ).'</option>';
|
64 |
}
|
includes/wpgmap_create.php
CHANGED
@@ -31,9 +31,10 @@
|
|
31 |
</tr>
|
32 |
<tr>
|
33 |
<td>
|
34 |
-
<label for="wpgmap_latlng"><b><?php _e( 'Latitude, Longitude', 'gmap-embed' ); ?></b></label><br/>
|
35 |
<input id="wpgmap_latlng" name="wpgmap_latlng" value="" type="text"
|
36 |
class="regular-text">
|
|
|
37 |
</td>
|
38 |
</tr>
|
39 |
<tr>
|
@@ -85,9 +86,8 @@
|
|
85 |
|
86 |
<tr>
|
87 |
<td>
|
88 |
-
<label for="wpgmap_map_address"><b><?php _e( 'Location Address', 'gmap-embed' ); ?></b></label><br/>
|
89 |
-
<
|
90 |
-
name="wpgmap_map_address" class="regular-text">
|
91 |
|
92 |
<br/>
|
93 |
|
@@ -144,7 +144,7 @@
|
|
144 |
</div>
|
145 |
|
146 |
<script type="text/javascript"
|
147 |
-
src="<?php echo esc_url( plugins_url( "../assets/js/geo_based_map_create.js?v=
|
148 |
</div>
|
149 |
|
150 |
<div class="media-frame-toolbar">
|
@@ -156,4 +156,4 @@
|
|
156 |
id="wp-gmap-embed-save"><?php _e( 'Save', 'gmap-embed' ); ?></button>
|
157 |
</div>
|
158 |
</div>
|
159 |
-
</div>
|
31 |
</tr>
|
32 |
<tr>
|
33 |
<td>
|
34 |
+
<label for="wpgmap_latlng"><b><?php _e( 'Latitude, Longitude(Approx)', 'gmap-embed' ); ?></b></label><br/>
|
35 |
<input id="wpgmap_latlng" name="wpgmap_latlng" value="" type="text"
|
36 |
class="regular-text">
|
37 |
+
<input type="hidden" name="wpgmap_center_lat_lng" id="wpgmap_center_lat_lng">
|
38 |
</td>
|
39 |
</tr>
|
40 |
<tr>
|
86 |
|
87 |
<tr>
|
88 |
<td>
|
89 |
+
<label for="wpgmap_map_address"><b><?php _e( 'Current Location Address(HTML supported)', 'gmap-embed' ); ?></b></label><br/>
|
90 |
+
<textarea id="wpgmap_map_address" style="width:25em;" name="wpgmap_map_address" class="regular-text" rows="3"></textarea>
|
|
|
91 |
|
92 |
<br/>
|
93 |
|
144 |
</div>
|
145 |
|
146 |
<script type="text/javascript"
|
147 |
+
src="<?php echo esc_url( plugins_url( "../assets/js/geo_based_map_create.js?v=".filemtime(__DIR__.'/../assets/js/geo_based_map_create.js'), __FILE__ ) ); ?>"></script>
|
148 |
</div>
|
149 |
|
150 |
<div class="media-frame-toolbar">
|
156 |
id="wp-gmap-embed-save"><?php _e( 'Save', 'gmap-embed' ); ?></button>
|
157 |
</div>
|
158 |
</div>
|
159 |
+
</div>
|
includes/wpgmap_edit.php
CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
4 |
}
|
5 |
$gmap_data = $this->get_wpgmapembed_data( intval( $_GET['id'] ) );
|
6 |
$wpgmap_single = json_decode( $gmap_data );
|
7 |
-
list( $
|
8 |
?>
|
9 |
<div data-columns="8">
|
10 |
<!-- getting hidden id-->
|
@@ -39,11 +39,12 @@ list( $wpgmap_lat, $wpgmap_lng ) = explode( ',', esc_html( $wpgmap_single->wpgma
|
|
39 |
|
40 |
<tr>
|
41 |
<td>
|
42 |
-
<label for="wpgmap_latlng"><b><?php _e( 'Latitude, Longitude', 'gmap-embed' ); ?></b></label><br/>
|
43 |
<input id="wpgmap_latlng" name="wpgmap_latlng"
|
44 |
value="<?php echo esc_attr( $wpgmap_single->wpgmap_latlng ); ?>"
|
45 |
type="text"
|
46 |
class="regular-text">
|
|
|
47 |
</td>
|
48 |
</tr>
|
49 |
|
@@ -108,7 +109,7 @@ list( $wpgmap_lat, $wpgmap_lng ) = explode( ',', esc_html( $wpgmap_single->wpgma
|
|
108 |
|
109 |
<tr>
|
110 |
<td>
|
111 |
-
<label for="wpgmap_map_address"><b><?php _e( 'Location Address', 'gmap-embed' ); ?></b></label><br/>
|
112 |
<textarea id="wpgmap_map_address" style="width:25em;" name="wpgmap_map_address"
|
113 |
class="regular-text"
|
114 |
rows="3"><?php echo esc_attr( trim( $wpgmap_single->wpgmap_map_address ) ); ?></textarea>
|
@@ -178,7 +179,7 @@ list( $wpgmap_lat, $wpgmap_lng ) = explode( ',', esc_html( $wpgmap_single->wpgma
|
|
178 |
$(function () {
|
179 |
icon = '<?php echo $wpgmap_single->wpgmap_marker_icon;?>';
|
180 |
google.maps.event.addDomListener(window, 'load',
|
181 |
-
initAutocomplete('map', 'pac-input',<?php echo $
|
182 |
);
|
183 |
if (jQuery('#wpgmap_show_infowindow').is(':checked') === true) {
|
184 |
openInfoWindow();
|
@@ -197,4 +198,4 @@ list( $wpgmap_lat, $wpgmap_lng ) = explode( ',', esc_html( $wpgmap_single->wpgma
|
|
197 |
id="wp-gmap-embed-update"><?php _e( 'Update', 'gmap-embed' ); ?></button>
|
198 |
</div>
|
199 |
</div>
|
200 |
-
</div>
|
4 |
}
|
5 |
$gmap_data = $this->get_wpgmapembed_data( intval( $_GET['id'] ) );
|
6 |
$wpgmap_single = json_decode( $gmap_data );
|
7 |
+
list( $wpgmap_center_lat, $wpgmap_center_lng ) = explode( ',', esc_html( $wpgmap_single->wpgmap_center_lat_lng ) );
|
8 |
?>
|
9 |
<div data-columns="8">
|
10 |
<!-- getting hidden id-->
|
39 |
|
40 |
<tr>
|
41 |
<td>
|
42 |
+
<label for="wpgmap_latlng"><b><?php _e( 'Latitude, Longitude(Approx)', 'gmap-embed' ); ?></b></label><br/>
|
43 |
<input id="wpgmap_latlng" name="wpgmap_latlng"
|
44 |
value="<?php echo esc_attr( $wpgmap_single->wpgmap_latlng ); ?>"
|
45 |
type="text"
|
46 |
class="regular-text">
|
47 |
+
<input type="hidden" name="wpgmap_center_lat_lng" id="wpgmap_center_lat_lng" value="<?php echo esc_attr($wpgmap_single->wpgmap_center_lat_lng);?>">
|
48 |
</td>
|
49 |
</tr>
|
50 |
|
109 |
|
110 |
<tr>
|
111 |
<td>
|
112 |
+
<label for="wpgmap_map_address"><b><?php _e( 'Current Location Address(HTML supported)', 'gmap-embed' ); ?></b></label><br/>
|
113 |
<textarea id="wpgmap_map_address" style="width:25em;" name="wpgmap_map_address"
|
114 |
class="regular-text"
|
115 |
rows="3"><?php echo esc_attr( trim( $wpgmap_single->wpgmap_map_address ) ); ?></textarea>
|
179 |
$(function () {
|
180 |
icon = '<?php echo $wpgmap_single->wpgmap_marker_icon;?>';
|
181 |
google.maps.event.addDomListener(window, 'load',
|
182 |
+
initAutocomplete('map', 'pac-input',<?php echo $wpgmap_center_lat;?>,<?php echo $wpgmap_center_lng;?>, '<?php echo $wpgmap_single->wpgmap_map_type; ?>',<?php echo $wpgmap_single->wpgmap_map_zoom;?>, 'edit')
|
183 |
);
|
184 |
if (jQuery('#wpgmap_show_infowindow').is(':checked') === true) {
|
185 |
openInfoWindow();
|
198 |
id="wp-gmap-embed-update"><?php _e( 'Update', 'gmap-embed' ); ?></button>
|
199 |
</div>
|
200 |
</div>
|
201 |
+
</div>
|
includes/wpgmap_settings.php
CHANGED
@@ -100,7 +100,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
100 |
?>
|
101 |
</select>
|
102 |
<p class="description" id="tagline-description">
|
103 |
-
<?php _e( '
|
104 |
</p>
|
105 |
</td>
|
106 |
</tr>
|
@@ -128,7 +128,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
128 |
|
129 |
</select>
|
130 |
<p class="description" id="tagline-description">
|
131 |
-
<?php _e( '
|
132 |
</p>
|
133 |
</td>
|
134 |
</tr>
|
@@ -143,4 +143,4 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
143 |
</tbody>
|
144 |
</table>
|
145 |
</div>
|
146 |
-
</div>
|
100 |
?>
|
101 |
</select>
|
102 |
<p class="description" id="tagline-description">
|
103 |
+
<?php _e( 'Choose your desired map language', 'gmap-embed' ); ?>
|
104 |
</p>
|
105 |
</td>
|
106 |
</tr>
|
128 |
|
129 |
</select>
|
130 |
<p class="description" id="tagline-description">
|
131 |
+
<?php _e( 'Choose your regional area', 'gmap-embed' ); ?>
|
132 |
</p>
|
133 |
</td>
|
134 |
</tr>
|
143 |
</tbody>
|
144 |
</table>
|
145 |
</div>
|
146 |
+
</div>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: google map, gmap, google map embed, wp map, wp map embed, map embed, best google maps, best maps, bing maps, cross-browser, custom google map, custom google maps, map direction, easy map, geo, geocoder, maps, google earth, google map plugin, google map shortcode, google map widget, google maps v3, google maps, gprs, gps, gpx, kml, latitude, Longitude, location, location by address, map, map directions, map markers, map plugin, map shortcode, map styles, maps google, post map, map point, polygons, roads, routes, store locator, street view, wp google map, contact page map, google map wordpress, google maps wordpress, google maps for wordpress, simple google map, simple google map plugin, wp google maps,maps
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 5.6
|
7 |
-
Version: 1.7.
|
8 |
Requires PHP: 5.3
|
9 |
Text Domain: gmap-embed
|
10 |
License: GPLv2 or later
|
@@ -136,6 +136,10 @@ See the [Video](https://www.youtube.com/watch?v=o90H34eacHg) ,hope you will get
|
|
136 |
|
137 |
== Changelog ==
|
138 |
|
|
|
|
|
|
|
|
|
139 |
= 1.7.1 =
|
140 |
* HTML content support in Google Map InfoWindow
|
141 |
* Added select drop-down in Google map SRM widget instead of text box for ShortCode.
|
4 |
Tags: google map, gmap, google map embed, wp map, wp map embed, map embed, best google maps, best maps, bing maps, cross-browser, custom google map, custom google maps, map direction, easy map, geo, geocoder, maps, google earth, google map plugin, google map shortcode, google map widget, google maps v3, google maps, gprs, gps, gpx, kml, latitude, Longitude, location, location by address, map, map directions, map markers, map plugin, map shortcode, map styles, maps google, post map, map point, polygons, roads, routes, store locator, street view, wp google map, contact page map, google map wordpress, google maps wordpress, google maps for wordpress, simple google map, simple google map plugin, wp google maps,maps
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 5.6
|
7 |
+
Version: 1.7.2
|
8 |
Requires PHP: 5.3
|
9 |
Text Domain: gmap-embed
|
10 |
License: GPLv2 or later
|
136 |
|
137 |
== Changelog ==
|
138 |
|
139 |
+
= 1.7.2 =
|
140 |
+
* Map Center position auto detection on drag-drop and re-centering by user.
|
141 |
+
* LIVE zoom updating and rendering once zoom level changed by user.
|
142 |
+
|
143 |
= 1.7.1 =
|
144 |
* HTML content support in Google Map InfoWindow
|
145 |
* Added select drop-down in Google map SRM widget instead of text box for ShortCode.
|
srm_gmap_embed.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
Text Domain: gmap-embed
|
8 |
Domain Path: /languages
|
9 |
Author URI: https://www.srmilon.info
|
10 |
-
Version: 1.7.
|
11 |
*/
|
12 |
|
13 |
if ( ! defined( 'ABSPATH' ) ) {
|
@@ -65,14 +65,30 @@ if ( ! class_exists( 'srm_gmap_embed_main' ) ) {
|
|
65 |
$srm_gmap_lng = get_option( 'srm_gmap_lng', 'en' );
|
66 |
$srm_gmap_region = get_option( 'srm_gmap_region', 'US' );
|
67 |
wp_enqueue_script( 'wp-gmap-api', 'https://maps.google.com/maps/api/js?key=' . $this->wpgmap_api_key . '&libraries=places&language=' . $srm_gmap_lng . '®ion=' . $srm_gmap_region, array( 'jquery' ), '20200506', true );
|
68 |
-
wp_enqueue_script( 'wp-gmap-custom-js', plugins_url( 'assets/js/custom.js', __FILE__ ), array( 'wp-gmap-api' ), '
|
69 |
-
wp_enqueue_style( 'wp-gmap-embed-css', plugins_url( 'assets/css/wp-gmap-style.css', __FILE__ ),
|
70 |
|
71 |
// For media upload
|
72 |
wp_enqueue_script( 'media-upload' );
|
73 |
wp_enqueue_script( 'thickbox' );
|
74 |
wp_enqueue_script( 'wpgmap-media-upload' );
|
75 |
wp_enqueue_style( 'thickbox' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
}
|
78 |
|
@@ -141,6 +157,7 @@ if ( ! class_exists( 'srm_gmap_embed_main' ) ) {
|
|
141 |
'wpgmap_title' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_title'] ) ),
|
142 |
'wpgmap_heading_class' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_heading_class'] ) ),
|
143 |
'wpgmap_show_heading' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_show_heading'] ) ),
|
|
|
144 |
'wpgmap_latlng' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_latlng'] ) ),
|
145 |
'wpgmap_map_zoom' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_map_zoom'] ) ),
|
146 |
'wpgmap_disable_zoom_scroll' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_disable_zoom_scroll'] ) ),
|
@@ -150,7 +167,9 @@ if ( ! class_exists( 'srm_gmap_embed_main' ) ) {
|
|
150 |
'wpgmap_map_address' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_map_address'] ) ),
|
151 |
'wpgmap_show_infowindow' => sanitize_text_field( $_POST['map_data']['wpgmap_show_infowindow'] ),
|
152 |
'wpgmap_enable_direction' => sanitize_text_field( $_POST['map_data']['wpgmap_enable_direction'] ),
|
153 |
-
'wpgmap_marker_icon' => sanitize_text_field( $_POST['map_data']['wpgmap_marker_icon'] )
|
|
|
|
|
154 |
);
|
155 |
$action_type = sanitize_text_field( esc_html( $_POST['map_data']['action_type'] ) );
|
156 |
if ( $meta_data['wpgmap_latlng'] == '' ) {
|
@@ -228,18 +247,19 @@ if ( ! class_exists( 'srm_gmap_embed_main' ) ) {
|
|
228 |
}
|
229 |
} else {
|
230 |
ob_start();
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
238 |
<h3>Frequently asked questions</h3>
|
239 |
-
|
240 |
require_once( plugin_dir_path( __FILE__ ) . 'includes/wpgmap_faqs.php' );
|
241 |
echo '</div>';
|
242 |
-
|
243 |
}
|
244 |
|
245 |
echo $content;
|
@@ -287,6 +307,7 @@ if ( ! class_exists( 'srm_gmap_embed_main' ) ) {
|
|
287 |
}
|
288 |
|
289 |
$gmap_data = array(
|
|
|
290 |
'wpgmap_title' => get_post_meta( $gmap_id, 'wpgmap_title', true ),
|
291 |
'wpgmap_heading_class' => get_post_meta( $gmap_id, 'wpgmap_heading_class', true ),
|
292 |
'wpgmap_show_heading' => get_post_meta( $gmap_id, 'wpgmap_show_heading', true ),
|
@@ -299,7 +320,8 @@ if ( ! class_exists( 'srm_gmap_embed_main' ) ) {
|
|
299 |
'wpgmap_map_address' => get_post_meta( $gmap_id, 'wpgmap_map_address', true ),
|
300 |
'wpgmap_show_infowindow' => get_post_meta( $gmap_id, 'wpgmap_show_infowindow', true ),
|
301 |
'wpgmap_enable_direction' => get_post_meta( $gmap_id, 'wpgmap_enable_direction', true ),
|
302 |
-
'wpgmap_marker_icon' => get_post_meta( $gmap_id, 'wpgmap_marker_icon', true )
|
|
|
303 |
);
|
304 |
|
305 |
return json_encode( $gmap_data );
|
@@ -393,7 +415,7 @@ if ( ! class_exists( 'srm_gmap_embed_main' ) ) {
|
|
393 |
//$this->gmap_embed_new_feature_admin_notice();
|
394 |
}
|
395 |
|
396 |
-
private function gmap_embed_generate_admin_review_notice(){
|
397 |
$gmap_embed_activation_time = get_option( 'gmap_embed_activation_time', false );
|
398 |
$seconds_diff = time() - $gmap_embed_activation_time;
|
399 |
$passed_days = ( $seconds_diff / 3600 ) / 24;
|
@@ -421,7 +443,7 @@ Just to help us spread the word and boost our motivation.!<br/>- <i>SRMILON</i><
|
|
421 |
}
|
422 |
}
|
423 |
|
424 |
-
private function gmap_embed_new_feature_admin_notice(){
|
425 |
if ( get_option( 'srm_gmap_lng' ) == false and isset( $_GET['page'] ) and $_GET['page'] == 'wpgmapembed') {
|
426 |
|
427 |
?>
|
7 |
Text Domain: gmap-embed
|
8 |
Domain Path: /languages
|
9 |
Author URI: https://www.srmilon.info
|
10 |
+
Version: 1.7.2
|
11 |
*/
|
12 |
|
13 |
if ( ! defined( 'ABSPATH' ) ) {
|
65 |
$srm_gmap_lng = get_option( 'srm_gmap_lng', 'en' );
|
66 |
$srm_gmap_region = get_option( 'srm_gmap_region', 'US' );
|
67 |
wp_enqueue_script( 'wp-gmap-api', 'https://maps.google.com/maps/api/js?key=' . $this->wpgmap_api_key . '&libraries=places&language=' . $srm_gmap_lng . '®ion=' . $srm_gmap_region, array( 'jquery' ), '20200506', true );
|
68 |
+
wp_enqueue_script( 'wp-gmap-custom-js', plugins_url( 'assets/js/custom.js', __FILE__ ), array( 'wp-gmap-api' ), filemtime(__DIR__.'/assets/js/custom.js'), false );
|
69 |
+
wp_enqueue_style( 'wp-gmap-embed-css', plugins_url( 'assets/css/wp-gmap-style.css', __FILE__ ), array(),filemtime(__DIR__.'/assets/css/wp-gmap-style.css') );
|
70 |
|
71 |
// For media upload
|
72 |
wp_enqueue_script( 'media-upload' );
|
73 |
wp_enqueue_script( 'thickbox' );
|
74 |
wp_enqueue_script( 'wpgmap-media-upload' );
|
75 |
wp_enqueue_style( 'thickbox' );
|
76 |
+
if(isset($_GET['tag']) and $_GET['tag']=='edit'){
|
77 |
+
// enqueue scripts for localization
|
78 |
+
wp_register_script( 'wp-gmap-lz-script', plugins_url( 'assets/js/localized_script.js', __FILE__ ), array( 'wp-gmap-custom-js' ), filemtime(__DIR__.'/assets/js/localized_script.js'), true);
|
79 |
+
// Localize the script with new data
|
80 |
+
$current_map_marker_lat_lng = explode(',', get_post_meta( $_GET['id'], 'wpgmap_latlng', true ));
|
81 |
+
$current_map_marker_lat = isset($current_map_marker_lat_lng[0])?$current_map_marker_lat_lng[0]:40.73359922990751;
|
82 |
+
$current_map_marker_lng = isset($current_map_marker_lat_lng[1])?$current_map_marker_lat_lng[1]:-74.02791395625002;
|
83 |
+
$translation_array = array(
|
84 |
+
'current_map_marker_lat' => $current_map_marker_lat,
|
85 |
+
'current_map_marker_lng' => $current_map_marker_lng
|
86 |
+
);
|
87 |
+
wp_localize_script( 'wp-gmap-lz-script', 'gmap_object', $translation_array );
|
88 |
+
|
89 |
+
// Enqueued script with localized data.
|
90 |
+
wp_enqueue_script( 'wp-gmap-lz-script' );
|
91 |
+
}
|
92 |
}
|
93 |
}
|
94 |
|
157 |
'wpgmap_title' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_title'] ) ),
|
158 |
'wpgmap_heading_class' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_heading_class'] ) ),
|
159 |
'wpgmap_show_heading' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_show_heading'] ) ),
|
160 |
+
// current marker lat lng
|
161 |
'wpgmap_latlng' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_latlng'] ) ),
|
162 |
'wpgmap_map_zoom' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_map_zoom'] ) ),
|
163 |
'wpgmap_disable_zoom_scroll' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_disable_zoom_scroll'] ) ),
|
167 |
'wpgmap_map_address' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_map_address'] ) ),
|
168 |
'wpgmap_show_infowindow' => sanitize_text_field( $_POST['map_data']['wpgmap_show_infowindow'] ),
|
169 |
'wpgmap_enable_direction' => sanitize_text_field( $_POST['map_data']['wpgmap_enable_direction'] ),
|
170 |
+
'wpgmap_marker_icon' => sanitize_text_field( $_POST['map_data']['wpgmap_marker_icon'] ),
|
171 |
+
// map center lat lng
|
172 |
+
'wpgmap_center_lat_lng' => sanitize_text_field( $_POST['map_data']['wpgmap_center_lat_lng'] )
|
173 |
);
|
174 |
$action_type = sanitize_text_field( esc_html( $_POST['map_data']['action_type'] ) );
|
175 |
if ( $meta_data['wpgmap_latlng'] == '' ) {
|
247 |
}
|
248 |
} else {
|
249 |
ob_start();
|
250 |
+
?>
|
251 |
+
<a style="padding: 9px;margin-left:100px;border-radius: 5px;background-color: #0073aa;color: white;text-decoration: none;font-weight: bold;font-size: 11px;"
|
252 |
+
href="<?php echo esc_url( admin_url() ) . 'admin.php?page=wpgmapembed&tag=new'; ?>"
|
253 |
+
data-id="wp-gmap-new" class="media-menu-item">
|
254 |
+
<i class="dashicons dashicons-plus"></i>
|
255 |
+
<?php echo __( "Create Your First Map", "gmap-embed" ); ?>
|
256 |
+
</a>
|
257 |
+
<br/><br/><div class="srm_gmap_instructions">
|
258 |
<h3>Frequently asked questions</h3>
|
259 |
+
<?php
|
260 |
require_once( plugin_dir_path( __FILE__ ) . 'includes/wpgmap_faqs.php' );
|
261 |
echo '</div>';
|
262 |
+
$content .= ob_get_clean();
|
263 |
}
|
264 |
|
265 |
echo $content;
|
307 |
}
|
308 |
|
309 |
$gmap_data = array(
|
310 |
+
'wpgmap_id' => $gmap_id,
|
311 |
'wpgmap_title' => get_post_meta( $gmap_id, 'wpgmap_title', true ),
|
312 |
'wpgmap_heading_class' => get_post_meta( $gmap_id, 'wpgmap_heading_class', true ),
|
313 |
'wpgmap_show_heading' => get_post_meta( $gmap_id, 'wpgmap_show_heading', true ),
|
320 |
'wpgmap_map_address' => get_post_meta( $gmap_id, 'wpgmap_map_address', true ),
|
321 |
'wpgmap_show_infowindow' => get_post_meta( $gmap_id, 'wpgmap_show_infowindow', true ),
|
322 |
'wpgmap_enable_direction' => get_post_meta( $gmap_id, 'wpgmap_enable_direction', true ),
|
323 |
+
'wpgmap_marker_icon' => get_post_meta( $gmap_id, 'wpgmap_marker_icon', true ),
|
324 |
+
'wpgmap_center_lat_lng' => get_center_lat_lng_by_map_id($gmap_id)
|
325 |
);
|
326 |
|
327 |
return json_encode( $gmap_data );
|
415 |
//$this->gmap_embed_new_feature_admin_notice();
|
416 |
}
|
417 |
|
418 |
+
private function gmap_embed_generate_admin_review_notice() {
|
419 |
$gmap_embed_activation_time = get_option( 'gmap_embed_activation_time', false );
|
420 |
$seconds_diff = time() - $gmap_embed_activation_time;
|
421 |
$passed_days = ( $seconds_diff / 3600 ) / 24;
|
443 |
}
|
444 |
}
|
445 |
|
446 |
+
private function gmap_embed_new_feature_admin_notice() {
|
447 |
if ( get_option( 'srm_gmap_lng' ) == false and isset( $_GET['page'] ) and $_GET['page'] == 'wpgmapembed') {
|
448 |
|
449 |
?>
|