WP Google Maps - Version 8.0.20

Version Description

  • Re-factored store locator into new class
  • Removed hard coded zoom level when editing marker
  • Improved OpenLayers gesture handling UX to prevent browser zooming when Ctrl is pressed over map viewport when the gesture notice is visible
  • WPGMZA.Distance.between now accepts latlng literals
  • Updated bundled OpenLayers library to 6.2.1
  • Fixed old marker not removed after editing location
  • Fixed OpenLayers longitude not wrapping properly causing markers to disappear when moving outside -180 to +180
  • Fixed UI style setting not changing
Download this release

Release Info

Developer perryrylance
Plugin Icon 128x128 WP Google Maps
Version 8.0.20
Comparing to
See all releases

Code changes from version 8.0.19 to 8.0.20

base/includes/wp-google-maps-polygons.php CHANGED
@@ -6,12 +6,6 @@ Polygon functionality for WP Google Maps
6
if(!defined('ABSPATH'))
7
exit;
8
9
- add_action('wp_enqueue_scripts', function() {
10
-
11
- wpgmza_enqueue_fontawesome();
12
-
13
- });
14
-
15
/**
16
* Render polygon editor HTML
17
* @param integer $mid Map ID
6
if(!defined('ABSPATH'))
7
exit;
8
9
/**
10
* Render polygon editor HTML
11
* @param integer $mid Map ID
constants.php CHANGED
@@ -5,6 +5,9 @@ if(!defined('ABSPATH'))
5
6
global $wpdb;
7
8
global $WPGMZA_TABLE_NAME_MARKERS;
9
global $WPGMZA_TABLE_NAME_MAPS;
10
global $WPGMZA_TABLE_NAME_POLYGONS;
@@ -18,5 +21,3 @@ $WPGMZA_TABLE_NAME_POLYGONS = $wpdb->prefix . 'wpgmza_polygon';
18
$WPGMZA_TABLE_NAME_POLYLINES = $wpdb->prefix . 'wpgmza_polylines';
19
$WPGMZA_TABLE_NAME_CIRCLES = $wpdb->prefix . 'wpgmza_circles';
20
$WPGMZA_TABLE_NAME_RECTANGLES = $wpdb->prefix . 'wpgmza_rectangles';
21
-
22
- define('WPGMZA_PLUGIN_DIR_URL', plugin_dir_url(__FILE__));
5
6
global $wpdb;
7
8
+ define('WPGMZA_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__));
9
+ define('WPGMZA_PLUGIN_DIR_URL', plugin_dir_url(__FILE__));
10
+
11
global $WPGMZA_TABLE_NAME_MARKERS;
12
global $WPGMZA_TABLE_NAME_MAPS;
13
global $WPGMZA_TABLE_NAME_POLYGONS;
21
$WPGMZA_TABLE_NAME_POLYLINES = $wpdb->prefix . 'wpgmza_polylines';
22
$WPGMZA_TABLE_NAME_CIRCLES = $wpdb->prefix . 'wpgmza_circles';
23
$WPGMZA_TABLE_NAME_RECTANGLES = $wpdb->prefix . 'wpgmza_rectangles';
css/common.css CHANGED
@@ -501,11 +501,6 @@ form.wpgmza-form .wpgmza-fancy-toggle-button + label
501
padding: 1em 1em;
502
}
503
504
- input.wpgmza-address
505
- {
506
- width: 320px;
507
- }
508
-
509
.wpgmza-upgrade-tab, .wpgmza-upgrade-tab a,
510
.update-att,
511
.update-att a
@@ -556,4 +551,5 @@ input[name='wpgmza_developer_mode']:checked + .notice-warning
556
z-index: 999;
557
text-align: center;
558
line-height: 400px;
559
}
501
padding: 1em 1em;
502
}
503
504
.wpgmza-upgrade-tab, .wpgmza-upgrade-tab a,
505
.update-att,
506
.update-att a
551
z-index: 999;
552
text-align: center;
553
line-height: 400px;
554
+ pointer-events: none;
555
}
css/styles/default.css CHANGED
@@ -1,5 +1,4 @@
1
- .wpgmza-store-locator > div > *,
2
- .wpgmza-directions-box-inner > div > *
3
{
4
display: inline-block;
5
/* vertical-align: top; */
@@ -11,11 +10,11 @@
11
width: 180px;
12
}
13
14
- .wpgmza-store-locator input[type="button"],
15
.wpgmza-not-found-msg,
16
div.wpgmza-waypoint-via,
17
.wpgmza-add-waypoint,
18
- input.wpgmza-get-directions
19
{
20
margin-left: 180px;
21
}
@@ -23,5 +22,6 @@
23
input.wpgmza-directions-from,
24
input.wpgmza-directions-to
25
{
26
- width: calc(80% - 180px);
27
}
1
+ .wpgmza-store-locator > div > *
2
{
3
display: inline-block;
4
/* vertical-align: top; */
10
width: 180px;
11
}
12
13
+ .wpgmza-store-locator input[type="button"]/*,
14
.wpgmza-not-found-msg,
15
div.wpgmza-waypoint-via,
16
.wpgmza-add-waypoint,
17
+ input.wpgmza-get-directions*/
18
{
19
margin-left: 180px;
20
}
22
input.wpgmza-directions-from,
23
input.wpgmza-directions-to
24
{
25
+ display: inline-block;
26
+ width: calc(100% - 72px);
27
}
html/settings-page.html.php CHANGED
@@ -366,7 +366,7 @@
366
</div>
367
368
<div id="marker-listing">
369
- <div class="update-nag update-att">
370
<i class="fa fa-arrow-circle-right"></i>
371
<a target="_blank"
372
href="<?php
366
</div>
367
368
<div id="marker-listing">
369
+ <div class="update-nag update-att wpgmza-upsell">
370
<i class="fa fa-arrow-circle-right"></i>
371
<a target="_blank"
372
href="<?php
html/store-locator.html.php ADDED
@@ -0,0 +1,30 @@
1
+ <div class="wpgmza-store-locator">
2
+ <div class="wpgmza-address-container">
3
+ <label
4
+ class="wpgmza-address"
5
+ data-name="addressLabel"></label>
6
+ <input
7
+ class="wpgmza-address"
8
+ type="text"
9
+ placeholder="<?php esc_attr_e('Enter a location', 'wp-google-maps'); ?>"
10
+ autocomplete="off"
11
+ data-name="defaultAddress"
12
+ />
13
+ </div>
14
+
15
+ <div class="wpgmza-radius-container">
16
+ <label class="wpgmza-radius">
17
+ <?php _e('Radius:', 'wp-google-maps'); ?>
18
+ </label>
19
+ <select class="wpgmza-radius"></select>
20
+ </div>
21
+
22
+ <input
23
+ class="wpgmza-search"
24
+ value="<?php esc_attr_e('Search', 'wp-google-maps'); ?>"
25
+ type="button"/>
26
+
27
+ <div class="wpgmza-no-results" style="display: none;">
28
+ <p data-name="notFoundMessage"></p>
29
+ </div>
30
+ </div>
includes/class.crud.php CHANGED
@@ -35,6 +35,9 @@ class Crud extends Factory implements \IteratorAggregate, \JsonSerializable
35
{
36
global $wpdb;
37
38
$this->fields = array();
39
$this->overrides = array();
40
@@ -71,12 +74,8 @@ class Crud extends Factory implements \IteratorAggregate, \JsonSerializable
71
else
72
throw new \Exception('Invalid ID');
73
74
- $this->table_name = $table_name;
75
-
76
$this->id = $id;
77
78
- Crud::cacheColumnsByTableName($table_name);
79
-
80
if($read_mode != Crud::BULK_READ)
81
{
82
if($this->id == -1)
@@ -91,6 +90,13 @@ class Crud extends Factory implements \IteratorAggregate, \JsonSerializable
91
if(!empty($arbitraryDataColumnName) && !empty($this->fields[$arbitraryDataColumnName]))
92
$this->parse_arbitrary_data($this->fields[$arbitraryDataColumnName]);
93
}
94
}
95
96
private static function cacheColumnsByTableName($table_name)
@@ -508,6 +514,33 @@ class Crud extends Factory implements \IteratorAggregate, \JsonSerializable
508
$this->trashed = true;
509
}
510
511
/**
512
* Set variables in bulk, this reduces the number of database calls
513
* @param string|array|object Either a string naming the property to be set (with a second argument which is the value), or an array or object of key and value pairs to be set on this object
35
{
36
global $wpdb;
37
38
+ $this->table_name = $table_name;
39
+ Crud::cacheColumnsByTableName($table_name);
40
+
41
$this->fields = array();
42
$this->overrides = array();
43
74
else
75
throw new \Exception('Invalid ID');
76
77
$this->id = $id;
78
79
if($read_mode != Crud::BULK_READ)
80
{
81
if($this->id == -1)
90
if(!empty($arbitraryDataColumnName) && !empty($this->fields[$arbitraryDataColumnName]))
91
$this->parse_arbitrary_data($this->fields[$arbitraryDataColumnName]);
92
}
93
+
94
+ $this->onCrudInitialized();
95
+ }
96
+
97
+ protected function onCrudInitialized()
98
+ {
99
+
100
}
101
102
private static function cacheColumnsByTableName($table_name)
514
$this->trashed = true;
515
}
516
517
+ public function duplicate()
518
+ {
519
+ global $wpdb;
520
+
521
+ $columns = array();
522
+
523
+ foreach($wpdb->get_col("SHOW COLUMNS FROM `{$this->table_name}`") as $name)
524
+ {
525
+ if($name == 'id')
526
+ continue;
527
+
528
+ $columns []= $name;
529
+ }
530
+
531
+ $imploded = implode(',', $columns);
532
+
533
+ $query = "INSERT INTO {$this->table_name} ($imploded) SELECT $imploded FROM {$this->table_name} WHERE id=%d";
534
+
535
+ $stmt = $wpdb->prepare($query, $this->id);
536
+
537
+ $wpdb->query($stmt);
538
+
539
+ $class = get_class($this);
540
+
541
+ return $class::createInstance($wpdb->insert_id);
542
+ }
543
+
544
/**
545
* Set variables in bulk, this reduces the number of database calls
546
* @param string|array|object Either a string naming the property to be set (with a second argument which is the value), or an array or object of key and value pairs to be set on this object
includes/class.database.php CHANGED
@@ -130,10 +130,15 @@ class Database extends Factory
130
sticky tinyint(1) DEFAULT '0',
131
other_data LONGTEXT NOT NULL,
132
latlng POINT,
133
PRIMARY KEY (id)
134
) AUTO_INCREMENT=1 " . Database::getCharsetAndCollate();
135
136
dbDelta($sql);
137
}
138
139
protected function installPolygonTable()
130
sticky tinyint(1) DEFAULT '0',
131
other_data LONGTEXT NOT NULL,
132
latlng POINT,
133
+ lnglat POINT NOT NULL,
134
PRIMARY KEY (id)
135
) AUTO_INCREMENT=1 " . Database::getCharsetAndCollate();
136
137
dbDelta($sql);
138
+
139
+ // TODO: Create marker first
140
+
141
+ // $wpdb->query("ALTER TABLE `$WPGMZA_TABLE_NAME_MARKERS` ADD SPATIAL INDEX(lnglat)");
142
}
143
144
protected function installPolygonTable()
includes/class.dom-document.php CHANGED
@@ -73,6 +73,68 @@ class DOMDocument extends \DOMDocument
73
return $result;
74
}
75
76
/**
77
* Loads the specified file and parses any PHP
78
* @param string $src The file you want to load
73
return $result;
74
}
75
76
+ private function translateLineNumber($htmlLineNumber, $src)
77
+ {
78
+
79
+ }
80
+
81
+ public function onError($severity, $message, $file, $unused)
82
+ {
83
+ if(!preg_match('/DOMDocument::loadHTML.+line: (\d+)/', $message, $m))
84
+ {
85
+ trigger_error($message, E_USER_WARNING);
86
+ return;
87
+ }
88
+
89
+ $htmlLineNumber = $m[1];
90
+ $lines = file($this->src_file);
91
+
92
+ $totalPhpLines = count($lines);
93
+ $lineCounter = 1;
94
+
95
+ $allowShortTags = ini_get('short_open_tag') == "1";
96
+ $regexOpenTag = ($allowShortTags ? '/<\?(php)?/' : '/<\?php/');
97
+ $regexCloseTag = "/\?>/";
98
+
99
+ $inPhp = false;
100
+
101
+ for($phpLineNumber = 1; $phpLineNumber <= $totalPhpLines; $phpLineNumber++)
102
+ {
103
+ if($lineCounter == $htmlLineNumber)
104
+ {
105
+ $message = preg_replace(
106
+ array('/loadHTML/', '/line: \d+/'),
107
+ array('loadPHPFile', "line: $phpLineNumber"),
108
+ $message
109
+ );
110
+ trigger_error($message, E_USER_WARNING);
111
+
112
+ return;
113
+ }
114
+
115
+ $line = $lines[$phpLineNumber - 1];
116
+
117
+ $numOpenTags = preg_match_all($regexOpenTag, $line);
118
+ $numCloseTags = preg_match_all($regexCloseTag, $line);
119
+
120
+ if($numOpenTags > $numCloseTags)
121
+ {
122
+ $inPhp = true;
123
+ }
124
+ else if($numCloseTags > 0)
125
+ {
126
+ $inPhp = false;
127
+ $lineCounter--; // NB: I don't understand why a close tag swallows the newline, but it does appear to
128
+ }
129
+
130
+ if(!$inPhp)
131
+ $lineCounter++;
132
+ }
133
+
134
+ trigger_error("Failed to translate line number", E_USER_WARNING);
135
+ trigger_error($message, E_USER_WARNING);
136
+ }
137
+
138
/**
139
* Loads the specified file and parses any PHP
140
* @param string $src The file you want to load
includes/class.dom-element.php CHANGED
@@ -38,8 +38,10 @@ class DOMElement extends \DOMElement
38
public function querySelector($query)
39
{
40
$results = $this->querySelectorAll($query);
41
if(empty($results))
42
return null;
43
return $results[0];
44
}
45
@@ -66,7 +68,7 @@ class DOMElement extends \DOMElement
66
if($sort)
67
usort($results, array('WPGMZA\DOMElement', 'sortByDOMPosition'));
68
69
- return $results;
70
}
71
72
/**
@@ -124,6 +126,16 @@ class DOMElement extends \DOMElement
124
return null;
125
}
126
127
/**
128
* Test if this element comes before the other element in the DOM tree
129
* @return boolean TRUE if this element comes before the other, FALSE if not
@@ -293,14 +305,21 @@ class DOMElement extends \DOMElement
293
294
if($body = $node->querySelector("body"))
295
{
296
- // TODO: I don't think a query selector is necessary here. Iterating over the bodies children should be more optimal.
297
- foreach($node->querySelectorAll("body>*") as $child)
298
$this->appendChild($child);
299
}
300
else
301
$this->appendChild($node);
302
303
- return $this;
304
}
305
306
/**
@@ -530,6 +549,9 @@ class DOMElement extends \DOMElement
530
if(!$name)
531
continue;
532
533
switch($input->getAttribute('type'))
534
{
535
case 'checkbox':
@@ -716,4 +738,3 @@ class DOMElement extends \DOMElement
716
}
717
}
718
719
- ?>
38
public function querySelector($query)
39
{
40
$results = $this->querySelectorAll($query);
41
+
42
if(empty($results))
43
return null;
44
+
45
return $results[0];
46
}
47
68
if($sort)
69
usort($results, array('WPGMZA\DOMElement', 'sortByDOMPosition'));
70
71
+ return new DOMQueryResults($results);
72
}
73
74
/**
126
return null;
127
}
128
129
+ /**
130
+ * Wraps this element in the element passed in, then replaces this nodes original position
131
+ * @param DOMElement The element to wrap this element in
132
+ */
133
+ public function wrap($wrapper)
134
+ {
135
+ $this->parentNode->replaceChild($wrapper, $this);
136
+ $wrapper->appendChild($this);
137
+ }
138
+
139
/**
140
* Test if this element comes before the other element in the DOM tree
141
* @return boolean TRUE if this element comes before the other, FALSE if not
305
306
if($body = $node->querySelector("body"))
307
{
308
+ // TODO: I don't think a query selector is necessary here. Iterating over the bodies children should be more optimal
309
+ $results = $node->querySelectorAll("body>*");
310
+
311
+ foreach($results as $child)
312
$this->appendChild($child);
313
+
314
+ return $results;
315
}
316
else
317
+ {
318
$this->appendChild($node);
319
+ return $node;
320
+ }
321
322
+ return null;
323
}
324
325
/**
549
if(!$name)
550
continue;
551
552
+ if(preg_match('/nonce/i', $name))
553
+ continue; // NB: Do not serialize nonce values
554
+
555
switch($input->getAttribute('type'))
556
{
557
case 'checkbox':
738
}
739
}
740
includes/class.dom-query-results.php ADDED
@@ -0,0 +1,95 @@
1
+ <?php
2
+
3
+ namespace WPGMZA;
4
+
5
+ class DOMQueryResults implements \ArrayAccess, \Countable, \Iterator
6
+ {
7
+ private $index = 0;
8
+ private $container;
9
+
10
+ public function __construct(array $arr = null)
11
+ {
12
+ if(!empty($arr))
13
+ $this->container = $arr;
14
+ else
15
+ $this->container = array();
16
+ }
17
+
18
+ public function __call($name, $arguments)
19
+ {
20
+ foreach($this->container as $element)
21
+ {
22
+ if(!method_exists($element, $name))
23
+ throw new \Exception("No such method '$name' on " . get_class($element));
24
+
25
+ call_user_func_array(
26
+ array($element, $name),
27
+ $arguments
28
+ );
29
+ }
30
+
31
+ return $this;
32
+ }
33
+
34
+ public function offsetExists($offset)
35
+ {
36
+ return isset($this->container[$offset]);
37
+ }
38
+
39
+ public function offsetGet($offset)
40
+ {
41
+ return isset($this->container[$offset]) ? $this->container[$offset] : null;
42
+ }
43
+
44
+ public function offsetSet($offset, $value)
45
+ {
46
+ if(!($value instanceof DOMElement))
47
+ throw new \Exception("Only DOMElement is permitted in query results");
48
+
49
+ if(is_null($offset))
50
+ $this->container[] = $value;
51
+ else
52
+ $this->container[$offset] = $value;
53
+ }
54
+
55
+ public function offsetUnset($offset)
56
+ {
57
+ unset($this->container[$offset]);
58
+ }
59
+
60
+ public function count()
61
+ {
62
+ return count($this->container);
63
+ }
64
+
65
+ public function current()
66
+ {
67
+ return $this->container[$this->index];
68
+ }
69
+
70
+ public function next()
71
+ {
72
+ $this->index++;
73
+ }
74
+
75
+ public function key()
76
+ {
77
+ return $this->index;
78
+ }
79
+
80
+ public function valid()
81
+ {
82
+ return isset($this->container[$this->key()]);
83
+ }
84
+
85
+ public function rewind()
86
+ {
87
+ $this->index = 0;
88
+ }
89
+
90
+ public function reverse()
91
+ {
92
+ $this->container = array_reverse($this->container);
93
+ $this->rewind();
94
+ }
95
+ }
includes/class.elias-fano.php CHANGED
@@ -121,3 +121,4 @@ class EliasFano
121
return $list;
122
}
123
}
121
return $list;
122
}
123
}
124
+
includes/class.factory.php CHANGED
@@ -44,6 +44,10 @@ class Factory
44
45
$override = call_user_func_array('apply_filters', $filter_args);
46
47
if($override instanceof \WPGMZA\Factory)
48
return $override;
49
44
45
$override = call_user_func_array('apply_filters', $filter_args);
46
47
+ // NB: This stops override being the same as the first argument, which is needed for example when passing a Map as the first argument of StoreLocator
48
+ if(count($args) && $args[0] === $override)
49
+ $override = null;
50
+
51
if($override instanceof \WPGMZA\Factory)
52
return $override;
53
includes/class.google-maps-api-loader.php CHANGED
@@ -129,13 +129,17 @@ class GoogleMapsAPILoader
129
// API Key
130
$key = get_option('wpgmza_google_maps_api_key');
131
132
- if($key)
133
$params['key'] = $key;
134
else if(is_admin())
135
$params['key'] = get_option('wpgmza_temp_api');
136
137
// Libraries
138
$libraries = array('geometry', 'places', 'visualization');
139
$params['libraries'] = implode(',', $libraries);
140
141
$params = apply_filters( 'wpgmza_google_maps_api_params', $params );
129
// API Key
130
$key = get_option('wpgmza_google_maps_api_key');
131
132
+ if(!empty($key))
133
$params['key'] = $key;
134
else if(is_admin())
135
$params['key'] = get_option('wpgmza_temp_api');
136
137
// Libraries
138
$libraries = array('geometry', 'places', 'visualization');
139
+
140
+ if($wpgmza->getCurrentPage() == Plugin::PAGE_MAP_EDIT)
141
+ $libraries[] = 'drawing';
142
+
143
$params['libraries'] = implode(',', $libraries);
144
145
$params = apply_filters( 'wpgmza_google_maps_api_params', $params );
includes/class.map.php CHANGED
@@ -18,6 +18,8 @@ class Map extends Crud
18
protected $_overrides;
19
protected $_element;
20
21
/**
22
* Constructor
23
* @param int|array|object $id_or_fields The ID to read an existing map, or an object or array to create a new one.
@@ -25,6 +27,7 @@ class Map extends Crud
25
public function __construct($id_or_fields=-1, $overrides=null)
26
{
27
global $wpdb;
28
29
Crud::__construct("{$wpdb->prefix}wpgmza_maps", $id_or_fields);
30
@@ -38,6 +41,15 @@ class Map extends Crud
38
39
$this->_element = $document->querySelector("div");
40
$this->_element->setAttribute('data-settings', json_encode($this));
41
}
42
43
public function __get($name)
@@ -45,7 +57,8 @@ class Map extends Crud
45
switch($name)
46
{
47
case 'overrides':
48
- return $this->_overrides;
49
break;
50
51
case "storeLocatorDistanceUnits":
18
protected $_overrides;
19
protected $_element;
20
21
+ protected $_storeLocator;
22
+
23
/**
24
* Constructor
25
* @param int|array|object $id_or_fields The ID to read an existing map, or an object or array to create a new one.
27
public function __construct($id_or_fields=-1, $overrides=null)
28
{
29
global $wpdb;
30
+ global $wpgmza;
31
32
Crud::__construct("{$wpdb->prefix}wpgmza_maps", $id_or_fields);
33
41
42
$this->_element = $document->querySelector("div");
43
$this->_element->setAttribute('data-settings', json_encode($this));
44
+
45
+ if(!$wpgmza->isProVersion())
46
+ $this->onInit();
47
+ }
48
+
49
+ protected function onInit()
50
+ {
51
+ if($this->store_locator_enabled == 1)
52
+ $this->_storeLocator = StoreLocator::createInstance($this);
53
}
54
55
public function __get($name)
57
switch($name)
58
{
59
case 'overrides':
60
+ case 'storeLocator':
61
+ return $this->{"_$name"};
62
break;
63
64
case "storeLocatorDistanceUnits":
includes/class.marker-filter.php CHANGED
@@ -134,6 +134,14 @@ class MarkerFilter extends Factory
134
$query->params[] = $radius;
135
}
136
137
protected function applyLimit($query)
138
{
139
if(empty($this->_limit))
@@ -159,6 +167,7 @@ class MarkerFilter extends Factory
159
$query->table = $WPGMZA_TABLE_NAME_MARKERS;
160
161
$this->applyRadiusClause($query);
162
$this->applyLimit($query);
163
164
return $query;
@@ -199,7 +208,7 @@ class MarkerFilter extends Factory
199
$markers[] = Marker::createInstance($data, Crud::BULK_READ);
200
}
201
202
- return $markers;
203
}
204
205
public function getFilteredIDs()
134
$query->params[] = $radius;
135
}
136
137
+ protected function applyIDsClause($set)
138
+ {
139
+ if(empty($this->ids))
140
+ return;
141
+
142
+ $query->in('id', $set);
143
+ }
144
+
145
protected function applyLimit($query)
146
{
147
if(empty($this->_limit))
167
$query->table = $WPGMZA_TABLE_NAME_MARKERS;
168
169
$this->applyRadiusClause($query);
170
+ $this->applyIDsClause($query);
171
$this->applyLimit($query);
172
173
return $query;
208
$markers[] = Marker::createInstance($data, Crud::BULK_READ);
209
}
210
211
+ return apply_filters('wpgmza_fetch_integrated_markers', $markers, $this);
212
}
213
214
public function getFilteredIDs()
includes/class.marker.php CHANGED
@@ -70,6 +70,7 @@ class Marker extends Crud implements \JsonSerializable
70
$json = Crud::jsonSerialize();
71
72
unset($json['latlng']);
73
74
return $json;
75
}
@@ -99,6 +100,9 @@ class Marker extends Crud implements \JsonSerializable
99
if($name == 'latlng')
100
return "POINT(" . floatval($this->lat) . " " . floatval($this->lng) . ")";
101
102
return Crud::get_column_parameter($name);
103
}
104
@@ -132,10 +136,16 @@ class Marker extends Crud implements \JsonSerializable
132
$this->lat,
133
$this->lng,
134
$this->get_column_parameter('latlng'),
135
$this->id
136
);
137
138
- $stmt = $wpdb->prepare("UPDATE " . $this->get_table_name() . " SET lat=%s, lng=%s, latlng={$wpgmza->spatialFunctionPrefix}GeomFromText(%s) WHERE id=%d", $params);
139
140
$wpdb->query($stmt);
141
}
70
$json = Crud::jsonSerialize();
71
72
unset($json['latlng']);
73
+ unset($json['lnglat']);
74
75
return $json;
76
}
100
if($name == 'latlng')
101
return "POINT(" . floatval($this->lat) . " " . floatval($this->lng) . ")";
102
103
+ if($name == 'lnglat')
104
+ return "POINT(" . floatval($this->lat) . " " . floatval($this->lng) . ")";
105
+
106
return Crud::get_column_parameter($name);
107
}
108
136
$this->lat,
137
$this->lng,
138
$this->get_column_parameter('latlng'),
139
+ $this->get_column_parameter('lnglat'),
140
$this->id
141
);
142
143
+ $stmt = $wpdb->prepare("UPDATE " . $this->get_table_name() . "
144
+ SET lat=%s,
145
+ lng=%s,
146
+ latlng={$wpgmza->spatialFunctionPrefix}GeomFromText(%s),
147
+ lnglat={$wpgmza->spatialFunctionPrefix}GeomFromText(%s)
148
+ WHERE id=%d", $params);
149
150
$wpdb->query($stmt);
151
}
includes/class.plugin.php CHANGED
@@ -260,6 +260,8 @@ class Plugin extends Factory
260
'googleMapsAPIErrorDialog' => $googleMapsAPIErrorDialogHTML
261
),
262
263
'resturl' => preg_replace('#/$#', '', get_rest_url(null, 'wpgmza/v1')),
264
'restnonce' => wp_create_nonce('wp_rest'),
265
'restnoncetable' => $this->restAPI->getNonceTable(),
260
'googleMapsAPIErrorDialog' => $googleMapsAPIErrorDialogHTML
261
),
262
263
+ 'imageFolderURL' => plugin_dir_url(WPGMZA_FILE) . 'images/',
264
+
265
'resturl' => preg_replace('#/$#', '', get_rest_url(null, 'wpgmza/v1')),
266
'restnonce' => wp_create_nonce('wp_rest'),
267
'restnoncetable' => $this->restAPI->getNonceTable(),
includes/class.store-locator.php ADDED
@@ -0,0 +1,160 @@
1
+ <?php
2
+
3
+ namespace WPGMZA;
4
+
5
+ class StoreLocator extends Factory implements \IteratorAggregate
6
+ {
7
+ private $_document;
8
+ private $_map;
9
+
10
+ public function __construct(Map $map)
11
+ {
12
+ global $wpgmza;
13
+
14
+ $this->_map = $map;
15
+
16
+ $this->_document = new DOMDocument();
17
+ $this->_document->loadPHPFile(plugin_dir_path(WPGMZA_FILE) . 'html/store-locator.html.php');
18
+
19
+ $this->_document->populate($this);
20
+
21
+ $this->populateRadiusSelect();
22
+
23
+ if($wpgmza->settings->useLegacyHTML)
24
+ {
25
+ $document = $this->_document;
26
+
27
+ $document
28
+ ->querySelectorAll(".wpgmza-store-locator")
29
+ ->addClass("wpgmza_sl_main_div");
30
+
31
+ $document
32
+ ->querySelectorAll(".wpgmza-address-container")
33
+ ->addClass("wpgmza-form-field wpgmza_sl_query_div wpgmza-clearfix");
34
+
35
+ $document
36
+ ->querySelectorAll("label.wpgmza-address")
37
+ ->setAttribute("for", "addressInput")
38
+ ->addClass("wpgmza-form-field__label wpgmza-form-field__label--float");
39
+
40
+ $document
41
+ ->querySelectorAll("input.wpgmza-address")
42
+ ->setAttribute("id", "addressInput")
43
+ ->setAttribute("size", 20);
44
+
45
+ $document
46
+ ->querySelectorAll(".wpgmza-radius-container")
47
+ ->addClass("wpgmza-form-field wpgmza_sl_radius_div wpgmza-clearfix");
48
+
49
+ $document
50
+ ->querySelectorAll("label.wpgmza-radius")
51
+ ->setAttribute("for", "radiusSelect")
52
+ ->addClass("wpgmza-form-field__label wpgmza-form-field__label--float");
53
+
54
+ $document
55
+ ->querySelectorAll("select.wpgmza-radius")
56
+ ->setAttribute("id", "radiusSelect")
57
+ ->addClass("wpgmza-form-field__input wpgmza_sl_radius_select");
58
+
59
+ $document
60
+ ->querySelectorAll("input.wpgmza-search")
61
+ ->addClass("wpgmza_sl_search_button")
62
+ ->setAttribute("onclick", "searchLocations({$this->map->id})");
63
+
64
+ $document
65
+ ->querySelectorAll("div.wpgmza-no-results")
66
+ ->addClass("wpgmza-not-found-msg js-not-found-msg");
67
+ }
68
+ }
69
+
70
+ public function __get($name)
71
+ {
72
+ if(isset($this->{"_$name"}))
73
+ return $this->{"_$name"};
74
+
75
+ switch($name)
76
+ {
77
+ case "addressLabel":
78
+ case "defaultAddress":
79
+ case "notFoundMessage":
80
+ case "defaultRadius":
81
+
82
+ $defaults = array(
83
+ "addressLabel" => __('ZIP / Address:', 'wp-google-maps'),
84
+ "defaultAddress" => '',
85
+ "notFoundMessage" => __('No results found in this location. Please try again.', 'wp-google-maps'),
86
+ "defaultRadius" => '10'
87
+ );
88
+
89
+ $snakeCase = strtolower( preg_replace('/(\b[a-z]+|\G(?!^))((?:[A-Z]|\d+)[a-z]*)/', '\1_\2', $name) );
90
+
91
+ if(!empty($this->map->{"store_locator_$snakeCase"}))
92
+ return $this->map->{"store_locator_$snakeCase"};
93
+
94
+ return $defaults[$name];
95
+ break;
96
+
97
+ case "html":
98
+ return $this->_document->html;
99
+ break;
100
+ }
101
+ }
102
+
103
+ public function getIterator()
104
+ {
105
+ $reflection = new \ReflectionObject($this);
106
+ $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
107
+
108
+ $arr = array();
109
+ foreach($properties as $prop)
110
+ $arr[$prop->name] = $this->{$prop->name};
111
+
112
+ $iterator = new \ArrayIterator(
113
+ array_merge(
114
+ $arr,
115
+ array(
116
+ 'addressLabel' => $this->addressLabel,
117
+ 'defaultAddress' => $this->defaultAddress,
118
+ 'notFoundMessage' => $this->notFoundMessage,
119
+ 'defaultRadius' => $this->defaultRadius
120
+ )
121
+ )
122
+ );
123
+
124
+ return $iterator;
125
+ }
126
+
127
+ protected function populateRadiusSelect()
128
+ {
129
+ global $wpgmza;
130
+
131
+ $document = $this->_document;
132
+ $radii = array(1, 5, 10, 25, 50, 75, 100, 150, 200, 300);
133
+ $suffix = __('km', 'wp-google-maps');
134
+ $select = $document->querySelector("select.wpgmza-radius");
135
+
136
+ if(!empty($wpgmza->settings->wpgmza_store_locator_radii))
137
+ $radii = preg_split('/\s*,\s*/', $wpgmza->settings->wpgmza_store_locator_radii);
138
+
139
+ if(!empty($this->map->store_locator_distance) && $this->map->store_locator_distance == 1)
140
+ $suffix = __('mi', 'wp-google-maps');
141
+
142
+ foreach($radii as $radius)
143
+ {
144
+ $option = $document->createElement('option');
145
+
146
+ $option->addClass("wpgmza-radius");
147
+ $option->setAttribute("value", $radius);
148
+
149
+ if($radius == $this->defaultRadius)
150
+ $option->setAttribute("selected", "selected");
151
+
152
+ if($wpgmza->settings->useLegacyHTML)
153
+ $option->addClass("wpgmza_sl_select_option");
154
+
155
+ $option->appendText($radius . $suffix);
156
+
157
+ $select->appendChild($option);
158
+ }
159
+ }
160
+ }
includes/class.strings.php CHANGED
@@ -83,7 +83,10 @@ class Strings
83
'use_two_fingers' => __('Use two fingers to move the map', 'wp-google-maps'),
84
'use_ctrl_scroll_to_zoom' => __('Use ctrl + scroll to zoom the map', 'wp-google-maps'),
85
'geocode_was_not_successful' => __('Geocode was not successful for the following reason: ', 'wp-google-maps'),
86
- 'geocoding_library_notice' => __('Geocoding this address failed. Please check you have enabled the Geocoding API for your Google Maps API project.', 'wp-google-maps')
87
));
88
}
89
83
'use_two_fingers' => __('Use two fingers to move the map', 'wp-google-maps'),
84
'use_ctrl_scroll_to_zoom' => __('Use ctrl + scroll to zoom the map', 'wp-google-maps'),
85
'geocode_was_not_successful' => __('Geocode was not successful for the following reason: ', 'wp-google-maps'),
86
+ 'geocoding_library_notice' => __('Geocoding this address failed. Please check you have enabled the Geocoding API for your Google Maps API project.', 'wp-google-maps'),
87
+
88
+ 'map_delete_prompt_text' => __('Are you sure you want to delete this map?', 'wp-google-maps'),
89
+ 'map_bulk_delete_prompt_text' => __('Are you sure you want to delete these maps?', 'wp-google-maps')
90
));
91
}
92
includes/class.upgrader.php CHANGED
@@ -19,5 +19,15 @@ class Upgrader
19
global $wpgmza;
20
$wpgmza->updateAllMarkerXMLFiles();
21
});
22
}
23
}
19
global $wpgmza;
20
$wpgmza->updateAllMarkerXMLFiles();
21
});
22
+
23
+ $this->upgradeLngLat();
24
+ }
25
+
26
+ protected function upgradeLngLat()
27
+ {
28
+ /*global $wpdb;
29
+ global $WPGMZA_TABLE_NAME_MARKERS;
30
+
31
+ $wpdb->query("UPDATE `$WPGMZA_TABLE_NAME_MARKERS` SET lnglat = POINT(Y(latlng), X(latlng))");*/
32
}
33
}
includes/google-maps/class.google-maps-loader.php CHANGED
@@ -99,6 +99,8 @@ class GoogleMapsLoader
99
$key = get_option('wpgmza_google_maps_api_key');
100
if(!empty($key))
101
$params['key'] = $key;
102
103
$params = apply_filters( 'wpgmza_google_maps_api_params', $params );
104
99
$key = get_option('wpgmza_google_maps_api_key');
100
if(!empty($key))
101
$params['key'] = $key;
102
+ else if(is_admin())
103
+ $params['key'] = get_option('wpgmza_temp_api');
104
105
$params = apply_filters( 'wpgmza_google_maps_api_params', $params );
106
includes/legacy/functions.circle.php ADDED
@@ -0,0 +1,324 @@
1
+ <?php
2
+
3
+ if(!function_exists('wpgmza_get_circle_data'))
4
+ {
5
+ function wpgmza_get_circle_data($map_id)
6
+ {
7
+ global $wpgmza;
8
+ global $wpdb;
9
+ global $wpgmza_tblname_circles;
10
+
11
+ $stmt = $wpdb->prepare("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(center) AS center FROM $wpgmza_tblname_circles WHERE map_id=%d", array($map_id));
12
+ $results = $wpdb->get_results($stmt);
13
+
14
+ $circles = array();
15
+ foreach($results as $obj)
16
+ $circles[$obj->id] = $obj;
17
+
18
+ return $circles;
19
+ }
20
+ }
21
+
22
+ function wpgmza_b_add_circle($mid)
23
+ {
24
+ global $wpgmza_tblname_maps;
25
+ global $wpdb;
26
+
27
+ wpgmaps_b_admin_add_circle_javascript();
28
+
29
+ if ($_GET['action'] == "add_circle" && isset($mid)) {
30
+ $res = wpgmza_get_map_data($mid);
31
+ echo "
32
+
33
+
34
+
35
+
36
+ <div class='wrap'>
37
+ <h1>WP Google Maps</h1>
38
+ <div class='wide'>
39
+
40
+ <h2>".__("Add circle","wp-google-maps")."</h2>
41
+ <form action='?page=wp-google-maps-menu&action=edit&map_id=".$mid."' method='post' id='wpgmaps_add_circle_form'>
42
+ <input type='hidden' name='wpgmaps_map_id' id='wpgmaps_map_id' value='".$mid."' />
43
+ <input type='hidden' name='wpgmaps_circle-nonce' id='wpgmaps_b_nonce' value='".wp_create_nonce( 'wpgmaps_circle-nonce' )."' />
44
+ <input type='hidden' name='center'/>
45
+
46
+ <table class='wpgmza-listing-comp' style='width:30%;float:left;'>
47
+ <tr>
48
+ <td>
49
+ ".__("Name","wp-google-maps")."
50
+ </td>
51
+ <td>
52
+ <input id=\"circle\" name=\"circle_name\" type=\"text\" value=\"\" />
53
+ </td>
54
+ </tr>
55
+ <tr>
56
+ <td>
57
+ ".__("Color","wp-google-maps")."
58
+ </td>
59
+ <td>
60
+ <input id=\"circle_color\" name=\"circle_color\" type=\"color\" value=\"#ff0000\" />
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>
65
+ ".__("Opacity","wp-google-maps")."
66
+ </td>
67
+ <td>
68
+ <input id=\"circle_opacity\" name=\"circle_opacity\" type=\"text\" value=\"0.6\" /> <small class='wpgmza-info__small'>(0 - 1.0) example: 0.6 for 60%</small>
69
+ </td>
70
+ </tr>
71
+ <tr>
72
+ <td>
73
+ ".__("Radius","wp-google-maps")."
74
+ </td>
75
+ <td>
76
+ <input id=\"circle_radius\" name=\"circle_radius\" type=\"text\" value=\"20\" />
77
+ </td>
78
+ </tr>
79
+ <tr>
80
+ <td></td>
81
+ <td>
82
+ <p id='circle-radius-visibility-warning' class='notice notice-warning'>
83
+ " . __('Please note your circle may be too small to be visible at this zoom level', 'wp-google-maps') . "
84
+ </p>
85
+ </td>
86
+ </tr>
87
+ </table>
88
+ <div class='wpgmza_map_seventy'>
89
+ <div id=\"wpgmza_map\">&nbsp;</div>
90
+ <p>
91
+ <ul style=\"list-style:initial; margin-top: -145px !important;\" class='update-nag update-blue update-slim update-map-overlay'>
92
+ <li style=\"margin-left:30px;\">" . __('Click on the map to insert a circle.', 'wp-google-maps') . "</li>
93
+ <li style=\"margin-left:30px;\">" . __('Click or drag the circle to move it.', 'wp-google-maps') . "</li>
94
+ </ul>
95
+ </p>
96
+ </div>
97
+
98
+ <p class='submit'><a href='javascript:history.back();' class='button button-secondary' title='".__("Cancel")."'>".__("Cancel")."</a> <input type='submit' name='wpgmza_save_circle' class='button-primary' value='".__("Save Circle","wp-google-maps")." &raquo;' /></p>
99
+
100
+ </form>
101
+ </div>
102
+
103
+
104
+ </div>
105
+
106
+
107
+
108
+ ";
109
+
110
+ }
111
+ }
112
+
113
+ function wpgmza_b_edit_circle($mid)
114
+ {
115
+ global $wpgmza;
116
+ global $wpgmza_tblname_maps;
117
+ global $wpgmza_tblname_circles;
118
+ global $wpdb;
119
+
120
+ wpgmaps_b_admin_add_circle_javascript();
121
+
122
+ if ($_GET['action'] == "edit_circle" && isset($mid)) {
123
+ $res = wpgmza_get_map_data($mid);
124
+ $circle_id = (int)$_GET['circle_id'];
125
+
126
+ $results = $wpdb->get_results("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(center) AS center FROM $wpgmza_tblname_circles WHERE id = $circle_id");
127
+
128
+ if(empty($results))
129
+ {
130
+ echo "<p class='notice notice-error'>" . __('Invalid circle ID', 'wp-google-maps') . "</p>";
131
+ return;
132
+ }
133
+
134
+ $circle = $results[0];
135
+
136
+ $name = addcslashes($circle->name, '"');
137
+ $center = preg_replace('/POINT\(|[,)]/', '', $circle->center);
138
+
139
+ echo "
140
+ <div class='wrap'>
141
+ <h1>WP Google Maps</h1>
142
+ <div class='wide'>
143
+
144
+ <h2>".__("Edit circle","wp-google-maps")."</h2>
145
+ <form action='?page=wp-google-maps-menu&action=edit&map_id=".$mid."' method='post' id='wpgmaps_add_circle_form'>
146
+ <input type='hidden' name='wpgmaps_map_id' id='wpgmaps_map_id' value='".$mid."' />
147
+ <input type='hidden' name='circle_id' value='{$circle_id}'/>
148
+ <input type='hidden' name='wpgmaps_circle-nonce' id='wpgmaps_b_nonce' value='".wp_create_nonce( 'wpgmaps_circle-nonce' )."' />
149
+
150
+
151
+ <input type='hidden' name='center' value='{$center}'/>
152
+
153
+ <table class='wpgmza-listing-comp' style='width:30%;float:left;'>
154
+ <tr>
155
+ <td>
156
+ " . __("Name","wp-google-maps") . "
157
+ </td>
158
+ <td>
159
+ <input id=\"circle\" name=\"circle_name\" type=\"text\" value=\"$name\" />
160
+ </td>
161
+ </tr>
162
+ <tr>
163
+ <td>
164
+ " . __('Center', 'wp-google-maps') . "
165
+ </td>
166
+ <td>
167
+ <input name='center' value='" . esc_attr($center) . "'/>
168
+ <button id='fit-bounds-to-shape'
169
+ class='button button-secondary'
170
+ type='button'
171
+ title='" . __('Fit map bounds to shape', 'wp-google-maps') . "'
172
+ data-fit-bounds-to-shape='circle'>
173
+ <i class='fas fa-eye'></i>
174
+ </button>
175
+ </td>
176
+ </tr>
177
+ <tr>
178
+ <td>
179
+ ".__("Color","wp-google-maps")."
180
+ </td>
181
+ <td>
182
+ <input id=\"circle_color\" name=\"circle_color\" type=\"color\" value=\"{$circle->color}\" />
183
+ </td>
184
+ </tr>
185
+ <tr>
186
+ <td>
187
+ ".__("Opacity","wp-google-maps")."
188
+ </td>
189
+ <td>
190
+ <input id=\"circle_opacity\" name=\"circle_opacity\" type=\"text\" value=\"{$circle->opacity}\" type='number' step='any' /> <small class='wpgmza-info__small'>(0 - 1.0) example: 0.6 for 60%</small>
191
+ </td>
192
+ </tr>
193
+ <tr>
194
+ <td>
195
+ ".__("Radius","wp-google-maps")."
196
+ </td>
197
+ <td>
198
+ <input id=\"circle_radius\" name=\"circle_radius\" type=\"text\" value=\"{$circle->radius}\" type='number' step='any' />
199
+ </td>
200
+ </tr>
201
+ <tr>
202
+ <td></td>
203
+ <td>
204
+ <p id='circle-radius-visibility-warning' class='notice notice-warning'>
205
+ " . __('Please note your circle may be too small to be visible at this zoom level', 'wp-google-maps') . "
206
+ </p>
207
+ </td>
208
+ </tr>
209
+ </table>
210
+ <div class='wpgmza_map_seventy'>
211
+ <div id=\"wpgmza_map\">&nbsp;</div>
212
+ <p>
213
+ <ul style=\"list-style:initial; margin-top: -145px !important;\" class='update-nag update-blue update-slim update-map-overlay'>
214
+ <li style=\"margin-left:30px;\">" . __('Click or drag the circle to move it.', 'wp-google-maps') . "</li>
215
+ </ul>
216
+ </p>
217
+ </div>
218
+
219
+ <p class='submit'><a href='javascript:history.back();' class='button button-secondary' title='".__("Cancel")."'>".__("Cancel")."</a> <input type='submit' name='wpgmza_save_circle' class='button-primary' value='".__("Save Circle","wp-google-maps")." &raquo;' /></p>
220
+
221
+ </form>
222
+ </div>
223
+
224
+
225
+ </div>
226
+
227
+
228
+
229
+ ";
230
+
231
+ }
232
+ }
233
+
234
+ function wpgmaps_b_admin_add_circle_javascript()
235
+ {
236
+ $res = wpgmza_get_map_data(sanitize_text_field($_GET['map_id']));
237
+ $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
238
+
239
+ $wpgmza_lat = $res->map_start_lat;
240
+ $wpgmza_lng = $res->map_start_lng;
241
+ $wpgmza_map_type = $res->type;
242
+ $wpgmza_width = $res->map_width;
243
+ $wpgmza_height = $res->map_height;
244
+ $wpgmza_width_type = $res->map_width_type;
245
+ $wpgmza_height_type = $res->map_height_type;
246
+ if (!$wpgmza_map_type || $wpgmza_map_type == "" || $wpgmza_map_type == "1") { $wpgmza_map_type = "ROADMAP"; }
247
+ else if ($wpgmza_map_type == "2") { $wpgmza_map_type = "SATELLITE"; }
248
+ else if ($wpgmza_map_type == "3") { $wpgmza_map_type = "HYBRID"; }
249
+ else if ($wpgmza_map_type == "4") { $wpgmza_map_type = "TERRAIN"; }
250
+ else { $wpgmza_map_type = "ROADMAP"; }
251
+ $start_zoom = $res->map_start_zoom;
252
+ if ($start_zoom < 1 || !$start_zoom) {
253
+ $start_zoom = 5;
254
+ }
255
+
256
+ $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
257
+ global $api_version_string;
258
+
259
+ $localized_data = array(
260
+ 'wpgmza_lat' => $wpgmza_lat,
261
+ 'wpgmza_lng' => $wpgmza_lng,
262
+ 'start_zoom' => $start_zoom,
263
+ 'wpgmza_width' => $wpgmza_width,
264
+ 'wpgmza_width_type' => $wpgmza_width_type,
265
+ 'wpgmza_height' => $wpgmza_height,
266
+ 'wpgmza_height_type' => $wpgmza_height_type,
267
+ 'wpgmza_map_type' => $wpgmza_map_type
268
+ );
269
+
270
+ wp_enqueue_style('wpgooglemaps-css', wpgmaps_get_plugin_url() . 'css/wpgmza_style.css');
271
+ wp_enqueue_script('wpgmza-legacy-circle-panel', plugin_dir_url(__FILE__) . 'js/legacy/legacy-circle-panel.js');
272
+ wp_localize_script('wpgmza-legacy-circle-panel', 'wpgmza_legacy', $localized_data);
273
+ }
274
+
275
+ if(!function_exists('wpgmza_get_circles_table'))
276
+ {
277
+ function wpgmza_get_circles_table($map_id)
278
+ {
279
+ global $wpdb;
280
+ global $wpgmza_tblname_circles;
281
+
282
+ $circles_table = "
283
+ <table>
284
+ <thead>
285
+ <tr>
286
+ <th>" . __('ID', 'wp-google-maps') . "</th>
287
+ <th>" . __('Name', 'wp-google-maps') . "</th>
288
+ <th>" . __('Action', 'wp-google-maps') . "</th>
289
+ </tr>
290
+ </thead>
291
+ <tbody>
292
+ ";
293
+
294
+ $stmt = $wpdb->prepare("SELECT * FROM $wpgmza_tblname_circles WHERE map_id = %d", array($map_id));
295
+ $circles = $wpdb->get_results($stmt);
296
+ foreach($circles as $circle)
297
+ {
298
+ $circles_table .= "
299
+ <tr>
300
+ <td>{$circle->id}</td>
301
+ <td>{$circle->name}</td>
302
+ <td width='170' align='left'>
303
+ <a href='" . get_option('siteurl') . "/wp-admin/admin.php?page=wp-google-maps-menu&amp;action=edit_circle&amp;map_id={$map_id}&amp;circle_id={$circle->id}'
304
+ title='" . __('Edit', 'wp-google-maps') . "'
305
+ class='wpgmza_edit_circle_btn button'
306
+ id='{$circle->id}'>
307
+ <i class='fa fa-edit'> </i>
308
+ </a>
309
+ <a href='javascript:void(0);'
310
+ title='" . __('Delete this circle', 'wp-google-maps') . "' class='wpgmza_circle_del_btn button' id='{$circle->id}'><i class='fa fa-times'> </i>
311
+ </a>
312
+ </td>
313
+ </tr>
314
+ ";
315
+ }
316
+
317
+ $circles_table .= "
318
+ </tbody>
319
+ </table>
320
+ ";
321
+
322
+ return $circles_table;
323
+ }
324
+ }
includes/legacy/functions.rectangle.php ADDED
@@ -0,0 +1,293 @@
1
+ <?php
2
+
3
+ if(!function_exists('wpgmza_get_rectangle_data'))
4
+ {
5
+ function wpgmza_get_rectangle_data($map_id)
6
+ {
7
+ global $wpgmza;
8
+ global $wpdb;
9
+ global $wpgmza_tblname_rectangles;
10
+
11
+ $stmt = $wpdb->prepare("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(cornerA) AS cornerA, {$wpgmza->spatialFunctionPrefix}AsText(cornerB) AS cornerB FROM $wpgmza_tblname_rectangles WHERE map_id=%d", array($map_id));
12
+ $results = $wpdb->get_results($stmt);
13
+
14
+ $rectangles = array();
15
+ foreach($results as $obj)
16
+ $rectangles[$obj->id] = $obj;
17
+
18
+ return $rectangles;
19
+ }
20
+ }
21
+
22
+ function wpgmza_b_add_rectangle($mid)
23
+ {
24
+ global $wpgmza_tblname_maps;
25
+ global $wpdb;
26
+
27
+ wpgmaps_b_admin_add_rectangle_javascript();
28
+
29
+ if ($_GET['action'] == "add_rectangle" && isset($mid)) {
30
+ $res = wpgmza_get_map_data($mid);
31
+ echo "
32
+
33
+
34
+
35
+
36
+ <div class='wrap'>
37
+ <h1>WP Google Maps</h1>
38
+ <div class='wide'>
39
+
40
+ <h2>".__("Add rectangle","wp-google-maps")."</h2>
41
+ <form action='?page=wp-google-maps-menu&action=edit&map_id=".$mid."' method='post' id='wpgmaps_add_rectangle_form'>
42
+ <input type='hidden' name='wpgmaps_map_id' id='wpgmaps_map_id' value='".$mid."' />
43
+ <input type='hidden' name='wpgmaps_rectangle-nonce' id='wpgmaps_b_nonce' value='".wp_create_nonce( 'wpgmaps_rectangle-nonce' )."' />
44
+ <input type='hidden' name='bounds'/>
45
+
46
+ <table class='wpgmza-listing-comp' style='width:30%;float:left;'>
47
+ <tr>
48
+ <td>
49
+ ".__("Name","wp-google-maps")."
50
+ </td>
51
+ <td>
52
+ <input id=\"rectangle\" name=\"rectangle_name\" type=\"text\" value=\"\" />
53
+ </td>
54
+ </tr>
55
+ <tr>
56
+ <td>
57
+ ".__("Color","wp-google-maps")."
58
+ </td>
59
+ <td>
60
+ <input id=\"rectangle_color\" name=\"rectangle_color\" type=\"color\" value=\"#ff0000\" />
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>
65
+ ".__("Opacity","wp-google-maps")."
66
+ </td>
67
+ <td>
68
+ <input id=\"rectangle_opacity\" name=\"rectangle_opacity\" type=\"text\" value=\"0.6\" /> <small class='wpgmza-info__small'>(0 - 1.0) example: 0.6 for 60%</small>
69
+ </td>
70
+ </tr>
71
+
72
+ </table>
73
+ <div class='wpgmza_map_seventy'>
74
+ <div id=\"wpgmza_map\">&nbsp;</div>
75
+ <p>
76
+ <ul style=\"list-style:initial; margin-top: -145px !important;\" class='update-nag update-blue update-slim update-map-overlay'>
77
+ <li style=\"margin-left:30px;\">" . __('Click on the map to insert a rectangle.', 'wp-google-maps') . "</li>
78
+ <li style=\"margin-left:30px;\">" . __('Click or drag the rectangle to move it.', 'wp-google-maps') . "</li>
79
+ </ul>
80
+ </p>
81
+ </div>
82
+
83
+ <p class='submit'><a href='javascript:history.back();' class='button button-secondary' title='".__("Cancel")."'>".__("Cancel")."</a> <input type='submit' name='wpgmza_save_rectangle' class='button-primary' value='".__("Save rectangle","wp-google-maps")." &raquo;' /></p>
84
+
85
+ </form>
86
+ </div>
87
+
88
+
89
+ </div>
90
+
91
+
92
+
93
+ ";
94
+
95
+ }
96
+ }
97
+
98
+ function wpgmza_b_edit_rectangle($mid)
99
+ {
100
+ global $wpgmza;
101
+ global $wpgmza_tblname_maps;
102
+ global $wpgmza_tblname_rectangles;
103
+ global $wpdb;
104
+
105
+ wpgmaps_b_admin_add_rectangle_javascript();
106
+
107
+ if ($_GET['action'] == "edit_rectangle" && isset($mid)) {
108
+ $res = wpgmza_get_map_data($mid);
109
+ $rectangle_id = (int)$_GET['rectangle_id'];
110
+
111
+ $results = $wpdb->get_results("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(cornerA) AS cornerA, {$wpgmza->spatialFunctionPrefix}AsText(cornerB) AS cornerB FROM $wpgmza_tblname_rectangles WHERE id = $rectangle_id");
112
+
113
+ if(empty($results))
114
+ {
115
+ echo "<p class='notice notice-error'>" . __('Invalid rectangle ID', 'wp-google-maps') . "</p>";
116
+ return;
117
+ }
118
+
119
+ $rectangle = $results[0];
120
+
121
+ $name = addcslashes($rectangle->name, '"');
122
+ preg_match_all('/-?\d+(\.\d+)?/', $rectangle->cornerA . $rectangle->cornerB, $m);
123
+
124
+ $north = $m[0][0];
125
+ $west = $m[0][1];
126
+ $south = $m[0][2];
127
+ $east = $m[0][3];
128
+
129
+ echo "
130
+ <div class='wrap'>
131
+ <h1>WP Google Maps</h1>
132
+ <div class='wide'>
133
+
134
+ <h2>".__("Edit rectangle","wp-google-maps")."</h2>
135
+ <form action='?page=wp-google-maps-menu&action=edit&map_id=".$mid."' method='post' id='wpgmaps_add_rectangle_form'>
136
+ <input type='hidden' name='wpgmaps_map_id' id='wpgmaps_map_id' value='".$mid."' />
137
+ <input type='hidden' name='rectangle_id' value='{$rectangle_id}'/>
138
+ <input type='hidden' name='wpgmaps_rectangle-nonce' id='wpgmaps_b_nonce' value='".wp_create_nonce( 'wpgmaps_rectangle-nonce' )."' />
139
+ <input type='hidden' name='bounds' value='$north $west $south $east'/>
140
+
141
+ <table class='wpgmza-listing-comp' style='width:30%;float:left;'>
142
+ <tr>
143
+ <td>
144
+ " . __("Name","wp-google-maps") . "
145
+ </td>
146
+ <td>
147
+ <input id=\"rectangle\" name=\"rectangle_name\" type=\"text\" value=\"$name\" />
148
+ </td>
149
+ </tr>
150
+ <tr>
151
+ <td>
152
+ ".__("Color","wp-google-maps")."
153
+ </td>
154
+ <td>
155
+ <input id=\"rectangle_color\" name=\"rectangle_color\" type=\"color\" value=\"{$rectangle->color}\" />
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td>
160
+ ".__("Opacity","wp-google-maps")."
161
+ </td>
162
+ <td>
163
+ <input id=\"rectangle_opacity\" name=\"rectangle_opacity\" type=\"text\" value=\"{$rectangle->opacity}\" type='number' step='any' /> <small class='wpgmza-info__small'>(0 - 1.0) example: 0.6 for 60%</small>
164
+ </td>
165
+ </tr>
166
+ <tr>
167
+ <td>
168
+ ".__('Show Rectangle', 'wp-google-maps')."
169
+ </td>
170
+ <td>
171
+ <button id='fit-bounds-to-shape'
172
+ class='button button-secondary'
173
+ type='button'
174
+ title='" . __('Fit map bounds to shape', 'wp-google-maps') . "'
175
+ data-fit-bounds-to-shape='rectangle'>
176
+ <i class='fas fa-eye'></i>
177
+ </button>
178
+ </td>
179
+ </tr>
180
+ </table>
181
+ <div class='wpgmza_map_seventy'>
182
+ <div id=\"wpgmza_map\">&nbsp;</div>
183
+ <p>
184
+ <ul style=\"list-style:initial; margin-top: -145px !important;\" class='update-nag update-blue update-slim update-map-overlay'>
185
+ <li style=\"margin-left:30px;\">" . __('Click or drag the rectangle to move it.', 'wp-google-maps') . "</li>
186
+ </ul>
187
+ </p>
188
+ </div>
189
+
190
+ <p class='submit'><a href='javascript:history.back();' class='button button-secondary' title='".__("Cancel")."'>".__("Cancel")."</a> <input type='submit' name='wpgmza_save_rectangle' class='button-primary' value='".__("Save rectangle","wp-google-maps")." &raquo;' /></p>
191
+
192
+ </form>
193
+ </div>
194
+
195
+
196
+ </div>
197
+
198
+
199
+
200
+ ";
201
+
202
+ }
203
+ }
204
+
205
+ function wpgmaps_b_admin_add_rectangle_javascript()
206
+ {
207
+ $res = wpgmza_get_map_data(sanitize_text_field($_GET['map_id']));
208
+ $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
209
+
210
+
211
+ $wpgmza_lat = $res->map_start_lat;
212
+ $wpgmza_lng = $res->map_start_lng;
213
+ $wpgmza_map_type = $res->type;
214
+ $wpgmza_width = $res->map_width;
215
+ $wpgmza_height = $res->map_height;
216
+ $wpgmza_width_type = $res->map_width_type;
217
+ $wpgmza_height_type = $res->map_height_type;
218
+ if (!$wpgmza_map_type || $wpgmza_map_type == "" || $wpgmza_map_type == "1") { $wpgmza_map_type = "ROADMAP"; }
219
+ else if ($wpgmza_map_type == "2") { $wpgmza_map_type = "SATELLITE"; }
220
+ else if ($wpgmza_map_type == "3") { $wpgmza_map_type = "HYBRID"; }
221
+ else if ($wpgmza_map_type == "4") { $wpgmza_map_type = "TERRAIN"; }
222
+ else { $wpgmza_map_type = "ROADMAP"; }
223
+ $start_zoom = $res->map_start_zoom;
224
+ if ($start_zoom < 1 || !$start_zoom) {
225
+ $start_zoom = 5;
226
+ }
227
+
228
+ $localized_data = array(
229
+ 'wpgmza_lat' => $wpgmza_lat,
230
+ 'wpgmza_lng' => $wpgmza_lng,
231
+ 'start_zoom' => $start_zoom,
232
+ 'wpgmza_width' => $wpgmza_width,
233
+ 'wpgmza_width_type' => $wpgmza_width_type,
234
+ 'wpgmza_height' => $wpgmza_height,
235
+ 'wpgmza_height_type' => $wpgmza_height_type,
236
+ 'wpgmza_map_type' => $wpgmza_map_type
237
+ );
238
+
239
+ wp_enqueue_style('wpgooglemaps-css', wpgmaps_get_plugin_url() . 'css/wpgmza_style.css');
240
+ wp_enqueue_script('wpgmza-legacy-rectangle-panel', plugin_dir_url(__FILE__) . 'js/legacy/legacy-rectangle-panel.js');
241
+ wp_localize_script('wpgmza-legacy-rectangle-panel', 'wpgmza_legacy', $localized_data);
242
+ }
243
+
244
+ if(!function_exists('wpgmza_get_rectangles_table'))
245
+ {
246
+ function wpgmza_get_rectangles_table($map_id)
247
+ {
248
+ global $wpdb;
249
+ global $wpgmza_tblname_rectangles;
250
+
251
+ $rectangles_table = "
252
+ <table>
253
+ <thead>
254
+ <tr>
255
+ <th>" . __('ID', 'wp-google-maps') . "</th>
256
+ <th>" . __('Name', 'wp-google-maps') . "</th>
257
+ <th>" . __('Action', 'wp-google-maps') . "</th>
258
+ </tr>
259
+ </thead>
260
+ <tbody>
261
+ ";
262
+
263
+ $stmt = $wpdb->prepare("SELECT * FROM $wpgmza_tblname_rectangles WHERE map_id = %d", array($map_id));
264
+ $rectangles = $wpdb->get_results($stmt);
265
+ foreach($rectangles as $rectangle)
266
+ {
267
+ $rectangles_table .= "
268
+ <tr>
269
+ <td>{$rectangle->id}</td>
270
+ <td>{$rectangle->name}</td>
271
+ <td width='170' align='left'>
272
+ <a href='" . get_option('siteurl') . "/wp-admin/admin.php?page=wp-google-maps-menu&amp;action=edit_rectangle&amp;map_id={$map_id}&amp;rectangle_id={$rectangle->id}'
273
+ title='" . __('Edit', 'wp-google-maps') . "'
274
+ class='wpgmza_edit_rectangle_btn button'
275
+ id='{$rectangle->id}'>
276
+ <i class='fa fa-edit'> </i>
277
+ </a>
278
+ <a href='javascript:void(0);'
279
+ title='" . __('Delete this rectangle', 'wp-google-maps') . "' class='wpgmza_rectangle_del_btn button' id='{$rectangle->id}'><i class='fa fa-times'> </i>
280
+ </a>
281
+ </td>
282
+ </tr>
283
+ ";
284
+ }
285
+
286
+ $rectangles_table .= "
287
+ </tbody>
288
+ </table>
289
+ ";
290
+
291
+ return $rectangles_table;
292
+ }
293
+ }
includes/legacy/settings-page.php CHANGED
@@ -47,27 +47,27 @@ function wpgmza_legacy_settings_page_basic()
47
else if ($wpgmza_settings_marker_pull == '1' || $wpgmza_settings_marker_pull == 1) { $wpgmza_settings_marker_pull_checked[1] = "checked='checked'"; $show_advanced_marker_tr = 'style="visibility:visible; display:table-row;"'; }
48
else { $wpgmza_settings_marker_pull_checked[0] = "checked='checked'"; $show_advanced_marker_tr = 'style="visibility:hidden; display:none;"'; }
49
50
- $wpgmza_settings_user_interface_style_checked[0] = '';
51
- $wpgmza_settings_user_interface_style_checked[1] = '';
52
- $wpgmza_settings_user_interface_style_checked[2] = '';
53
- $wpgmza_settings_user_interface_style_checked[3] = '';
54
- $wpgmza_settings_user_interface_style_checked[4] = '';
55
- $wpgmza_settings_user_interface_style_checked[5] = '';
56
- if (isset($wpgmza_settings['wpgmza_settings_user_interface_style'])) { $wpgmza_settings_user_interface_style = $wpgmza_settings['wpgmza_settings_user_interface_style']; } else {$wpgmza_settings_user_interface_style = false; }
57
- if ($wpgmza_settings_user_interface_style == 'bare-bones') { $wpgmza_settings_user_interface_style_checked[0] = "checked='checked'";
58
$wpgmza->settings->user_interface_style = 'bare-bones'; }
59
- else if ($wpgmza_settings_user_interface_style == 'default') { $wpgmza_settings_user_interface_style_checked[1] = "checked='checked'";
60
$wpgmza->settings->user_interface_style = 'default'; }
61
- else if ($wpgmza_settings_user_interface_style == 'legacy') { $wpgmza_settings_user_interface_style_checked[2] = "checked='checked'";
62
$wpgmza->settings->user_interface_style = 'legacy';}
63
64
- else if ($wpgmza_settings_user_interface_style == 'compact') { $wpgmza_settings_user_interface_style_checked[3] = "checked='checked'";
65
$wpgmza->settings->user_interface_style = 'compact'; }
66
- else if ($wpgmza_settings_user_interface_style == 'modern') { $wpgmza_settings_user_interface_style_checked[4] = "checked='checked'";
67
$wpgmza->settings->user_interface_style = 'modern'; }
68
- else if ($wpgmza_settings_user_interface_style == 'minimal') { $wpgmza_settings_user_interface_style_checked[5] = "checked='checked'";
69
$wpgmza->settings->user_interface_style = 'minimal'; }
70
- else { $wpgmza_settings_user_interface_style_checked[2] = "checked='checked'"; }
71
72
73
@@ -273,55 +273,55 @@ function wpgmza_legacy_settings_page_basic()
273
274
<td>
275
<input type='radio'
276
- name='wpgmza_settings_user_interface_style'
277
- id='wpgmza_settings_user_interface_style_bare_bones'
278
value='bare-bones' "
279
- . $wpgmza_settings_user_interface_style_checked[0] .
280
" />" . __("Bare Bones - Applies no styling to the components at all. This is recommended for designers and developers who want to style the components from scratch.", "wp-google-maps") . "
281
282
<br />
283
284
<input type='radio'
285
- name='wpgmza_settings_user_interface_style'
286
- id='wpgmza_settings_user_interface_style_default'
287
value='default' "
288
- . $wpgmza_settings_user_interface_style_checked[1] .
289
" />" . __("Default - The default front end.", "wp-google-maps") . "
290
291
<br />
292
293
<input type='radio'
294
- name='wpgmza_settings_user_interface_style'
295
- id='wpgmza_settings_user_interface_style_legacy'
296
value='legacy' "
297
- . $wpgmza_settings_user_interface_style_checked[2] .
298
" />" . __("Legacy - This setting is the same as Default, but provides options to change individual components to the modern style.", "wp-google-maps") . "
299
300
<br />
301
302
<input type='radio'
303
- name='wpgmza_settings_user_interface_style'
304
- id='wpgmza_settings_user_interface_style_compact'
305
value='compact' "
306
- . $wpgmza_settings_user_interface_style_checked[3] .
307
" />" . __("Compact - Puts all components and their labels inline.", "wp-google-maps") . "
308
309
<br />
310
311
<input type='radio'
312
- name='wpgmza_settings_user_interface_style'
313
- id='wpgmza_settings_user_interface_style_modern'
314
value='modern' "
315
- . $wpgmza_settings_user_interface_style_checked[4] .
316
" />" . __("Modern - Puts components inside the map, with pull-out panels.", "wp-google-maps") . "
317
318
<br />
319
320
<input type='radio'
321
- name='wpgmza_settings_user_interface_style'
322
- id='wpgmza_settings_user_interface_style_minimal'
323
value='minimal' "
324
- . $wpgmza_settings_user_interface_style_checked[5] .
325
" />" . __("Minimal - The same as Compact, but with icons instead of text labels.", "wp-google-maps") . "
326
327
<br />
47
else if ($wpgmza_settings_marker_pull == '1' || $wpgmza_settings_marker_pull == 1) { $wpgmza_settings_marker_pull_checked[1] = "checked='checked'"; $show_advanced_marker_tr = 'style="visibility:visible; display:table-row;"'; }
48
else { $wpgmza_settings_marker_pull_checked[0] = "checked='checked'"; $show_advanced_marker_tr = 'style="visibility:hidden; display:none;"'; }
49
50
+ $user_interface_style_checked[0] = '';
51
+ $user_interface_style_checked[1] = '';
52
+ $user_interface_style_checked[2] = '';
53
+ $user_interface_style_checked[3] = '';
54
+ $user_interface_style_checked[4] = '';
55
+ $user_interface_style_checked[5] = '';
56
+ if (isset($wpgmza_settings['user_interface_style'])) { $user_interface_style = $wpgmza_settings['user_interface_style']; } else {$user_interface_style = false; }
57
+ if ($user_interface_style == 'bare-bones') { $user_interface_style_checked[0] = "checked='checked'";
58
$wpgmza->settings->user_interface_style = 'bare-bones'; }
59
+ else if ($user_interface_style == 'default') { $user_interface_style_checked[1] = "checked='checked'";
60
$wpgmza->settings->user_interface_style = 'default'; }
61
+ else if ($user_interface_style == 'legacy') { $user_interface_style_checked[2] = "checked='checked'";
62
$wpgmza->settings->user_interface_style = 'legacy';}
63
64
+ else if ($user_interface_style == 'compact') { $user_interface_style_checked[3] = "checked='checked'";
65
$wpgmza->settings->user_interface_style = 'compact'; }
66
+ else if ($user_interface_style == 'modern') { $user_interface_style_checked[4] = "checked='checked'";
67
$wpgmza->settings->user_interface_style = 'modern'; }
68
+ else if ($user_interface_style == 'minimal') { $user_interface_style_checked[5] = "checked='checked'";
69
$wpgmza->settings->user_interface_style = 'minimal'; }
70
+ else { $user_interface_style_checked[2] = "checked='checked'"; }
71
72
73
273
274
<td>
275
<input type='radio'
276
+ name='user_interface_style'
277
+ id='user_interface_style_bare_bones'
278
value='bare-bones' "
279
+ . $user_interface_style_checked[0] .
280
" />" . __("Bare Bones - Applies no styling to the components at all. This is recommended for designers and developers who want to style the components from scratch.", "wp-google-maps") . "
281
282
<br />
283
284
<input type='radio'
285
+ name='user_interface_style'
286
+ id='user_interface_style_default'
287
value='default' "
288
+ . $user_interface_style_checked[1] .
289
" />" . __("Default - The default front end.", "wp-google-maps") . "
290
291
<br />
292
293
<input type='radio'
294
+ name='user_interface_style'
295
+ id='user_interface_style_legacy'
296
value='legacy' "
297
+ . $user_interface_style_checked[2] .
298
" />" . __("Legacy - This setting is the same as Default, but provides options to change individual components to the modern style.", "wp-google-maps") . "
299
300
<br />
301
302
<input type='radio'
303
+ name='user_interface_style'
304
+ id='user_interface_style_compact'
305
value='compact' "
306
+ . $user_interface_style_checked[3] .
307
" />" . __("Compact - Puts all components and their labels inline.", "wp-google-maps") . "
308
309
<br />
310
311
<input type='radio'
312
+ name='user_interface_style'
313
+ id='user_interface_style_modern'
314
value='modern' "
315
+ . $user_interface_style_checked[4] .
316
" />" . __("Modern - Puts components inside the map, with pull-out panels.", "wp-google-maps") . "
317
318
<br />
319
320
<input type='radio'
321
+ name='user_interface_style'
322
+ id='user_interface_style_minimal'
323
value='minimal' "
324
+ . $user_interface_style_checked[5] .
325
" />" . __("Minimal - The same as Compact, but with icons instead of text labels.", "wp-google-maps") . "
326
327
<br />
includes/open-layers/class.ol-loader.php CHANGED
@@ -39,11 +39,6 @@ class OLLoader
39
wp_enqueue_style('wpgmza-ol-base-style', plugin_dir_url(dirname(__DIR__)) . 'lib/ol.css');
40
wp_enqueue_style('wpgmza-ol-style', plugin_dir_url(dirname(__DIR__)) . 'css/open-layers.css');
41
42
- // TODO: Fix this, don't use this handle, use wpgmza_api_call. For some reason it won't enqueue using that. I suspect something else is using this handle. Whatever it is isn't in wpGoogleMaps.php
43
- // NB: Removed ol-debug.js to save 2.6MB space
44
- //if($wpgmza->isInDeveloperMode() || defined('SCRIPT_DEBUG'))
45
- //wp_enqueue_script('wpgmza_ol_api_call', plugin_dir_url(dirname(__DIR__)) . 'lib/ol-debug.js');
46
- //else
47
wp_enqueue_script('wpgmza_ol_api_call', plugin_dir_url(dirname(__DIR__)) . 'lib/ol.js');
48
}
49
}
39
wp_enqueue_style('wpgmza-ol-base-style', plugin_dir_url(dirname(__DIR__)) . 'lib/ol.css');
40
wp_enqueue_style('wpgmza-ol-style', plugin_dir_url(dirname(__DIR__)) . 'css/open-layers.css');
41
42
wp_enqueue_script('wpgmza_ol_api_call', plugin_dir_url(dirname(__DIR__)) . 'lib/ol.js');
43
}
44
}
js/v8/core.js CHANGED
@@ -697,6 +697,13 @@ jQuery(function($) {
697
698
};
699
700
if(window.WPGMZA)
701
window.WPGMZA = $.extend(window.WPGMZA, core);
702
else
697
698
};
699
700
+ // NB: Warn the user if the built in Array prototype has been extended. This will save debugging headaches where for ... in loops do bizarre things.
701
+ for(var key in [])
702
+ {
703
+ console.warn("It appears that the built in JavaScript Array has been extended, this can create issues with for ... in loops, which may cause failure.");
704
+ break;
705
+ }
706
+
707
if(window.WPGMZA)
708
window.WPGMZA = $.extend(window.WPGMZA, core);
709
else
js/v8/distance.js CHANGED
@@ -120,11 +120,11 @@ jQuery(function($) {
120
*/
121
between: function(a, b)
122
{
123
- if(!(a instanceof WPGMZA.LatLng))
124
- throw new Error("First argument must be an instance of WPGMZA.LatLng");
125
126
- if(!(b instanceof WPGMZA.LatLng))
127
- throw new Error("Second argument must be an instance of WPGMZA.LatLng");
128
129
if(a === b)
130
return 0.0;
@@ -134,8 +134,8 @@ jQuery(function($) {
134
var lat2 = b.lat;
135
var lon2 = b.lng;
136
137
- var dLat = deg2rad(lat2-lat1);
138
- var dLon = deg2rad(lon2-lon1);
139
140
var a =
141
Math.sin(dLat/2) * Math.sin(dLat/2) +
120
*/
121
between: function(a, b)
122
{
123
+ if(!(a instanceof WPGMZA.LatLng) && !("lat" in a && "lng" in a))
124
+ throw new Error("First argument must be an instance of WPGMZA.LatLng or a literal");
125
126
+ if(!(b instanceof WPGMZA.LatLng) && !("lat" in b && "lng" in b))
127
+ throw new Error("Second argument must be an instance of WPGMZA.LatLng or a literal");
128
129
if(a === b)
130
return 0.0;
134
var lat2 = b.lat;
135
var lon2 = b.lng;
136
137
+ var dLat = deg2rad(lat2 - lat1);
138
+ var dLon = deg2rad(lon2 - lon1);
139
140
var a =
141
Math.sin(dLat/2) * Math.sin(dLat/2) +
js/v8/google-maps/google-map.js CHANGED
@@ -616,9 +616,7 @@ jQuery(function($) {
616
var options = {};
617
618
options.scrollwheel = true;
619
-
620
options.draggable = true;
621
-
622
options.disableDoubleClickZoom = false;
623
624
this.googleMap.setOptions(options);
616
var options = {};
617
618
options.scrollwheel = true;
619
options.draggable = true;
620
options.disableDoubleClickZoom = false;
621
622
this.googleMap.setOptions(options);
js/v8/map-edit-page.js CHANGED
@@ -39,12 +39,6 @@ jQuery(function($) {
39
});
40
}
41
42
- $(document).on("click", ".wpgmza_edit_btn", function() {
43
- var cur_id = jQuery(this).attr("data-edit-marker-id");
44
-
45
- WPGMZA.AdminMarkerDataTable.prototype.onCenterMarker(cur_id);
46
- });
47
-
48
$('#wpgmza_max_zoom, #wpgmza_min_zoom').on("change input", function(event) {
49
self.onZoomLimitChanged(event);
50
});
@@ -58,7 +52,7 @@ jQuery(function($) {
58
return new WPGMZA.MapEditPage();
59
}
60
61
- WPGMZA.MapEditPage.prototype.onZoomLimitChanged = function()
62
{
63
this.map.setOptions({
64
minZoom: $("#wpgmza_max_zoom").val(),
39
});
40
}
41
42
$('#wpgmza_max_zoom, #wpgmza_min_zoom').on("change input", function(event) {
43
self.onZoomLimitChanged(event);
44
});
52
return new WPGMZA.MapEditPage();
53
}
54
55
+ WPGMZA.MapEditPage.prototype.onZoomLimitChanged = function(event)
56
{
57
this.map.setOptions({
58
minZoom: $("#wpgmza_max_zoom").val(),
js/v8/map.js CHANGED
@@ -107,6 +107,14 @@ jQuery(function($) {
107
return new constructor(element, options);
108
}
109
110
Object.defineProperty(WPGMZA.Map.prototype, "lat", {
111
112
get: function() {
@@ -121,6 +129,14 @@ jQuery(function($) {
121
122
});
123
124
Object.defineProperty(WPGMZA.Map.prototype, "lng", {
125
126
get: function() {
@@ -135,6 +151,14 @@ jQuery(function($) {
135
136
});
137
138
Object.defineProperty(WPGMZA.Map.prototype, "zoom", {
139
140
get: function() {
107
return new constructor(element, options);
108
}
109
110
+ /**
111
+ * The maps current latitude
112
+ *
113
+ * @property lat
114
+ * @memberof WPGMZA.Map
115
+ * @name WPGMZA.Map#lat
116
+ * @type Number
117
+ */
118
Object.defineProperty(WPGMZA.Map.prototype, "lat", {
119
120
get: function() {
129
130
});
131
132
+ /**
133
+ * The maps current longitude
134
+ *
135
+ * @property lng
136
+ * @memberof WPGMZA.Map
137
+ * @name WPGMZA.Map#lng
138
+ * @type Number
139
+ */
140
Object.defineProperty(WPGMZA.Map.prototype, "lng", {
141
142
get: function() {
151
152
});
153
154
+ /**
155
+ * The maps current zoom level
156
+ *
157
+ * @property zoom
158
+ * @memberof WPGMZA.Map
159
+ * @name WPGMZA.Map#zoom
160
+ * @type Number
161
+ */
162
Object.defineProperty(WPGMZA.Map.prototype, "zoom", {
163
164
get: function() {
js/v8/marker.js CHANGED
@@ -131,8 +131,9 @@ jQuery(function($) {
131
/**
132
* Called when the marker has been added to a map
133
* @method
134
- * @method
135
* @memberof WPGMZA.Marker
136
*/
137
WPGMZA.Marker.prototype.onAdded = function(event)
138
{
@@ -224,6 +225,7 @@ jQuery(function($) {
224
* Called when the marker has been clicked
225
* @method
226
* @memberof WPGMZA.Marker
227
*/
228
WPGMZA.Marker.prototype.onClick = function(event)
229
{
@@ -234,6 +236,7 @@ jQuery(function($) {
234
* Called when the marker has been selected, either by the icon being clicked, or from a marker listing
235
* @method
236
* @memberof WPGMZA.Marker
237
*/
238
WPGMZA.Marker.prototype.onSelect = function(event)
239
{
@@ -244,6 +247,7 @@ jQuery(function($) {
244
* Called when the user hovers the mouse over this marker
245
* @method
246
* @memberof WPGMZA.Marker
247
*/
248
WPGMZA.Marker.prototype.onMouseOver = function(event)
249
{
131
/**
132
* Called when the marker has been added to a map
133
* @method
134
* @memberof WPGMZA.Marker
135
+ * @listens module:WPGMZA.Marker~added
136
+ * @fires module:WPGMZA.Marker~select When this marker is targeted by the marker shortcode attribute
137
*/
138
WPGMZA.Marker.prototype.onAdded = function(event)
139
{
225
* Called when the marker has been clicked
226
* @method
227
* @memberof WPGMZA.Marker
228
+ * @listens module:WPGMZA.Marker~click
229
*/
230
WPGMZA.Marker.prototype.onClick = function(event)
231
{
236
* Called when the marker has been selected, either by the icon being clicked, or from a marker listing
237
* @method
238
* @memberof WPGMZA.Marker
239
+ * @listens module:WPGMZA.Marker~select
240
*/
241
WPGMZA.Marker.prototype.onSelect = function(event)
242
{
247
* Called when the user hovers the mouse over this marker
248
* @method
249
* @memberof WPGMZA.Marker
250
+ * @listens module:WPGMZA.Marker~mouseover
251
*/
252
WPGMZA.Marker.prototype.onMouseOver = function(event)
253
{
js/v8/open-layers/ol-map.js CHANGED
@@ -240,7 +240,11 @@ jQuery(function($) {
240
241
WPGMZA.OLMap.prototype.wrapLongitude = function()
242
{
243
- var center = this.getCenter();
244
245
if(center.lng >= -180 && center.lng <= 180)
246
return;
240
241
WPGMZA.OLMap.prototype.wrapLongitude = function()
242
{
243
+ var transformed = ol.proj.transform(this.olMap.getView().getCenter(), "EPSG:3857", "EPSG:4326");
244
+ var center = {
245
+ lat: transformed[1],
246
+ lng: transformed[0]
247
+ };
248
249
if(center.lng >= -180 && center.lng <= 180)
250
return;
js/v8/wp-google-maps.combined.js CHANGED
@@ -699,6 +699,13 @@ jQuery(function($) {
699
700
};
701
702
if(window.WPGMZA)
703
window.WPGMZA = $.extend(window.WPGMZA, core);
704
else
@@ -1081,11 +1088,11 @@ jQuery(function($) {
1081
*/
1082
between: function(a, b)
1083
{
1084
- if(!(a instanceof WPGMZA.LatLng))
1085
- throw new Error("First argument must be an instance of WPGMZA.LatLng");
1086
1087
- if(!(b instanceof WPGMZA.LatLng))
1088
- throw new Error("Second argument must be an instance of WPGMZA.LatLng");
1089
1090
if(a === b)
1091
return 0.0;
@@ -1095,8 +1102,8 @@ jQuery(function($) {
1095
var lat2 = b.lat;
1096
var lon2 = b.lng;
1097
1098
- var dLat = deg2rad(lat2-lat1);
1099
- var dLon = deg2rad(lon2-lon1);
1100
1101
var a =
1102
Math.sin(dLat/2) * Math.sin(dLat/2) +
@@ -2776,12 +2783,6 @@ jQuery(function($) {
2776
});
2777
}
2778
2779
- $(document).on("click", ".wpgmza_edit_btn", function() {
2780
- var cur_id = jQuery(this).attr("data-edit-marker-id");
2781
-
2782
- WPGMZA.AdminMarkerDataTable.prototype.onCenterMarker(cur_id);
2783
- });
2784
-
2785
$('#wpgmza_max_zoom, #wpgmza_min_zoom').on("change input", function(event) {
2786
self.onZoomLimitChanged(event);
2787
});
@@ -2795,7 +2796,7 @@ jQuery(function($) {
2795
return new WPGMZA.MapEditPage();
2796
}
2797
2798
- WPGMZA.MapEditPage.prototype.onZoomLimitChanged = function()
2799
{
2800
this.map.setOptions({
2801
minZoom: $("#wpgmza_max_zoom").val(),
@@ -3521,6 +3522,14 @@ jQuery(function($) {
3521
return new constructor(element, options);
3522
}
3523
3524
Object.defineProperty(WPGMZA.Map.prototype, "lat", {
3525
3526
get: function() {
@@ -3535,6 +3544,14 @@ jQuery(function($) {
3535
3536
});
3537
3538
Object.defineProperty(WPGMZA.Map.prototype, "lng", {
3539