Version Description
Upgrade Google Map Plugin from here to get updated features.
Download this release
Release Info
Developer | milonfci |
Plugin | WP Google Map |
Version | 1.5.4 |
Comparing to | |
See all releases |
Code changes from version 1.5.3 to 1.5.4
- assets/css/wp-gmap-style.css +43 -5
- assets/js/custom.js +6 -3
- assets/js/geo_based_map_create.js +128 -75
- assets/js/geo_based_map_edit.js +109 -55
- includes/gmap.php +2 -2
- includes/shortcodes.php +58 -54
- includes/wpgmap_create.php +134 -103
- includes/wpgmap_edit.php +166 -118
- readme.txt +5 -2
- srm_gmap_embed.php +292 -288
assets/css/wp-gmap-style.css
CHANGED
@@ -130,13 +130,20 @@ ul#wp-gmap-nav li a {
|
|
130 |
}
|
131 |
|
132 |
/******* Map Properties ******/
|
133 |
-
.wp-gmap-properties {
|
134 |
-
width:
|
135 |
-
|
136 |
-
border: 1px #ccc solid;
|
137 |
-
background-color: #f3f3f3;
|
138 |
margin: 9px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
float: left;
|
|
|
|
|
140 |
}
|
141 |
|
142 |
.gmap_properties tr {
|
@@ -241,4 +248,35 @@ ul#wp-gmap-nav li a {
|
|
241 |
font-weight: bold !important;
|
242 |
margin: 5px 0 0 5px !important;
|
243 |
color: #238b68 !important;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
}
|
130 |
}
|
131 |
|
132 |
/******* Map Properties ******/
|
133 |
+
.wp-gmap-properties-outer {
|
134 |
+
width: 32%;
|
135 |
+
float: left;
|
|
|
|
|
136 |
margin: 9px;
|
137 |
+
border: 1px #ccc solid;
|
138 |
+
|
139 |
+
}
|
140 |
+
|
141 |
+
.wp-gmap-properties, .wp-gmap-other-properties {
|
142 |
+
width: 98.1%;
|
143 |
+
background-color: white;
|
144 |
float: left;
|
145 |
+
padding: 5px 1% 1% 1%;
|
146 |
+
|
147 |
}
|
148 |
|
149 |
.gmap_properties tr {
|
248 |
font-weight: bold !important;
|
249 |
margin: 5px 0 0 5px !important;
|
250 |
color: #238b68 !important;;
|
251 |
+
}
|
252 |
+
|
253 |
+
/* Updated 31.01.2020*/
|
254 |
+
.wpgmap_tab_menu {
|
255 |
+
width: 100%;
|
256 |
+
background-color: #ccc;
|
257 |
+
float: left;
|
258 |
+
height: 30px;
|
259 |
+
}
|
260 |
+
|
261 |
+
ul.wpgmap_tab {
|
262 |
+
padding: 0;
|
263 |
+
margin: 0;
|
264 |
+
height: 30px;
|
265 |
+
}
|
266 |
+
|
267 |
+
.wpgmap_tab li {
|
268 |
+
display: inline;
|
269 |
+
padding: 6px 6px;
|
270 |
+
float: left;
|
271 |
+
background-color: #ccc;
|
272 |
+
border-right: 1px white solid;
|
273 |
+
cursor: pointer;
|
274 |
+
}
|
275 |
+
|
276 |
+
.wpgmap_tab li:hover, .wpgmap_tab .active {
|
277 |
+
background-color: white;
|
278 |
+
}
|
279 |
+
|
280 |
+
.hidden {
|
281 |
+
display: none;
|
282 |
}
|
assets/js/custom.js
CHANGED
@@ -43,6 +43,7 @@
|
|
43 |
function readyGmapPopupWindow() {
|
44 |
loadSrmGmapsList();
|
45 |
}
|
|
|
46 |
window.onload = readyGmapPopupWindow;
|
47 |
|
48 |
//******* To insert ShortCode From List *******
|
@@ -125,6 +126,7 @@
|
|
125 |
var wpgmap_map_height = parent.find("#wpgmap_map_height").val();
|
126 |
var wpgmap_map_type = parent.find("#wpgmap_map_type").val();
|
127 |
var wpgmap_map_address = parent.find("#wpgmap_map_address").val();
|
|
|
128 |
|
129 |
var map_data = {
|
130 |
wpgmap_title: wpgmap_title,
|
@@ -138,7 +140,8 @@
|
|
138 |
wpgmap_map_type: wpgmap_map_type,
|
139 |
wpgmap_map_address: wpgmap_map_address,
|
140 |
wpgmap_show_infowindow: wpgmap_show_infowindow,
|
141 |
-
wpgmap_enable_direction: wpgmap_enable_direction
|
|
|
142 |
};
|
143 |
|
144 |
if (btn_id == 'wp-gmap-embed-save') {
|
@@ -166,8 +169,8 @@
|
|
166 |
if (btn_id == 'wp-gmap-embed-save' || btn_id == 'wp-gmap-embed-update') {
|
167 |
|
168 |
$("#" + btn_id).prop('disabled', false);
|
169 |
-
var redirectTo = (btn_id == 'wp-gmap-embed-save')?1:2;
|
170 |
-
window.location.href = '?page=wpgmapembed&message='+redirectTo;
|
171 |
$('body #wp-gmap-all .wpgmap_msg_error').html('<div class="success bellow-h2 notice notice-success is-dismissible"><p>' + response.message + '</p></div>');
|
172 |
}
|
173 |
$("#wpgmap_title,#wpgmap_latlng, #wpgmap_map_address").val("");
|
43 |
function readyGmapPopupWindow() {
|
44 |
loadSrmGmapsList();
|
45 |
}
|
46 |
+
|
47 |
window.onload = readyGmapPopupWindow;
|
48 |
|
49 |
//******* To insert ShortCode From List *******
|
126 |
var wpgmap_map_height = parent.find("#wpgmap_map_height").val();
|
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,
|
140 |
wpgmap_map_type: wpgmap_map_type,
|
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') {
|
169 |
if (btn_id == 'wp-gmap-embed-save' || btn_id == 'wp-gmap-embed-update') {
|
170 |
|
171 |
$("#" + btn_id).prop('disabled', false);
|
172 |
+
var redirectTo = (btn_id == 'wp-gmap-embed-save') ? 1 : 2;
|
173 |
+
window.location.href = '?page=wpgmapembed&message=' + redirectTo;
|
174 |
$('body #wp-gmap-all .wpgmap_msg_error').html('<div class="success bellow-h2 notice notice-success is-dismissible"><p>' + response.message + '</p></div>');
|
175 |
}
|
176 |
$("#wpgmap_title,#wpgmap_latlng, #wpgmap_map_address").val("");
|
assets/js/geo_based_map_create.js
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
var map;
|
2 |
-
|
3 |
-
|
|
|
|
|
4 |
|
5 |
// Getting detailed address by lat,lng
|
6 |
-
function wpgmapSetAddressByLatLng(lat, lng
|
7 |
jQuery.getJSON('https://maps.googleapis.com/maps/api/geocode/json?key=' + wp_gmap_api_key + '&latlng=' + lat + ',' + lng + '&sensor=true')
|
8 |
.done(function (location) {
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
});
|
12 |
|
13 |
}
|
14 |
|
15 |
-
//
|
16 |
-
function
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
}
|
26 |
-
else if (map_type === 'SATELLITE') {
|
27 |
-
map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
|
28 |
-
}
|
29 |
-
else if (map_type === 'HYBRID') {
|
30 |
-
map.setMapTypeId(google.maps.MapTypeId.HYBRID);
|
31 |
-
}
|
32 |
-
else if (map_type === 'TERRAIN') {
|
33 |
-
map.setMapTypeId(google.maps.MapTypeId.TERRAIN);
|
34 |
-
}
|
35 |
-
|
36 |
-
map.setCenter({lat: center_lat, lng: center_lng});
|
37 |
-
marker1 = new google.maps.Marker({
|
38 |
-
position: new google.maps.LatLng(center_lat, center_lng),
|
39 |
-
title: "",
|
40 |
-
draggable: true,
|
41 |
-
animation: google.maps.Animation.DROP
|
42 |
-
});
|
43 |
-
marker1.setMap(map);
|
44 |
-
marker1.addListener('dragend', function (markerLocation) {
|
45 |
-
document.getElementById("wpgmap_latlng").value = markerLocation.latLng.lat() + "," + markerLocation.latLng.lng();
|
46 |
-
wpgmapSetAddressByLatLng(markerLocation.latLng.lat(), markerLocation.latLng.lng());
|
47 |
-
});
|
48 |
-
return false;
|
49 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
|
|
|
|
51 |
var gmap_settings = {
|
52 |
center: {lat: center_lat, lng: center_lng},
|
53 |
zoom: zoom,
|
@@ -65,18 +65,45 @@ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
|
65 |
else if (map_type === 'TERRAIN') {
|
66 |
gmap_settings.mapTypeId = google.maps.MapTypeId.TERRAIN;
|
67 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
-
map = new google.maps.Map(
|
70 |
marker1 = new google.maps.Marker({
|
71 |
position: new google.maps.LatLng(center_lat, center_lng),
|
72 |
title: "",
|
73 |
draggable: true,
|
74 |
animation: google.maps.Animation.DROP
|
75 |
});
|
|
|
|
|
76 |
marker1.setMap(map);
|
77 |
|
78 |
-
//
|
79 |
-
|
80 |
var searchBox = new google.maps.places.SearchBox(input);
|
81 |
google.maps.event.addDomListener(window, "load", function () {
|
82 |
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
|
@@ -112,16 +139,22 @@ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
|
112 |
return;
|
113 |
}
|
114 |
// Create a marker for each place.
|
115 |
-
|
116 |
map: map,
|
117 |
title: place.name,
|
118 |
draggable: true,
|
119 |
-
position: place.geometry.location
|
120 |
-
|
|
|
|
|
|
|
121 |
marker1.position = place.geometry.location;
|
122 |
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
125 |
|
126 |
if (place.geometry.viewport) {
|
127 |
// Only geocodes have viewport.
|
@@ -131,20 +164,31 @@ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
|
131 |
}
|
132 |
});
|
133 |
map.fitBounds(bounds);
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
});
|
138 |
});
|
139 |
|
140 |
}
|
141 |
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
|
|
144 |
function initWpGmap(lat, lng, map_type) {
|
145 |
-
initAutocomplete('map', 'pac-input', lat, lng, map_type, parseInt(
|
146 |
}
|
147 |
|
|
|
148 |
var tryAPIGeolocation = function () {
|
149 |
jQuery.post("https://www.googleapis.com/geolocation/v1/geolocate?key=" + wp_gmap_api_key, function (success) {
|
150 |
initWpGmap(success.location.lat, success.location.lng, 'ROADMAP');
|
@@ -185,18 +229,6 @@ var tryGeolocation = function () {
|
|
185 |
}
|
186 |
};
|
187 |
|
188 |
-
function openInfoWindow() {
|
189 |
-
if (jQuery('#wpgmap_show_infowindow').is(':checked')) {
|
190 |
-
initWpGmap(marker1.position.lat(), marker1.position.lng(), 'roadmap');
|
191 |
-
var gmap_embed_address = jQuery("#wpgmap_map_address").val();
|
192 |
-
infowindow = new google.maps.InfoWindow({
|
193 |
-
content: gmap_embed_address
|
194 |
-
});
|
195 |
-
infowindow.open(map, marker1);
|
196 |
-
} else {
|
197 |
-
infowindow.close();
|
198 |
-
}
|
199 |
-
}
|
200 |
|
201 |
// ========================Show in marker infowindow Toggle=========================
|
202 |
jQuery('#wpgmap_show_infowindow').click('change', function (element) {
|
@@ -216,18 +248,10 @@ jQuery(document.body).find('#wpgmap_map_address').on('keyup', function (element)
|
|
216 |
infowindow.setContent(jQuery(this).val());
|
217 |
});
|
218 |
|
219 |
-
// jQuery('#wpgmap_show_heading').click('change', function (element) {
|
220 |
-
// if (jQuery('#wpgmap_show_heading').is(':checked')) {
|
221 |
-
// jQuery('#wpgmap_heading_preview').css({'display': 'block'}).html(jQuery('#wpgmap_title').val());
|
222 |
-
// } else {
|
223 |
-
// jQuery('#wpgmap_heading_preview').css({'display': 'none'});
|
224 |
-
// }
|
225 |
-
// });
|
226 |
-
|
227 |
// ========================On address field text change=========================
|
228 |
jQuery(document.body).find('#wpgmap_title').on('keyup', function (element) {
|
229 |
// if (jQuery('#wpgmap_show_heading').is(':checked')) {
|
230 |
-
|
231 |
// }
|
232 |
});
|
233 |
|
@@ -237,4 +261,33 @@ jQuery(document.body).find('#wpgmap_map_type').on('change', function (element) {
|
|
237 |
initWpGmap(marker1.position.lat(), marker1.position.lng(), map_type);
|
238 |
});
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
tryGeolocation();
|
1 |
+
var map, marker1, infowindow, icon = 'https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi2.png';
|
2 |
+
|
3 |
+
function _e(id) {
|
4 |
+
return document.getElementById(id);
|
5 |
+
}
|
6 |
|
7 |
// Getting detailed address by lat,lng
|
8 |
+
function wpgmapSetAddressByLatLng(lat, lng) {
|
9 |
jQuery.getJSON('https://maps.googleapis.com/maps/api/geocode/json?key=' + wp_gmap_api_key + '&latlng=' + lat + ',' + lng + '&sensor=true')
|
10 |
.done(function (location) {
|
11 |
+
_e('wpgmap_map_address').value = location.results[0].formatted_address;
|
12 |
+
})
|
13 |
+
.fail(function (d) {
|
14 |
+
console.log(d);
|
15 |
+
})
|
16 |
+
.always(function (d) {
|
17 |
+
console.log(d);
|
18 |
});
|
19 |
|
20 |
}
|
21 |
|
22 |
+
// Generating already initialized map
|
23 |
+
function generateAlreadyInitiztedMap(map_type, center_lat, center_lng) {
|
24 |
+
if (map_type === 'ROADMAP') {
|
25 |
+
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
|
26 |
+
}
|
27 |
+
else if (map_type === 'SATELLITE') {
|
28 |
+
map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
|
29 |
+
}
|
30 |
+
else if (map_type === 'HYBRID') {
|
31 |
+
map.setMapTypeId(google.maps.MapTypeId.HYBRID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
+
else if (map_type === 'TERRAIN') {
|
34 |
+
map.setMapTypeId(google.maps.MapTypeId.TERRAIN);
|
35 |
+
}
|
36 |
+
|
37 |
+
map.setCenter({lat: center_lat, lng: center_lng});
|
38 |
+
marker1 = new google.maps.Marker({
|
39 |
+
position: new google.maps.LatLng(center_lat, center_lng),
|
40 |
+
title: "",
|
41 |
+
draggable: true,
|
42 |
+
animation: google.maps.Animation.DROP
|
43 |
+
});
|
44 |
+
marker1.setMap(map);
|
45 |
+
// Adding dragend Event Listener
|
46 |
+
addMarkerDragendListener(marker1);
|
47 |
+
}
|
48 |
|
49 |
+
// Set map settings for by map Type
|
50 |
+
function setMapSettingsByMapType(map_type, center_lat, center_lng, zoom) {
|
51 |
var gmap_settings = {
|
52 |
center: {lat: center_lat, lng: center_lng},
|
53 |
zoom: zoom,
|
65 |
else if (map_type === 'TERRAIN') {
|
66 |
gmap_settings.mapTypeId = google.maps.MapTypeId.TERRAIN;
|
67 |
}
|
68 |
+
return gmap_settings;
|
69 |
+
}
|
70 |
+
|
71 |
+
function addMarkerDragendListener(marker) {
|
72 |
+
marker.addListener('dragend', function (markerLocation) {
|
73 |
+
_e("wpgmap_latlng").value = markerLocation.latLng.lat() + "," + markerLocation.latLng.lng();
|
74 |
+
wpgmapSetAddressByLatLng(markerLocation.latLng.lat(), markerLocation.latLng.lng());
|
75 |
+
});
|
76 |
+
}
|
77 |
+
|
78 |
+
// To render Google Map
|
79 |
+
function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
80 |
+
|
81 |
+
// Set address by Lat Lng
|
82 |
+
_e("wpgmap_latlng").value = center_lat + "," + center_lng;
|
83 |
+
wpgmapSetAddressByLatLng(center_lat, center_lng);
|
84 |
+
|
85 |
+
// In acse of already initiated map
|
86 |
+
if (typeof map === 'object') {
|
87 |
+
generateAlreadyInitiztedMap(map_type, center_lat, center_lng);
|
88 |
+
return false;
|
89 |
+
}
|
90 |
+
|
91 |
+
// Set Map Settings by Map Type
|
92 |
+
var gmap_settings = setMapSettingsByMapType(map_type, center_lat, center_lng, zoom);
|
93 |
|
94 |
+
map = new google.maps.Map(_e(id), gmap_settings);
|
95 |
marker1 = new google.maps.Marker({
|
96 |
position: new google.maps.LatLng(center_lat, center_lng),
|
97 |
title: "",
|
98 |
draggable: true,
|
99 |
animation: google.maps.Animation.DROP
|
100 |
});
|
101 |
+
// Add dragend event listener
|
102 |
+
addMarkerDragendListener(marker1);
|
103 |
marker1.setMap(map);
|
104 |
|
105 |
+
// Create the search box and link it to the UI element.
|
106 |
+
input = document.getElementById(input);
|
107 |
var searchBox = new google.maps.places.SearchBox(input);
|
108 |
google.maps.event.addDomListener(window, "load", function () {
|
109 |
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
|
139 |
return;
|
140 |
}
|
141 |
// Create a marker for each place.
|
142 |
+
marker1 = new google.maps.Marker({
|
143 |
map: map,
|
144 |
title: place.name,
|
145 |
draggable: true,
|
146 |
+
position: place.geometry.location,
|
147 |
+
icon: icon
|
148 |
+
});
|
149 |
+
markers.push(marker1);
|
150 |
+
openInfoWindow();
|
151 |
marker1.position = place.geometry.location;
|
152 |
|
153 |
+
// Add Marker event listener
|
154 |
+
addMarkerDragendListener(marker1);
|
155 |
+
|
156 |
+
_e('wpgmap_map_address').value = place.formatted_address;
|
157 |
+
_e("wpgmap_latlng").value = place.geometry.location.lat() + "," + place.geometry.location.lng();
|
158 |
|
159 |
if (place.geometry.viewport) {
|
160 |
// Only geocodes have viewport.
|
164 |
}
|
165 |
});
|
166 |
map.fitBounds(bounds);
|
167 |
+
|
168 |
+
// Add Marker event listener
|
169 |
+
addMarkerDragendListener(markers[0]);
|
|
|
170 |
});
|
171 |
|
172 |
}
|
173 |
|
174 |
+
function openInfoWindow() {
|
175 |
+
if (jQuery('#wpgmap_show_infowindow').is(':checked')) {
|
176 |
+
var gmap_embed_address = jQuery("#wpgmap_map_address").val();
|
177 |
+
infowindow = new google.maps.InfoWindow({
|
178 |
+
content: gmap_embed_address
|
179 |
+
});
|
180 |
+
infowindow.open(map, marker1);
|
181 |
+
} else {
|
182 |
+
infowindow.close();
|
183 |
+
}
|
184 |
+
}
|
185 |
|
186 |
+
// Initialize Map
|
187 |
function initWpGmap(lat, lng, map_type) {
|
188 |
+
initAutocomplete('map', 'pac-input', lat, lng, map_type, parseInt(_e('wpgmap_map_zoom').value));
|
189 |
}
|
190 |
|
191 |
+
|
192 |
var tryAPIGeolocation = function () {
|
193 |
jQuery.post("https://www.googleapis.com/geolocation/v1/geolocate?key=" + wp_gmap_api_key, function (success) {
|
194 |
initWpGmap(success.location.lat, success.location.lng, 'ROADMAP');
|
229 |
}
|
230 |
};
|
231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
// ========================Show in marker infowindow Toggle=========================
|
234 |
jQuery('#wpgmap_show_infowindow').click('change', function (element) {
|
248 |
infowindow.setContent(jQuery(this).val());
|
249 |
});
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
// ========================On address field text change=========================
|
252 |
jQuery(document.body).find('#wpgmap_title').on('keyup', function (element) {
|
253 |
// if (jQuery('#wpgmap_show_heading').is(':checked')) {
|
254 |
+
jQuery('#wpgmap_heading_preview').css({'display': 'block'}).html(jQuery('#wpgmap_title').val());
|
255 |
// }
|
256 |
});
|
257 |
|
261 |
initWpGmap(marker1.position.lat(), marker1.position.lng(), map_type);
|
262 |
});
|
263 |
|
264 |
+
jQuery(document.body).find('.wpgmap_tab li').on('click', function (e) {
|
265 |
+
e.preventDefault();
|
266 |
+
jQuery('.wpgmap_tab li').removeClass('active');
|
267 |
+
jQuery(this).addClass('active');
|
268 |
+
|
269 |
+
jQuery('.wp-gmap-tab-contents').addClass('hidden');
|
270 |
+
var wpgmap_id = jQuery(this).attr('id');
|
271 |
+
jQuery('.' + wpgmap_id).removeClass('hidden');
|
272 |
+
});
|
273 |
+
|
274 |
+
|
275 |
+
// ========================================For Media Upload===================================
|
276 |
+
jQuery(document).ready(function ($) {
|
277 |
+
|
278 |
+
$('#upload_image_button').click(function () {
|
279 |
+
|
280 |
+
formfield = $('#upload_image').attr('name');
|
281 |
+
tb_show('Upload your marker image', 'media-upload.php?type=image&TB_iframe=true');
|
282 |
+
window.send_to_editor = function (html) {
|
283 |
+
icon = $(html).attr('src');
|
284 |
+
$('#wpgmap_upload_hidden').val(icon);
|
285 |
+
tb_remove();
|
286 |
+
marker1.setIcon(icon);
|
287 |
+
jQuery("#wpgmap_icon_img").attr('src', icon);
|
288 |
+
};
|
289 |
+
return false;
|
290 |
+
});
|
291 |
+
});
|
292 |
+
|
293 |
tryGeolocation();
|
assets/js/geo_based_map_edit.js
CHANGED
@@ -1,56 +1,53 @@
|
|
1 |
-
var map;
|
2 |
-
|
3 |
-
|
|
|
|
|
4 |
|
5 |
// Getting detailed address by lat,lng
|
6 |
function wpgmapSetAddressByLatLng(lat, lng, id) {
|
7 |
jQuery.getJSON('https://maps.googleapis.com/maps/api/geocode/json?key=' + wp_gmap_api_key + '&latlng=' + lat + ',' + lng + '&sensor=true')
|
8 |
.done(function (location) {
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
});
|
12 |
|
13 |
}
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
}
|
29 |
-
else if (map_type === 'SATELLITE') {
|
30 |
-
map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
|
31 |
-
}
|
32 |
-
else if (map_type === 'HYBRID') {
|
33 |
-
map.setMapTypeId(google.maps.MapTypeId.HYBRID);
|
34 |
-
}
|
35 |
-
else if (map_type === 'TERRAIN') {
|
36 |
-
map.setMapTypeId(google.maps.MapTypeId.TERRAIN);
|
37 |
-
}
|
38 |
-
|
39 |
-
map.setCenter({lat: center_lat, lng: center_lng});
|
40 |
-
marker1 = new google.maps.Marker({
|
41 |
-
position: new google.maps.LatLng(center_lat, center_lng),
|
42 |
-
title: "",
|
43 |
-
draggable: true,
|
44 |
-
animation: google.maps.Animation.DROP
|
45 |
-
});
|
46 |
-
marker1.setMap(map);
|
47 |
-
marker1.addListener('dragend', function (markerLocation) {
|
48 |
-
document.getElementById("wpgmap_latlng").value = markerLocation.latLng.lat() + "," + markerLocation.latLng.lng();
|
49 |
-
wpgmapSetAddressByLatLng(markerLocation.latLng.lat(), markerLocation.latLng.lng());
|
50 |
-
});
|
51 |
-
return false;
|
52 |
}
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
var gmap_settings = {
|
55 |
center: {lat: center_lat, lng: center_lng},
|
56 |
zoom: zoom,
|
@@ -68,18 +65,44 @@ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
|
68 |
else if (map_type === 'TERRAIN') {
|
69 |
gmap_settings.mapTypeId = google.maps.MapTypeId.TERRAIN;
|
70 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
-
map = new google.maps.Map(
|
73 |
marker1 = new google.maps.Marker({
|
74 |
position: new google.maps.LatLng(center_lat, center_lng),
|
75 |
title: "",
|
76 |
draggable: true,
|
77 |
-
animation: google.maps.Animation.DROP
|
|
|
78 |
});
|
|
|
|
|
79 |
marker1.setMap(map);
|
80 |
|
81 |
// // Create the search box and link it to the UI element.
|
82 |
-
|
83 |
var searchBox = new google.maps.places.SearchBox(input);
|
84 |
google.maps.event.addDomListener(window, "load", function () {
|
85 |
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
|
@@ -115,16 +138,18 @@ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
|
115 |
return;
|
116 |
}
|
117 |
// Create a marker for each place.
|
118 |
-
|
119 |
map: map,
|
120 |
title: place.name,
|
121 |
draggable: true,
|
122 |
-
position: place.geometry.location
|
123 |
-
|
|
|
|
|
124 |
marker1.position = place.geometry.location;
|
125 |
|
126 |
-
|
127 |
-
|
128 |
|
129 |
if (place.geometry.viewport) {
|
130 |
// Only geocodes have viewport.
|
@@ -134,14 +159,16 @@ function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
|
134 |
}
|
135 |
});
|
136 |
map.fitBounds(bounds);
|
137 |
-
|
138 |
-
|
139 |
-
wpgmapSetAddressByLatLng(markerLocation.latLng.lat(), markerLocation.latLng.lng());
|
140 |
-
});
|
141 |
});
|
142 |
|
143 |
}
|
144 |
|
|
|
|
|
|
|
|
|
145 |
function openInfoWindow() {
|
146 |
if (jQuery('#wpgmap_show_infowindow').is(':checked')) {
|
147 |
// initWpGmap(marker1.position.lat(), marker1.position.lng(), 'roadmap');
|
@@ -156,7 +183,6 @@ function openInfoWindow() {
|
|
156 |
}
|
157 |
|
158 |
|
159 |
-
|
160 |
// ========================Show in marker infowindow Toggle=========================
|
161 |
jQuery('#wpgmap_show_infowindow').click('change', function (element) {
|
162 |
openInfoWindow();
|
@@ -186,4 +212,32 @@ jQuery(document.body).find('#wpgmap_title').on('keyup', function (element) {
|
|
186 |
jQuery(document.body).find('#wpgmap_map_type').on('change', function (element) {
|
187 |
var map_type = jQuery(this).val();
|
188 |
initWpGmap(marker1.position.lat(), marker1.position.lng(), map_type);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
});
|
1 |
+
var map, marker1, infowindow, icon = 'https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi2.png';
|
2 |
+
|
3 |
+
function _e(id) {
|
4 |
+
return document.getElementById(id);
|
5 |
+
}
|
6 |
|
7 |
// Getting detailed address by lat,lng
|
8 |
function wpgmapSetAddressByLatLng(lat, lng, id) {
|
9 |
jQuery.getJSON('https://maps.googleapis.com/maps/api/geocode/json?key=' + wp_gmap_api_key + '&latlng=' + lat + ',' + lng + '&sensor=true')
|
10 |
.done(function (location) {
|
11 |
+
_e('wpgmap_map_address').value = location.results[0].formatted_address;
|
12 |
+
})
|
13 |
+
.fail(function (d) {
|
14 |
+
console.log(d);
|
15 |
+
})
|
16 |
+
.always(function (d) {
|
17 |
+
console.log(d);
|
18 |
});
|
19 |
|
20 |
}
|
21 |
|
22 |
+
// Generating already initialized map
|
23 |
+
function generateAlreadyInitiztedMap(map_type, center_lat, center_lng) {
|
24 |
+
if (map_type === 'ROADMAP') {
|
25 |
+
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
|
26 |
+
}
|
27 |
+
else if (map_type === 'SATELLITE') {
|
28 |
+
map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
|
29 |
+
}
|
30 |
+
else if (map_type === 'HYBRID') {
|
31 |
+
map.setMapTypeId(google.maps.MapTypeId.HYBRID);
|
32 |
+
}
|
33 |
+
else if (map_type === 'TERRAIN') {
|
34 |
+
map.setMapTypeId(google.maps.MapTypeId.TERRAIN);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
+
map.setCenter({lat: center_lat, lng: center_lng});
|
38 |
+
marker1 = new google.maps.Marker({
|
39 |
+
position: new google.maps.LatLng(center_lat, center_lng),
|
40 |
+
title: "",
|
41 |
+
draggable: true,
|
42 |
+
animation: google.maps.Animation.DROP
|
43 |
+
});
|
44 |
+
marker1.setMap(map);
|
45 |
+
// Adding dragend Event Listener
|
46 |
+
addMarkerDragendListener(marker1);
|
47 |
+
}
|
48 |
+
|
49 |
+
// Set map settings for by map Type
|
50 |
+
function setMapSettingsByMapType(map_type, center_lat, center_lng, zoom) {
|
51 |
var gmap_settings = {
|
52 |
center: {lat: center_lat, lng: center_lng},
|
53 |
zoom: zoom,
|
65 |
else if (map_type === 'TERRAIN') {
|
66 |
gmap_settings.mapTypeId = google.maps.MapTypeId.TERRAIN;
|
67 |
}
|
68 |
+
return gmap_settings;
|
69 |
+
}
|
70 |
+
|
71 |
+
function addMarkerDragendListener(marker) {
|
72 |
+
marker.addListener('dragend', function (markerLocation) {
|
73 |
+
document.getElementById("wpgmap_latlng").value = markerLocation.latLng.lat() + "," + markerLocation.latLng.lng();
|
74 |
+
wpgmapSetAddressByLatLng(markerLocation.latLng.lat(), markerLocation.latLng.lng());
|
75 |
+
});
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
// to render Google Map
|
80 |
+
function initAutocomplete(id, input, center_lat, center_lng, map_type, zoom) {
|
81 |
+
wpgmapSetAddressByLatLng(center_lat, center_lng);
|
82 |
+
document.getElementById("wpgmap_latlng").value = center_lat + "," + center_lng;
|
83 |
+
// In acse of already initiated
|
84 |
+
if (typeof map === 'object') {
|
85 |
+
generateAlreadyInitiztedMap(map_type, center_lat, center_lng);
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
|
89 |
+
// Set Map Settings by Map Type
|
90 |
+
var gmap_settings = setMapSettingsByMapType(map_type, center_lat, center_lng, zoom);
|
91 |
|
92 |
+
map = new google.maps.Map(_e(id), gmap_settings);
|
93 |
marker1 = new google.maps.Marker({
|
94 |
position: new google.maps.LatLng(center_lat, center_lng),
|
95 |
title: "",
|
96 |
draggable: true,
|
97 |
+
animation: google.maps.Animation.DROP,
|
98 |
+
icon: icon
|
99 |
});
|
100 |
+
// Add dragend event listener
|
101 |
+
addMarkerDragendListener(marker1);
|
102 |
marker1.setMap(map);
|
103 |
|
104 |
// // Create the search box and link it to the UI element.
|
105 |
+
input = document.getElementById(input);
|
106 |
var searchBox = new google.maps.places.SearchBox(input);
|
107 |
google.maps.event.addDomListener(window, "load", function () {
|
108 |
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
|
138 |
return;
|
139 |
}
|
140 |
// Create a marker for each place.
|
141 |
+
marker1 = new google.maps.Marker({
|
142 |
map: map,
|
143 |
title: place.name,
|
144 |
draggable: true,
|
145 |
+
position: place.geometry.location,
|
146 |
+
icon: icon
|
147 |
+
});
|
148 |
+
markers.push(marker1);
|
149 |
marker1.position = place.geometry.location;
|
150 |
|
151 |
+
_e('wpgmap_map_address').value = place.formatted_address;
|
152 |
+
_e("wpgmap_latlng").value = place.geometry.location.lat() + "," + place.geometry.location.lng();
|
153 |
|
154 |
if (place.geometry.viewport) {
|
155 |
// Only geocodes have viewport.
|
159 |
}
|
160 |
});
|
161 |
map.fitBounds(bounds);
|
162 |
+
// Add Marker event listener
|
163 |
+
addMarkerDragendListener(markers[0]);
|
|
|
|
|
164 |
});
|
165 |
|
166 |
}
|
167 |
|
168 |
+
function initWpGmap(lat, lng, map_type) {
|
169 |
+
initAutocomplete('map', 'pac-input', lat, lng, map_type, parseInt(document.getElementById('wpgmap_map_zoom').value));
|
170 |
+
}
|
171 |
+
|
172 |
function openInfoWindow() {
|
173 |
if (jQuery('#wpgmap_show_infowindow').is(':checked')) {
|
174 |
// initWpGmap(marker1.position.lat(), marker1.position.lng(), 'roadmap');
|
183 |
}
|
184 |
|
185 |
|
|
|
186 |
// ========================Show in marker infowindow Toggle=========================
|
187 |
jQuery('#wpgmap_show_infowindow').click('change', function (element) {
|
188 |
openInfoWindow();
|
212 |
jQuery(document.body).find('#wpgmap_map_type').on('change', function (element) {
|
213 |
var map_type = jQuery(this).val();
|
214 |
initWpGmap(marker1.position.lat(), marker1.position.lng(), map_type);
|
215 |
+
});
|
216 |
+
|
217 |
+
jQuery(document.body).find('.wpgmap_tab li').on('click', function (e) {
|
218 |
+
e.preventDefault();
|
219 |
+
jQuery('.wpgmap_tab li').removeClass('active');
|
220 |
+
jQuery(this).addClass('active');
|
221 |
+
|
222 |
+
jQuery('.wp-gmap-tab-contents').addClass('hidden');
|
223 |
+
var wpgmap_id = jQuery(this).attr('id');
|
224 |
+
jQuery('.' + wpgmap_id).removeClass('hidden');
|
225 |
+
});
|
226 |
+
|
227 |
+
// For Media Upload
|
228 |
+
jQuery(document).ready(function ($) {
|
229 |
+
|
230 |
+
$('#upload_image_button').click(function () {
|
231 |
+
|
232 |
+
formfield = $('#upload_image').attr('name');
|
233 |
+
tb_show('Upload your marker image', 'media-upload.php?type=image&TB_iframe=true');
|
234 |
+
window.send_to_editor = function (html) {
|
235 |
+
icon = $(html).attr('src');
|
236 |
+
$('#wpgmap_upload_hidden').val(icon);
|
237 |
+
tb_remove();
|
238 |
+
marker1.setIcon(icon);
|
239 |
+
jQuery("#wpgmap_icon_img").attr('src', icon);
|
240 |
+
};
|
241 |
+
return false;
|
242 |
+
});
|
243 |
});
|
includes/gmap.php
CHANGED
@@ -98,10 +98,10 @@ if ( isset( $_GET['page'] ) ) {
|
|
98 |
$message_status = $_GET['message'];
|
99 |
switch ( $message_status ) {
|
100 |
case 1:
|
101 |
-
echo __( 'Map has been created Successfully. <a href="https://youtu.be/
|
102 |
break;
|
103 |
case 2:
|
104 |
-
echo __( 'Map Updated Successfully. <a href="https://youtu.be/
|
105 |
break;
|
106 |
case 3:
|
107 |
echo __( 'Settings updated Successfully.', 'gmap-embed' );
|
98 |
$message_status = $_GET['message'];
|
99 |
switch ( $message_status ) {
|
100 |
case 1:
|
101 |
+
echo __( 'Map has been created Successfully. <a href="https://youtu.be/FRBqfx_lB-Y?t=181" target="_blank"> See How to use >></a>', 'gmap-embed' );
|
102 |
break;
|
103 |
case 2:
|
104 |
+
echo __( 'Map Updated Successfully. <a href="https://youtu.be/FRBqfx_lB-Y?t=181" target="_blank"> See How to use >></a>', 'gmap-embed' );
|
105 |
break;
|
106 |
case 3:
|
107 |
echo __( 'Settings updated Successfully.', 'gmap-embed' );
|
includes/shortcodes.php
CHANGED
@@ -1,35 +1,37 @@
|
|
1 |
<?php
|
2 |
-
if (!defined('ABSPATH'))
|
|
|
|
|
3 |
// ************* Google Map SRM Shortcode***************
|
4 |
-
if (!function_exists('srm_gmap_embed_shortcode')) {
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
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; ?>"), {
|
@@ -40,7 +42,7 @@ if (!function_exists('srm_gmap_embed_shortcode')) {
|
|
40 |
});
|
41 |
|
42 |
// To view directions form and data
|
43 |
-
|
44 |
var directionsDisplay = new google.maps.DirectionsRenderer();
|
45 |
|
46 |
directionsDisplay.setMap(map);
|
@@ -80,18 +82,19 @@ if (!function_exists('srm_gmap_embed_shortcode')) {
|
|
80 |
|
81 |
}
|
82 |
});
|
83 |
-
|
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 |
-
|
93 |
-
|
94 |
-
|
95 |
var infowindow = new google.maps.InfoWindow({
|
96 |
content: "<?php echo $wpgmap_map_address;?>"
|
97 |
});
|
@@ -99,9 +102,9 @@ if (!function_exists('srm_gmap_embed_shortcode')) {
|
|
99 |
google.maps.event.addListener(marker, 'click', function () {
|
100 |
infowindow.open(map, marker);
|
101 |
});
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
});
|
107 |
|
@@ -113,8 +116,8 @@ if (!function_exists('srm_gmap_embed_shortcode')) {
|
|
113 |
style="width:<?php echo $wpgmap_map_width . ' !important'; ?>;height:<?php echo $wpgmap_map_height; ?> !important;margin:5px 0; ">
|
114 |
|
115 |
</div>
|
116 |
-
|
117 |
-
|
118 |
<style type="text/css">
|
119 |
.wp_gmap_direction_box {
|
120 |
width: 100%;
|
@@ -145,25 +148,26 @@ if (!function_exists('srm_gmap_embed_shortcode')) {
|
|
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; ?>"
|
|
|
167 |
</div>
|
168 |
|
169 |
<!-- Directions will be listed here-->
|
@@ -173,12 +177,12 @@ if (!function_exists('srm_gmap_embed_shortcode')) {
|
|
173 |
</div>
|
174 |
|
175 |
</div>
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
|
181 |
}
|
182 |
|
183 |
//******* Defining Shortcode for Google Map SRM
|
184 |
-
add_shortcode('gmap-embed', 'srm_gmap_embed_shortcode');
|
1 |
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
// ************* Google Map SRM Shortcode***************
|
6 |
+
if ( ! function_exists( 'srm_gmap_embed_shortcode' ) ) {
|
7 |
+
|
8 |
+
function srm_gmap_embed_shortcode( $atts, $content ) {
|
9 |
+
static $count;
|
10 |
+
if ( ! $count ) {
|
11 |
+
$count = 0;
|
12 |
+
}
|
13 |
+
$count ++;
|
14 |
+
|
15 |
+
$wpgmap_title = esc_html( get_post_meta( $atts['id'], 'wpgmap_title', true ) );
|
16 |
+
$wpgmap_show_heading = esc_html( get_post_meta( $atts['id'], 'wpgmap_show_heading', true ) );
|
17 |
+
$wpgmap_heading_class = esc_html( get_post_meta( $atts['id'], 'wpgmap_heading_class', true ) );
|
18 |
+
$wpgmap_latlng = esc_html( get_post_meta( $atts['id'], 'wpgmap_latlng', true ) );
|
19 |
+
$wpgmap_disable_zoom_scroll = esc_html( get_post_meta( $atts['id'], 'wpgmap_disable_zoom_scroll', true ) );
|
20 |
+
$wpgmap_map_zoom = esc_html( get_post_meta( $atts['id'], 'wpgmap_map_zoom', true ) );
|
21 |
+
$wpgmap_map_width = esc_html( get_post_meta( $atts['id'], 'wpgmap_map_width', true ) );
|
22 |
+
$wpgmap_map_height = esc_html( get_post_meta( $atts['id'], 'wpgmap_map_height', true ) );
|
23 |
+
$wpgmap_map_type = esc_html( get_post_meta( $atts['id'], 'wpgmap_map_type', true ) );
|
24 |
+
$wpgmap_map_address = esc_html( get_post_meta( $atts['id'], 'wpgmap_map_address', true ) );
|
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 |
+
|
31 |
+
if ( isset( $wpgmap_show_heading ) && $wpgmap_show_heading == 1 ) {
|
32 |
+
echo "<h1 class='$wpgmap_heading_class'>" . $wpgmap_title . "</h1>";
|
33 |
+
}
|
34 |
+
?>
|
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; ?>"), {
|
42 |
});
|
43 |
|
44 |
// To view directions form and data
|
45 |
+
<?php if($wpgmap_enable_direction and strlen( get_option( 'wpgmapembed_license' ) ) == 32 ){ ?>
|
46 |
var directionsDisplay = new google.maps.DirectionsRenderer();
|
47 |
|
48 |
directionsDisplay.setMap(map);
|
82 |
|
83 |
}
|
84 |
});
|
85 |
+
<?php }?>
|
86 |
//=========Direction view end
|
87 |
|
88 |
var marker = new google.maps.Marker({
|
89 |
position: new google.maps.LatLng(<?php echo $wpgmap_latlng;?>),
|
90 |
map: map,
|
91 |
+
animation: google.maps.Animation.DROP,
|
92 |
+
icon: '<?php echo $wpgmap_marker_icon;?>'
|
93 |
});
|
94 |
marker.setMap(map);
|
95 |
+
<?php
|
96 |
+
if($wpgmap_show_infowindow){
|
97 |
+
?>
|
98 |
var infowindow = new google.maps.InfoWindow({
|
99 |
content: "<?php echo $wpgmap_map_address;?>"
|
100 |
});
|
102 |
google.maps.event.addListener(marker, 'click', function () {
|
103 |
infowindow.open(map, marker);
|
104 |
});
|
105 |
+
<?php
|
106 |
+
}
|
107 |
+
?>
|
108 |
|
109 |
});
|
110 |
|
116 |
style="width:<?php echo $wpgmap_map_width . ' !important'; ?>;height:<?php echo $wpgmap_map_height; ?> !important;margin:5px 0; ">
|
117 |
|
118 |
</div>
|
119 |
+
<?php
|
120 |
+
if ( $wpgmap_enable_direction == 1 and strlen( get_option( 'wpgmapembed_license' ) ) == 32 ) { ?>
|
121 |
<style type="text/css">
|
122 |
.wp_gmap_direction_box {
|
123 |
width: 100%;
|
148 |
<div class="wp_gmap_direction_box">
|
149 |
<div class="ui-bar-c ui-corner-all ui-shadow" style="padding:1em;">
|
150 |
<div data-role="fieldcontain" class="fieldcontain">
|
151 |
+
<label for="from"><?php _e( 'From', 'gmap-embed' ) ?></label>
|
152 |
<input type="text" id="from_<?php echo $count; ?>" value=""/>
|
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>
|
160 |
<select name="select-choice-0" id="mode" style="padding: 5px;">
|
161 |
+
<option value="DRIVING"><?php _e( 'Driving', 'gmap-embed' ) ?></option>
|
162 |
+
<option value="WALKING"><?php _e( 'Walking', 'gmap-embed' ) ?></option>
|
163 |
+
<option value="BICYCLING"><?php _e( 'Bicycling', 'gmap-embed' ) ?></option>
|
164 |
</select>
|
165 |
</div>
|
166 |
<button type="button" data-icon="search" data-role="button" href="#"
|
167 |
+
id="wp_gmap_submit_<?php echo $count; ?>"><?php _e( 'Get Directions', 'gmap-embed' ) ?>
|
168 |
</button>
|
169 |
+
<span id="wp_gmap_loading_<?php echo $count; ?>"
|
170 |
+
style="display: none;"><?php _e( 'Loading', 'gmap-embed' ) ?>...</span>
|
171 |
</div>
|
172 |
|
173 |
<!-- Directions will be listed here-->
|
177 |
</div>
|
178 |
|
179 |
</div>
|
180 |
+
<?php } ?>
|
181 |
+
<?php
|
182 |
+
return ob_get_clean();
|
183 |
+
}
|
184 |
|
185 |
}
|
186 |
|
187 |
//******* Defining Shortcode for Google Map SRM
|
188 |
+
add_shortcode( 'gmap-embed', 'srm_gmap_embed_shortcode' );
|
includes/wpgmap_create.php
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
-
<?php if (!defined('ABSPATH'))
|
|
|
|
|
2 |
<div data-columns="8">
|
3 |
|
4 |
<span class="wpgmap_msg_error" style="width:80%;">
|
@@ -6,115 +8,143 @@
|
|
6 |
</span>
|
7 |
|
8 |
<!-- google map properties -->
|
9 |
-
<div class="wp-gmap-properties">
|
10 |
-
<
|
11 |
-
<
|
12 |
-
<
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
<
|
75 |
-
<
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
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 |
</div>
|
109 |
|
110 |
<div class="wp-gmap-preview">
|
111 |
<h1 id="wpgmap_heading_preview" style="padding: 0px;margin: 0px;"></h1>
|
112 |
-
<input id="pac-input" class="controls" type="text"
|
|
|
113 |
<div id="map" style="height: 415px;"></div>
|
114 |
</div>
|
115 |
|
116 |
<script type="text/javascript"
|
117 |
-
src="<?php echo esc_url(plugins_url("../assets/js/geo_based_map_create.js?v=1.4
|
118 |
</div>
|
119 |
|
120 |
<div class="media-frame-toolbar">
|
@@ -122,7 +152,8 @@
|
|
122 |
<div class="media-toolbar-secondary"
|
123 |
style="text-align: right;float: right;margin-top:10px;margin-right:10px;">
|
124 |
<span class="spinner" style="margin: 0px !important;float:left;"></span>
|
125 |
-
<button class=" button button-primary button-large"
|
|
|
126 |
</div>
|
127 |
</div>
|
128 |
</div>
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
+
exit;
|
3 |
+
} ?>
|
4 |
<div data-columns="8">
|
5 |
|
6 |
<span class="wpgmap_msg_error" style="width:80%;">
|
8 |
</span>
|
9 |
|
10 |
<!-- google map properties -->
|
11 |
+
<div class="wp-gmap-properties-outer">
|
12 |
+
<div class="wpgmap_tab_menu">
|
13 |
+
<ul class="wpgmap_tab">
|
14 |
+
<li class="active" id="wp-gmap-properties">General</li>
|
15 |
+
<li id="wp-gmap-other-properties">Other Settings</li>
|
16 |
+
</ul>
|
17 |
+
</div>
|
18 |
+
<div class="wp-gmap-tab-contents wp-gmap-properties">
|
19 |
+
<table class="gmap_properties">
|
20 |
+
<tr>
|
21 |
+
<td>
|
22 |
+
<label for="wpgmap_title"><b><?php _e( 'Map Title', 'gmap-embed' ); ?></b></label><br/>
|
23 |
+
<input id="wpgmap_title" name="wpgmap_title" value="" type="text"
|
24 |
+
class="regular-text">
|
25 |
+
<br/>
|
26 |
+
|
27 |
+
<input type="checkbox" value="1" name="wpgmap_show_heading"
|
28 |
+
id="wpgmap_show_heading">
|
29 |
+
<label for="wpgmap_show_heading"><?php _e( 'Show as map title', 'gmap-embed' ); ?></label>
|
30 |
+
</td>
|
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>
|
40 |
+
<td>
|
41 |
+
<input id="wpgmap_upload_hidden" type="hidden" size="36" name="upload_image"
|
42 |
+
value="https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi2.png"/>
|
43 |
+
<img src="https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi2.png"
|
44 |
+
id="wpgmap_icon_img" width="32" style="float: left;">
|
45 |
+
<input id="upload_image_button" type="button" value="Change Marker Icon"
|
46 |
+
style="float: left;margin-left: 14px;margin-top: 12px;"/>
|
47 |
+
</td>
|
48 |
+
</tr>
|
49 |
+
|
50 |
+
<tr>
|
51 |
+
<td>
|
52 |
+
<label for="wpgmap_map_zoom"><b><?php _e( 'Zoom', 'gmap-embed' ); ?></b></label><br/>
|
53 |
+
<input id="wpgmap_map_zoom" name="wpgmap_map_zoom" value="13" type="text"
|
54 |
+
class="regular-text">
|
55 |
+
</td>
|
56 |
+
</tr>
|
57 |
+
|
58 |
+
<tr>
|
59 |
+
<td>
|
60 |
+
<label for="wpgmap_map_width"><b><?php _e( 'Width (%)', 'gmap-embed' ); ?></b></label><br/>
|
61 |
+
<input id="wpgmap_map_width" name="wpgmap_map_width" value="100%"
|
62 |
+
type="text" class="regular-text">
|
63 |
+
</td>
|
64 |
+
</tr>
|
65 |
+
|
66 |
+
<tr>
|
67 |
+
<td>
|
68 |
+
<label for="wpgmap_map_height"><b><?php _e( 'Height (px)', 'gmap-embed' ); ?></b></label><br/>
|
69 |
+
<input id="wpgmap_map_height" name="wpgmap_map_height" value="300px"
|
70 |
+
type="text" class="regular-text">
|
71 |
+
</td>
|
72 |
+
</tr>
|
73 |
+
|
74 |
+
<tr>
|
75 |
+
<td>
|
76 |
+
<label for="wpgmap_map_type"><b><?php _e( 'Map Type', 'gmap-embed' ); ?></b></label><br/>
|
77 |
+
<select id="wpgmap_map_type" class="regular-text" style="width:25em;">
|
78 |
+
<option>ROADMAP</option>
|
79 |
+
<option>SATELLITE</option>
|
80 |
+
<option>HYBRID</option>
|
81 |
+
<option>TERRAIN</option>
|
82 |
+
</select>
|
83 |
+
</td>
|
84 |
+
</tr>
|
85 |
+
|
86 |
+
<tr>
|
87 |
+
<td>
|
88 |
+
<label for="wpgmap_map_address"><b><?php _e( 'Location Address', 'gmap-embed' ); ?></b></label><br/>
|
89 |
+
<input type="text" id="wpgmap_map_address" style="width:25em;"
|
90 |
+
name="wpgmap_map_address" class="regular-text">
|
91 |
+
|
92 |
+
<br/>
|
93 |
+
|
94 |
+
<label for="wpgmap_show_infowindow"><input type="checkbox" value="1"
|
95 |
+
name="wpgmap_show_infowindow"
|
96 |
+
id="wpgmap_show_infowindow">
|
97 |
+
<?php _e( 'Show location address in marker infowindow', 'gmap-embed' ); ?>
|
98 |
+
</label>
|
99 |
+
|
100 |
+
</td>
|
101 |
+
</tr>
|
102 |
+
|
103 |
+
</table>
|
104 |
+
</div>
|
105 |
+
<div class="wp-gmap-tab-contents wp-gmap-other-properties hidden">
|
106 |
+
<table class="gmap_properties">
|
107 |
+
<tr>
|
108 |
+
<td>
|
109 |
+
<label for="wpgmap_heading_class"><b><?php _e( 'Heading Custom Class', 'gmap-embed' ); ?> <span
|
110 |
+
style="color:gray;">(if any)</span></b></label><br/>
|
111 |
+
<input id="wpgmap_heading_class" name="wpgmap_heading_class" value="" type="text"
|
112 |
+
class="regular-text">
|
113 |
+
</td>
|
114 |
+
</tr>
|
115 |
+
<tr>
|
116 |
+
<td>
|
117 |
+
<label for="wpgmap_enable_direction"><input type="checkbox" value="1"
|
118 |
+
name="wpgmap_enable_direction"
|
119 |
+
id="wpgmap_enable_direction">
|
120 |
+
<?php _e( 'Enable Direction in Map', 'gmap-embed' ); ?>
|
121 |
+
</label>
|
122 |
+
|
123 |
+
|
124 |
+
</td>
|
125 |
+
</tr>
|
126 |
+
<tr>
|
127 |
+
<td>
|
128 |
+
<label for="wpgmap_disable_zoom_scroll"><input type="checkbox" value="1"
|
129 |
+
name="wpgmap_disable_zoom_scroll"
|
130 |
+
id="wpgmap_disable_zoom_scroll">
|
131 |
+
<?php _e( 'Disable zoom on mouse scroll', 'gmap-embed' ); ?>
|
132 |
+
</label>
|
133 |
+
</td>
|
134 |
+
</tr>
|
135 |
+
</table>
|
136 |
+
</div>
|
137 |
</div>
|
138 |
|
139 |
<div class="wp-gmap-preview">
|
140 |
<h1 id="wpgmap_heading_preview" style="padding: 0px;margin: 0px;"></h1>
|
141 |
+
<input id="pac-input" class="controls" type="text"
|
142 |
+
placeholder="<?php _e( 'Search by Address, Zip Code', 'gmap-embed' ); ?>"/>
|
143 |
<div id="map" style="height: 415px;"></div>
|
144 |
</div>
|
145 |
|
146 |
<script type="text/javascript"
|
147 |
+
src="<?php echo esc_url( plugins_url( "../assets/js/geo_based_map_create.js?v=1.5.4", __FILE__ ) ); ?>"></script>
|
148 |
</div>
|
149 |
|
150 |
<div class="media-frame-toolbar">
|
152 |
<div class="media-toolbar-secondary"
|
153 |
style="text-align: right;float: right;margin-top:10px;margin-right:10px;">
|
154 |
<span class="spinner" style="margin: 0px !important;float:left;"></span>
|
155 |
+
<button class=" button button-primary button-large"
|
156 |
+
id="wp-gmap-embed-save"><?php _e( 'Save', 'gmap-embed' ); ?></button>
|
157 |
</div>
|
158 |
</div>
|
159 |
</div>
|
includes/wpgmap_edit.php
CHANGED
@@ -1,138 +1,185 @@
|
|
1 |
<?php
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
6 |
?>
|
7 |
<div data-columns="8">
|
8 |
<!-- getting hidden id-->
|
9 |
-
<input id="wpgmap_map_id" name="wpgmap_map_id" value="<?php echo intval($_GET['id']); ?>" type="hidden"/>
|
10 |
|
11 |
<span class="wpgmap_msg_error" style="width:80%;">
|
12 |
<!-- error will goes here-->
|
13 |
</span>
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
<
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
<
|
39 |
-
<
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
<
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
</
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
</
|
78 |
-
|
79 |
-
|
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 |
</div>
|
123 |
|
124 |
<div class="wp-gmap-preview">
|
125 |
-
<h1 id="wpgmap_heading_preview"
|
126 |
-
|
|
|
|
|
127 |
<div id="map" style="height: 415px;"></div>
|
128 |
</div>
|
129 |
<script type="text/javascript"
|
130 |
-
src="<?php echo esc_url(plugins_url("../assets/js/geo_based_map_edit.js?v=1.4
|
131 |
<script>
|
132 |
(function ($) {
|
133 |
$(function () {
|
|
|
|
|
134 |
google.maps.event.addDomListener(window, 'load',
|
135 |
-
initAutocomplete('map', 'pac-input',<?php echo $wpgmap_lat;?>,<?php echo $wpgmap_lng;?>, '<?php echo $wpgmap_single->wpgmap_map_type; ?>',<?php echo $wpgmap_single->wpgmap_map_zoom;?>,'edit')
|
136 |
);
|
137 |
if (jQuery('#wpgmap_show_infowindow').is(':checked') === true) {
|
138 |
openInfoWindow();
|
@@ -147,7 +194,8 @@ list($wpgmap_lat, $wpgmap_lng) = explode(',', esc_html($wpgmap_single->wpgmap_la
|
|
147 |
<div class="media-toolbar-secondary"
|
148 |
style="text-align: right;float: right;margin-top:10px;">
|
149 |
<span class="spinner" style="margin: 0px !important;float:left;"></span>
|
150 |
-
<button class="button button-primary" style="margin-right:10px;"
|
|
|
151 |
</div>
|
152 |
</div>
|
153 |
</div>
|
1 |
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
$gmap_data = $this->get_wpgmapembed_data( intval( $_GET['id'] ) );
|
6 |
+
$wpgmap_single = json_decode( $gmap_data );
|
7 |
+
list( $wpgmap_lat, $wpgmap_lng ) = explode( ',', esc_html( $wpgmap_single->wpgmap_latlng ) );
|
8 |
?>
|
9 |
<div data-columns="8">
|
10 |
<!-- getting hidden id-->
|
11 |
+
<input id="wpgmap_map_id" name="wpgmap_map_id" value="<?php echo intval( $_GET['id'] ); ?>" type="hidden"/>
|
12 |
|
13 |
<span class="wpgmap_msg_error" style="width:80%;">
|
14 |
<!-- error will goes here-->
|
15 |
</span>
|
16 |
+
<div class="wp-gmap-properties-outer">
|
17 |
+
<div class="wpgmap_tab_menu">
|
18 |
+
<ul class="wpgmap_tab">
|
19 |
+
<li class="active" id="wp-gmap-properties">General</li>
|
20 |
+
<li id="wp-gmap-other-properties">Other Settings</li>
|
21 |
+
</ul>
|
22 |
+
</div>
|
23 |
+
<div class="wp-gmap-tab-contents wp-gmap-properties">
|
24 |
+
<table style="width: 100% !important;" class="gmap_properties">
|
25 |
+
<tr>
|
26 |
+
<td>
|
27 |
+
<label for="wpgmap_title"><b><?php _e( 'Map Title', 'gmap-embed' ); ?></b></label><br/>
|
28 |
+
<input id="wpgmap_title" name="wpgmap_title"
|
29 |
+
value="<?php echo esc_attr( $wpgmap_single->wpgmap_title ); ?>"
|
30 |
+
type="text"
|
31 |
+
class="regular-text">
|
32 |
+
<br/>
|
33 |
+
|
34 |
+
<input type="checkbox" value="1" name="wpgmap_show_heading"
|
35 |
+
id="wpgmap_show_heading" <?php echo ( $wpgmap_single->wpgmap_show_heading == 1 ) ? 'checked' : ''; ?>>
|
36 |
+
<label for="wpgmap_show_heading"><?php _e( 'Show as map title', 'gmap-embed' ); ?></label>
|
37 |
+
</td>
|
38 |
+
</tr>
|
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 |
+
|
50 |
+
<tr>
|
51 |
+
<td>
|
52 |
+
<input id="wpgmap_upload_hidden" type="hidden" size="36" name="upload_image"
|
53 |
+
value="<?php echo $wpgmap_single->wpgmap_marker_icon; ?>"/>
|
54 |
+
<img src="<?php echo $wpgmap_single->wpgmap_marker_icon; ?>"
|
55 |
+
id="wpgmap_icon_img" width="32" style="float: left;">
|
56 |
+
<input id="upload_image_button" type="button" value="Change Marker Icon"
|
57 |
+
style="float: left;margin-left: 14px;margin-top: 12px;"/>
|
58 |
+
</td>
|
59 |
+
</tr>
|
60 |
+
|
61 |
+
<tr>
|
62 |
+
<td>
|
63 |
+
<label for="wpgmap_map_zoom"><b><?php _e( 'Zoom', 'gmap-embed' ); ?></b></label><br/>
|
64 |
+
<input id="wpgmap_map_zoom" name="wpgmap_map_zoom"
|
65 |
+
value="<?php echo esc_attr( $wpgmap_single->wpgmap_map_zoom ); ?>" type="text"
|
66 |
+
class="regular-text">
|
67 |
+
|
68 |
+
|
69 |
+
</td>
|
70 |
+
</tr>
|
71 |
+
|
72 |
+
<tr>
|
73 |
+
<td>
|
74 |
+
<label for="wpgmap_map_width"><b><?php _e( 'Width (%)', 'gmap-embed' ); ?></b></label><br/>
|
75 |
+
<input id="wpgmap_map_width" name="wpgmap_map_width"
|
76 |
+
value="<?php echo esc_attr( $wpgmap_single->wpgmap_map_width ); ?>"
|
77 |
+
type="text" class="regular-text">
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
+
|
81 |
+
<tr>
|
82 |
+
<td>
|
83 |
+
<label for="wpgmap_map_height"><b><?php _e( 'Height (px)', 'gmap-embed' ); ?></b></label><br/>
|
84 |
+
<input id="wpgmap_map_height" name="wpgmap_map_height"
|
85 |
+
value="<?php echo esc_attr( $wpgmap_single->wpgmap_map_height ); ?>"
|
86 |
+
type="text" class="regular-text">
|
87 |
+
</td>
|
88 |
+
</tr>
|
89 |
+
|
90 |
+
<tr>
|
91 |
+
<td>
|
92 |
+
<label><b><?php _e( 'Map Type', 'gmap-embed' ); ?></b></label><br/>
|
93 |
+
<select id="wpgmap_map_type" class="regular-text" style="width:25em;">
|
94 |
+
<option <?php echo $wpgmap_single->wpgmap_map_type == 'ROADMAP' ? 'selected' : ''; ?>>
|
95 |
+
ROADMAP
|
96 |
+
</option>
|
97 |
+
<option <?php echo $wpgmap_single->wpgmap_map_type == 'SATELLITE' ? 'selected' : ''; ?>>
|
98 |
+
SATELLITE
|
99 |
+
</option>
|
100 |
+
<option <?php echo $wpgmap_single->wpgmap_map_type == 'HYBRID' ? 'selected' : ''; ?>>HYBRID
|
101 |
+
</option>
|
102 |
+
<option <?php echo $wpgmap_single->wpgmap_map_type == 'TERRAIN' ? 'selected' : ''; ?>>
|
103 |
+
TERRAIN
|
104 |
+
</option>
|
105 |
+
</select>
|
106 |
+
</td>
|
107 |
+
</tr>
|
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>
|
115 |
+
|
116 |
+
<br/>
|
117 |
+
|
118 |
+
<label for="wpgmap_show_infowindow"><input type="checkbox" value="1"
|
119 |
+
name="wpgmap_show_infowindow"
|
120 |
+
id="wpgmap_show_infowindow" <?php echo ( $wpgmap_single->wpgmap_show_infowindow == 1 ) ? 'checked' : ''; ?>>
|
121 |
+
<?php _e( 'Show in marker infowindow', 'gmap-embed' ); ?>
|
122 |
+
</label>
|
123 |
+
|
124 |
+
<br/>
|
125 |
+
|
126 |
+
|
127 |
+
</td>
|
128 |
+
</tr>
|
129 |
+
|
130 |
+
</table>
|
131 |
+
</div>
|
132 |
+
<div class="wp-gmap-tab-contents wp-gmap-other-properties hidden">
|
133 |
+
<table class="gmap_properties">
|
134 |
+
<tr>
|
135 |
+
<td>
|
136 |
+
<label for="wpgmap_heading_class"><b><?php _e( 'Heading Custom Class', 'gmap-embed' ); ?></b></label><br/>
|
137 |
+
<input id="wpgmap_heading_class" name="wpgmap_heading_class"
|
138 |
+
value="<?php echo $wpgmap_single->wpgmap_heading_class; ?>" type="text"
|
139 |
+
class="regular-text">
|
140 |
+
</td>
|
141 |
+
</tr>
|
142 |
+
<tr>
|
143 |
+
<td>
|
144 |
+
<label for="wpgmap_enable_direction"><input type="checkbox" value="1"
|
145 |
+
name="wpgmap_enable_direction"
|
146 |
+
id="wpgmap_enable_direction" <?php echo ( $wpgmap_single->wpgmap_enable_direction == 1 ) ? 'checked' : ''; ?>>
|
147 |
+
<?php _e( 'Enable Direction in Map', 'gmap-embed' ); ?>
|
148 |
+
</label>
|
149 |
+
|
150 |
+
|
151 |
+
</td>
|
152 |
+
</tr>
|
153 |
+
|
154 |
+
<tr>
|
155 |
+
<td>
|
156 |
+
<label for="wpgmap_disable_zoom_scroll"><input type="checkbox" value="1"
|
157 |
+
name="wpgmap_disable_zoom_scroll"
|
158 |
+
id="wpgmap_disable_zoom_scroll" <?php echo ( $wpgmap_single->wpgmap_disable_zoom_scroll == 1 ) ? 'checked' : ''; ?>>
|
159 |
+
<?php _e( 'Disable zoom on mouse scroll', 'gmap-embed' ); ?>
|
160 |
+
</label>
|
161 |
+
</td>
|
162 |
+
</tr>
|
163 |
+
</table>
|
164 |
+
</div>
|
165 |
</div>
|
166 |
|
167 |
<div class="wp-gmap-preview">
|
168 |
+
<h1 id="wpgmap_heading_preview"
|
169 |
+
style="padding: 0px;margin: 0px;"><?php echo $wpgmap_single->wpgmap_title; ?></h1>
|
170 |
+
<input id="pac-input" class="controls" type="text"
|
171 |
+
placeholder="<?php _e( 'Search by Address, Zip Code', 'gmap-embed' ); ?>"/>
|
172 |
<div id="map" style="height: 415px;"></div>
|
173 |
</div>
|
174 |
<script type="text/javascript"
|
175 |
+
src="<?php echo esc_url( plugins_url( "../assets/js/geo_based_map_edit.js?v=1.5.4", __FILE__ ) ); ?>"></script>
|
176 |
<script>
|
177 |
(function ($) {
|
178 |
$(function () {
|
179 |
+
icon = '<?php echo $wpgmap_single->wpgmap_marker_icon;?>';
|
180 |
+
console.log(icon);
|
181 |
google.maps.event.addDomListener(window, 'load',
|
182 |
+
initAutocomplete('map', 'pac-input',<?php echo $wpgmap_lat;?>,<?php echo $wpgmap_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();
|
194 |
<div class="media-toolbar-secondary"
|
195 |
style="text-align: right;float: right;margin-top:10px;">
|
196 |
<span class="spinner" style="margin: 0px !important;float:left;"></span>
|
197 |
+
<button class="button button-primary" style="margin-right:10px;"
|
198 |
+
id="wp-gmap-embed-update"><?php _e( 'Update', 'gmap-embed' ); ?></button>
|
199 |
</div>
|
200 |
</div>
|
201 |
</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.3
|
7 |
-
Version: 1.5.
|
8 |
Requires PHP: 5.3
|
9 |
Text Domain: gmap-embed
|
10 |
License: GPLv2 or later
|
@@ -304,4 +304,7 @@ New version released with helpful resources and insitilization of street view.
|
|
304 |
New version released with bug fixing
|
305 |
|
306 |
= 1.5.3 =
|
307 |
-
New version released with payment option updated.
|
|
|
|
|
|
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.3
|
7 |
+
Version: 1.5.4
|
8 |
Requires PHP: 5.3
|
9 |
Text Domain: gmap-embed
|
10 |
License: GPLv2 or later
|
304 |
New version released with bug fixing
|
305 |
|
306 |
= 1.5.3 =
|
307 |
+
New version released with payment option updated.
|
308 |
+
|
309 |
+
= 1.5.4 =
|
310 |
+
Dynamic/Customized Marker icon option added, Code related optimization added.
|
srm_gmap_embed.php
CHANGED
@@ -7,200 +7,205 @@
|
|
7 |
Text Domain: gmap-embed
|
8 |
Domain Path: /languages
|
9 |
Author URI: http://www.srmilon.info
|
10 |
-
Version: 1.5.
|
11 |
*/
|
12 |
|
13 |
-
if (!defined('ABSPATH'))
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
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 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
192 |
<div class="wp-gmap-single-left">
|
193 |
<div class="wp-gmap-single-title">
|
194 |
' . $title . '
|
195 |
</div>
|
196 |
<div class="wp-gmap-single-shortcode">
|
197 |
-
<input class="wpgmap-shortcode regular-text" type="text" value="' . esc_attr('[gmap-embed id="' . get_the_ID() . '"]') . '"
|
198 |
onclick="this.select()"/>
|
199 |
</div>
|
200 |
</div>
|
201 |
<div class="wp-gmap-single-action">
|
202 |
<a href="?page=wpgmapembed&tag=edit&id=' . get_the_ID() . '" class="button media-button button-primary button-large wpgmap-edit" data-id="' . get_the_ID() . '">
|
203 |
-
' . __('Change', 'gmap-embed') . '
|
204 |
</a>
|
205 |
<button type="button"
|
206 |
class="button media-button button-danger button-large wpgmap-insert-delete" data-id="' . get_the_ID() . '" style="background-color: red;color: white;opacity:0.7;">
|
@@ -208,12 +213,12 @@ if (!class_exists('srm_gmap_embed_main')) {
|
|
208 |
</button>
|
209 |
</div>
|
210 |
</div>';
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
data-id="wp-gmap-new" class="media-menu-item">' . __("Create New Map", "gmap-embed") . '</a>';
|
216 |
-
|
217 |
<h3>Frequently asked questions</h3>
|
218 |
<ul>
|
219 |
<li>
|
@@ -246,25 +251,24 @@ if (!class_exists('srm_gmap_embed_main')) {
|
|
246 |
</li>
|
247 |
</ul>
|
248 |
</div>';
|
249 |
-
|
250 |
|
251 |
-
|
252 |
|
253 |
|
254 |
-
|
255 |
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
$mapsList = new WP_Query($args);
|
263 |
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
<div class="wp-gmap-single-left">
|
269 |
<div class="wp-gmap-single-title">
|
270 |
' . $title . '
|
@@ -281,108 +285,108 @@ if (!class_exists('srm_gmap_embed_main')) {
|
|
281 |
</button>
|
282 |
</div>
|
283 |
</div>';
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
}
|
360 |
|
361 |
|
362 |
}
|
363 |
new srm_gmap_embed_main();
|
364 |
// including requird files
|
365 |
-
require_once plugin_dir_path(__FILE__) . '/includes/widget.php';
|
366 |
-
require_once plugin_dir_path(__FILE__) . '/includes/shortcodes.php';
|
367 |
|
368 |
-
if ($pagenow == 'post.php' || $pagenow == 'post-new.php') {
|
369 |
-
|
370 |
}
|
371 |
|
372 |
-
load_plugin_textdomain('gmap-embed', false, dirname(plugin_basename(__FILE__)) . '/languages');
|
373 |
|
374 |
//updated at 07.04.2019 14:20:00
|
375 |
|
376 |
-
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'gmap_srm_settings_link');
|
377 |
function gmap_srm_settings_link( $links ) {
|
378 |
$links[] = '<a href="' .
|
379 |
-
|
380 |
-
|
|
|
381 |
return $links;
|
382 |
}
|
383 |
|
384 |
-
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'gmap_srm_settings_linka');
|
385 |
function gmap_srm_settings_linka( $links ) {
|
386 |
-
$links[] = '<a target="_blank" style="color: #11967A;font-weight:bold;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZBERRKARGNEYA">' . __('Upgrade To Premium') . '</a>';
|
|
|
387 |
return $links;
|
388 |
}
|
7 |
Text Domain: gmap-embed
|
8 |
Domain Path: /languages
|
9 |
Author URI: http://www.srmilon.info
|
10 |
+
Version: 1.5.4
|
11 |
*/
|
12 |
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
+
exit;
|
15 |
+
}
|
16 |
+
load_plugin_textdomain( 'gmap-embed', false, dirname( plugin_basename( __FILE__, '/languages/' ) ) );
|
17 |
+
if ( ! class_exists( 'srm_gmap_embed_main' ) ) {
|
18 |
+
|
19 |
+
class srm_gmap_embed_main {
|
20 |
+
|
21 |
+
private $plugin_name = 'Google Map SRM';
|
22 |
+
public $wpgmap_api_key = 'AIzaSyD79uz_fsapIldhWBl0NqYHHGBWkxlabro';
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* constructor function
|
27 |
+
*/
|
28 |
+
function __construct() {
|
29 |
+
$this->wpgmap_api_key = get_option( 'wpgmap_api_key' );
|
30 |
+
add_action( 'activated_plugin', array( $this, 'wpgmap_do_after_activation' ), 10, 2 );
|
31 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'gmap_enqueue_scripts' ) );
|
32 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_gmap_scripts' ) );
|
33 |
+
add_action( 'admin_menu', array( $this, 'gmap_create_menu' ) );
|
34 |
+
add_action( 'admin_init', array( $this, 'gmap_register_fields' ) );
|
35 |
+
add_action( 'wp_ajax_wpgmapembed_save_map_data', array( $this, 'save_wpgmapembed_data' ) );
|
36 |
+
add_action( 'wp_ajax_wpgmapembed_load_map_data', array( $this, 'load_wpgmapembed_list' ) );
|
37 |
+
add_action( 'wp_ajax_wpgmapembed_popup_load_map_data', array( $this, 'load_popup_wpgmapembed_list' ) );
|
38 |
+
add_action( 'wp_ajax_wpgmapembed_get_wpgmap_data', array( $this, 'get_wpgmapembed_data' ) );
|
39 |
+
add_action( 'wp_ajax_wpgmapembed_remove_wpgmap', array( $this, 'remove_wpgmapembed_data' ) );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* To set options values
|
44 |
+
*/
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* To enqueue scripts for front-end
|
49 |
+
*/
|
50 |
+
public function gmap_enqueue_scripts() {
|
51 |
+
//including map library
|
52 |
+
wp_enqueue_script( 'srm_gmap_api', 'https://maps.googleapis.com/maps/api/js?key=' . $this->wpgmap_api_key . '&libraries=places', array( 'jquery' ) );
|
53 |
+
}
|
54 |
+
|
55 |
+
function enqueue_admin_gmap_scripts() {
|
56 |
+
global $pagenow;
|
57 |
+
if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' || @$_GET['page'] == 'wpgmapembed' ) {
|
58 |
+
wp_enqueue_script( 'wp-gmap-api', 'https://maps.google.com/maps/api/js?key=' . $this->wpgmap_api_key . '&libraries=places', array( 'jquery' ), '20161019', true );
|
59 |
+
wp_enqueue_script( 'wp-gmap-custom-js', plugins_url( 'assets/js/custom.js', __FILE__ ), array( 'wp-gmap-api' ), '20161019', false );
|
60 |
+
wp_enqueue_style( 'wp-gmap-embed-css', plugins_url( 'assets/css/wp-gmap-style.css', __FILE__ ), rand( 999, 9999 ) );
|
61 |
+
|
62 |
+
// For media upload
|
63 |
+
wp_enqueue_script( 'media-upload' );
|
64 |
+
wp_enqueue_script( 'thickbox' );
|
65 |
+
wp_enqueue_script( 'wpgmap-media-upload' );
|
66 |
+
wp_enqueue_style( 'thickbox' );
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
* To create menu in admin panel
|
73 |
+
*/
|
74 |
+
public function gmap_create_menu() {
|
75 |
+
|
76 |
+
//create new top-level menu
|
77 |
+
add_menu_page( $this->plugin_name, $this->plugin_name, 'administrator', 'wpgmapembed', array(
|
78 |
+
$this,
|
79 |
+
'srm_gmap_main'
|
80 |
+
), 'dashicons-location', 11 );
|
81 |
+
|
82 |
+
//to create sub menu
|
83 |
+
add_submenu_page( 'wpgmapembed', __( "Add new Map", "gmap-embed" ), __( "Add New", "gmap-embed" ), 'administrator', 'wpgmapembed&tag=new', array(
|
84 |
+
$this,
|
85 |
+
'srm_gmap_new'
|
86 |
+
), 'dashicons-location' );
|
87 |
+
}
|
88 |
+
|
89 |
+
public function gmap_register_fields() {
|
90 |
+
//register fields
|
91 |
+
register_setting( 'gmap_settings_group', 'gmap_title' );
|
92 |
+
register_setting( 'gmap_settings_group', 'wpgmap_heading_class' );
|
93 |
+
register_setting( 'gmap_settings_group', 'gmap_lat' );
|
94 |
+
register_setting( 'gmap_settings_group', 'gmap_long' );
|
95 |
+
register_setting( 'gmap_settings_group', 'gmap_width' );
|
96 |
+
register_setting( 'gmap_settings_group', 'gmap_height' );
|
97 |
+
register_setting( 'gmap_settings_group', 'gmap_zoom' );
|
98 |
+
register_setting( 'gmap_settings_group', 'gmap_disable_zoom_scroll' );
|
99 |
+
register_setting( 'gmap_settings_group', 'gmap_type' );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Google Map Embed Mail Page
|
104 |
+
*/
|
105 |
+
public function srm_gmap_main() {
|
106 |
+
require plugin_dir_path( __FILE__ ) . '/includes/gmap.php';
|
107 |
+
}
|
108 |
+
|
109 |
+
/*
|
110 |
+
* To update post meta data
|
111 |
+
*/
|
112 |
+
|
113 |
+
public function __update_post_meta( $post_id, $field_name, $value = '' ) {
|
114 |
+
if ( ! get_post_meta( $post_id, $field_name ) ) {
|
115 |
+
add_post_meta( $post_id, $field_name, $value );
|
116 |
+
} else {
|
117 |
+
update_post_meta( $post_id, $field_name, $value );
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* To save New Map Data
|
123 |
+
*/
|
124 |
+
|
125 |
+
public function save_wpgmapembed_data() {
|
126 |
+
$error = '';
|
127 |
+
// Getting ajax fileds value
|
128 |
+
$meta_data = array(
|
129 |
+
'wpgmap_title' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_title'] ) ),
|
130 |
+
'wpgmap_heading_class' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_heading_class'] ) ),
|
131 |
+
'wpgmap_show_heading' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_show_heading'] ) ),
|
132 |
+
'wpgmap_latlng' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_latlng'] ) ),
|
133 |
+
'wpgmap_map_zoom' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_map_zoom'] ) ),
|
134 |
+
'wpgmap_disable_zoom_scroll' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_disable_zoom_scroll'] ) ),
|
135 |
+
'wpgmap_map_width' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_map_width'] ) ),
|
136 |
+
'wpgmap_map_height' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_map_height'] ) ),
|
137 |
+
'wpgmap_map_type' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_map_type'] ) ),
|
138 |
+
'wpgmap_map_address' => sanitize_text_field( esc_html( $_POST['map_data']['wpgmap_map_address'] ) ),
|
139 |
+
'wpgmap_show_infowindow' => sanitize_text_field( $_POST['map_data']['wpgmap_show_infowindow'] ),
|
140 |
+
'wpgmap_enable_direction' => sanitize_text_field( $_POST['map_data']['wpgmap_enable_direction'] ),
|
141 |
+
'wpgmap_marker_icon' => sanitize_text_field( $_POST['map_data']['wpgmap_marker_icon'] )
|
142 |
+
);
|
143 |
+
$action_type = sanitize_text_field( esc_html( $_POST['map_data']['action_type'] ) );
|
144 |
+
if ( $meta_data['wpgmap_latlng'] == '' ) {
|
145 |
+
$error = "Please input Latitude and Longitude";
|
146 |
+
}
|
147 |
+
if ( strlen( $error ) > 0 ) {
|
148 |
+
echo json_encode( array(
|
149 |
+
'responseCode' => 0,
|
150 |
+
'message' => $error
|
151 |
+
) );
|
152 |
+
exit;
|
153 |
+
} else {
|
154 |
+
|
155 |
+
if ( $action_type == 'save' ) {
|
156 |
+
// saving post array
|
157 |
+
$post_array = array(
|
158 |
+
'post_type' => 'wpgmapembed'
|
159 |
+
);
|
160 |
+
$post_id = wp_insert_post( $post_array );
|
161 |
+
|
162 |
+
} elseif ( $action_type == 'update' ) {
|
163 |
+
$post_id = intval( $_POST['map_data']['post_id'] );
|
164 |
+
}
|
165 |
+
|
166 |
+
// Updating post meta
|
167 |
+
foreach ( $meta_data as $key => $value ) {
|
168 |
+
$this->__update_post_meta( $post_id, $key, $value );
|
169 |
+
}
|
170 |
+
$returnArray = array(
|
171 |
+
'responseCode' => 1,
|
172 |
+
'post_id' => $post_id
|
173 |
+
);
|
174 |
+
if ( $action_type == 'save' ) {
|
175 |
+
$returnArray['message'] = 'Created Successfully.';
|
176 |
+
} elseif ( $action_type == 'update' ) {
|
177 |
+
$returnArray['message'] = 'Updated Successfully.';
|
178 |
+
}
|
179 |
+
echo json_encode( $returnArray );
|
180 |
+
exit;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
public function load_wpgmapembed_list() {
|
185 |
+
$content = '';
|
186 |
+
$args = array(
|
187 |
+
'post_type' => 'wpgmapembed',
|
188 |
+
'posts_per_page' => - 1
|
189 |
+
);
|
190 |
+
$mapsList = new WP_Query( $args );
|
191 |
+
|
192 |
+
if ( $mapsList->have_posts() ) {
|
193 |
+
while ( $mapsList->have_posts() ) {
|
194 |
+
$mapsList->the_post();
|
195 |
+
$title = get_post_meta( get_the_ID(), 'wpgmap_title', true );
|
196 |
+
$content .= '<div class="wp-gmap-single">
|
197 |
<div class="wp-gmap-single-left">
|
198 |
<div class="wp-gmap-single-title">
|
199 |
' . $title . '
|
200 |
</div>
|
201 |
<div class="wp-gmap-single-shortcode">
|
202 |
+
<input class="wpgmap-shortcode regular-text" type="text" value="' . esc_attr( '[gmap-embed id="' . get_the_ID() . '"]' ) . '"
|
203 |
onclick="this.select()"/>
|
204 |
</div>
|
205 |
</div>
|
206 |
<div class="wp-gmap-single-action">
|
207 |
<a href="?page=wpgmapembed&tag=edit&id=' . get_the_ID() . '" class="button media-button button-primary button-large wpgmap-edit" data-id="' . get_the_ID() . '">
|
208 |
+
' . __( 'Change', 'gmap-embed' ) . '
|
209 |
</a>
|
210 |
<button type="button"
|
211 |
class="button media-button button-danger button-large wpgmap-insert-delete" data-id="' . get_the_ID() . '" style="background-color: red;color: white;opacity:0.7;">
|
213 |
</button>
|
214 |
</div>
|
215 |
</div>';
|
216 |
+
}
|
217 |
+
} else {
|
218 |
+
$content = __( "You have not created any Map yet. ", "gmap-embed" );
|
219 |
+
$content .= '<a style="padding: 9px;border-radius: 5px;background-color: #0073aa;color: white;text-decoration: none;font-weight: bold;font-size: 11px;" href="' . esc_url( admin_url() ) . 'admin.php?page=wpgmapembed&tag=new"
|
220 |
+
data-id="wp-gmap-new" class="media-menu-item">' . __( "Create New Map", "gmap-embed" ) . '</a>';
|
221 |
+
$content .= '<br/><br/><div class="srm_gmap_instructions">
|
222 |
<h3>Frequently asked questions</h3>
|
223 |
<ul>
|
224 |
<li>
|
251 |
</li>
|
252 |
</ul>
|
253 |
</div>';
|
254 |
+
}
|
255 |
|
256 |
+
echo $content;
|
257 |
|
258 |
|
259 |
+
}
|
260 |
|
261 |
+
public function load_popup_wpgmapembed_list() {
|
262 |
+
$content = '';
|
263 |
+
$args = array(
|
264 |
+
'post_type' => 'wpgmapembed'
|
265 |
+
);
|
266 |
+
$mapsList = new WP_Query( $args );
|
|
|
267 |
|
268 |
+
while ( $mapsList->have_posts() ) {
|
269 |
+
$mapsList->the_post();
|
270 |
+
$title = get_post_meta( get_the_ID(), 'wpgmap_title', true );
|
271 |
+
$content .= '<div class="wp-gmap-single">
|
272 |
<div class="wp-gmap-single-left">
|
273 |
<div class="wp-gmap-single-title">
|
274 |
' . $title . '
|
285 |
</button>
|
286 |
</div>
|
287 |
</div>';
|
288 |
+
}
|
289 |
+
echo $content;
|
290 |
+
exit;
|
291 |
+
|
292 |
+
|
293 |
+
}
|
294 |
+
|
295 |
+
public function get_wpgmapembed_data( $gmap_id = '' ) {
|
296 |
+
if ( $gmap_id == '' ) {
|
297 |
+
$gmap_id = intval( $_POST['wpgmap_id'] );
|
298 |
+
}
|
299 |
+
|
300 |
+
$gmap_data = array(
|
301 |
+
'wpgmap_title' => get_post_meta( $gmap_id, 'wpgmap_title', true ),
|
302 |
+
'wpgmap_heading_class' => get_post_meta( $gmap_id, 'wpgmap_heading_class', true ),
|
303 |
+
'wpgmap_show_heading' => get_post_meta( $gmap_id, 'wpgmap_show_heading', true ),
|
304 |
+
'wpgmap_latlng' => get_post_meta( $gmap_id, 'wpgmap_latlng', true ),
|
305 |
+
'wpgmap_map_zoom' => get_post_meta( $gmap_id, 'wpgmap_map_zoom', true ),
|
306 |
+
'wpgmap_disable_zoom_scroll' => get_post_meta( $gmap_id, 'wpgmap_disable_zoom_scroll', true ),
|
307 |
+
'wpgmap_map_width' => get_post_meta( $gmap_id, 'wpgmap_map_width', true ),
|
308 |
+
'wpgmap_map_height' => get_post_meta( $gmap_id, 'wpgmap_map_height', true ),
|
309 |
+
'wpgmap_map_type' => get_post_meta( $gmap_id, 'wpgmap_map_type', true ),
|
310 |
+
'wpgmap_map_address' => get_post_meta( $gmap_id, 'wpgmap_map_address', true ),
|
311 |
+
'wpgmap_show_infowindow' => get_post_meta( $gmap_id, 'wpgmap_show_infowindow', true ),
|
312 |
+
'wpgmap_enable_direction' => get_post_meta( $gmap_id, 'wpgmap_enable_direction', true ),
|
313 |
+
'wpgmap_marker_icon' => get_post_meta( $gmap_id, 'wpgmap_marker_icon', true )
|
314 |
+
);
|
315 |
+
|
316 |
+
return json_encode( $gmap_data );
|
317 |
+
}
|
318 |
+
|
319 |
+
public function remove_wpgmapembed_data() {
|
320 |
+
|
321 |
+
$meta_data = array(
|
322 |
+
'wpgmap_title',
|
323 |
+
'wpgmap_heading_class',
|
324 |
+
'wpgmap_show_heading',
|
325 |
+
'wpgmap_latlng',
|
326 |
+
'wpgmap_map_zoom',
|
327 |
+
'wpgmap_disable_zoom_scroll',
|
328 |
+
'wpgmap_map_width',
|
329 |
+
'wpgmap_map_height',
|
330 |
+
'wpgmap_map_type',
|
331 |
+
'wpgmap_map_address',
|
332 |
+
'wpgmap_show_infowindow',
|
333 |
+
'wpgmap_enable_direction'
|
334 |
+
);
|
335 |
+
|
336 |
+
$post_id = intval( $_POST['post_id'] );
|
337 |
+
wp_delete_post( $post_id );
|
338 |
+
foreach ( $meta_data as $field_name => $value ) {
|
339 |
+
delete_post_meta( $post_id, $field_name, $value );
|
340 |
+
}
|
341 |
+
$returnArray = array(
|
342 |
+
'responseCode' => 1,
|
343 |
+
'message' => "Deleted Successfully."
|
344 |
+
);
|
345 |
+
echo json_encode( $returnArray );
|
346 |
+
exit;
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Works on when plugin is activated successfully
|
351 |
+
*/
|
352 |
+
|
353 |
+
function wpgmap_do_after_activation( $plugin, $network_activation ) {
|
354 |
+
// do stuff
|
355 |
+
if ( $plugin == 'gmap-embed/srm_gmap_embed.php' ) {
|
356 |
+
wp_redirect( admin_url( 'admin.php?page=wpgmapembed' ) );
|
357 |
+
exit;
|
358 |
+
}
|
359 |
+
}
|
360 |
+
|
361 |
+
}
|
|
|
|
|
362 |
|
363 |
|
364 |
}
|
365 |
new srm_gmap_embed_main();
|
366 |
// including requird files
|
367 |
+
require_once plugin_dir_path( __FILE__ ) . '/includes/widget.php';
|
368 |
+
require_once plugin_dir_path( __FILE__ ) . '/includes/shortcodes.php';
|
369 |
|
370 |
+
if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
|
371 |
+
require_once plugin_dir_path( __FILE__ ) . '/includes/wpgmap_popup_content.php';
|
372 |
}
|
373 |
|
374 |
+
load_plugin_textdomain( 'gmap-embed', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
375 |
|
376 |
//updated at 07.04.2019 14:20:00
|
377 |
|
378 |
+
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'gmap_srm_settings_link' );
|
379 |
function gmap_srm_settings_link( $links ) {
|
380 |
$links[] = '<a href="' .
|
381 |
+
admin_url( 'admin.php?page=wpgmapembed' ) .
|
382 |
+
'">' . __( 'Settings' ) . '</a>';
|
383 |
+
|
384 |
return $links;
|
385 |
}
|
386 |
|
387 |
+
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'gmap_srm_settings_linka' );
|
388 |
function gmap_srm_settings_linka( $links ) {
|
389 |
+
$links[] = '<a target="_blank" style="color: #11967A;font-weight:bold;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZBERRKARGNEYA">' . __( 'Upgrade To Premium' ) . '</a>';
|
390 |
+
|
391 |
return $links;
|
392 |
}
|