Simple Google Map - Version 3.2.2

Version Description

  • Add custom map marker image with icon attribute
  • Add default custom map marker image via plugin settings page
  • Remove direction to address from info window.
Download this release

Release Info

Developer gwelser
Plugin Icon wp plugin Simple Google Map
Version 3.2.2
Comparing to
See all releases

Code changes from version 3.2.1 to 3.2.2

README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://clarknikdelpowell.com/pay
4
  Tags: google, google map, google maps, simple google map, no api key
5
  Requires at least: 3.2
6
  Tested up to: 4.5.3
7
- Stable tag: 3.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -21,13 +21,15 @@ With this plugin you can insert a google map into your posts, pages, or wigitize
21
  * Set default options = less necessary shortcode and widget options.
22
  * Modify the default CSS or turn it off completely and style the map yourself.
23
  * Add a form for getting directions by simply adding your destination address.
 
24
  * It's simple!
25
 
26
  **ADDITIONAL NOTES**
27
 
28
  * There can only be one map one a page. A widget map counts as one.
29
  * The size of the info window (speech bubble) is dictated by the size of the map, thus the size of the containing div, div#SGM
30
- * If you wish to use html in the content value in shortcode, be sure and type it in visual mode (not HTML mode). the pointy brackets will be special html characters in HTML mode and are converted back into pointy brackets by the plugin.
 
31
 
32
  For an example and more visit [the plugin's homepage](http://clarknikdelpowell.com/wordpress/simple-google-map/ "Simple Google Map by Clark Nikdel Powell").
33
 
@@ -39,15 +41,21 @@ For an example and more visit [the plugin's homepage](http://clarknikdelpowell.c
39
 
40
  The shortcode name is SGM and here are the options..
41
 
42
- * lat [int] – the latitude of the marker and the center of the map.
43
- * lng [int] – the longitude of the marker and the center of the map.
44
  * zoom [int] – the zoom level (1-19).
45
- * type [int] – the starting map type. possible values are only ROADMAP, SATELLITE, HYBRID, or TERRAIN and must be in uppercase
46
  * directionsto [string] – the destination address for getting directions. obviously you want this to be the address of your latitude longitude coordinates.
47
- * content – what goes inside the infoWindow (speech bubble) that appears when the marker is clicked.
 
48
 
49
  == Changelog ==
50
 
 
 
 
 
 
51
  = 3.2.1 =
52
  * Revert arrays to long syntax for compatibility with PHP 5.3.
53
  * Move strip_last_chars function to base class.
4
  Tags: google, google map, google maps, simple google map, no api key
5
  Requires at least: 3.2
6
  Tested up to: 4.5.3
7
+ Stable tag: 3.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
21
  * Set default options = less necessary shortcode and widget options.
22
  * Modify the default CSS or turn it off completely and style the map yourself.
23
  * Add a form for getting directions by simply adding your destination address.
24
+ * Add a custom map marker image.
25
  * It's simple!
26
 
27
  **ADDITIONAL NOTES**
28
 
29
  * There can only be one map one a page. A widget map counts as one.
30
  * The size of the info window (speech bubble) is dictated by the size of the map, thus the size of the containing div, div#SGM
31
+ * If you wish to use html in the content value in shortcode, be sure and type it in visual mode (not HTML mode). The pointy brackets will be special html characters in HTML mode and are converted back into pointy brackets by the plugin.
32
+ * Custom map marker image must be properly sized. Simple Google Map will *not* resize the image for you.
33
 
34
  For an example and more visit [the plugin's homepage](http://clarknikdelpowell.com/wordpress/simple-google-map/ "Simple Google Map by Clark Nikdel Powell").
35
 
41
 
42
  The shortcode name is SGM and here are the options..
43
 
44
+ * lat [decimal] – the latitude of the marker and the center of the map.
45
+ * lng [decimal] – the longitude of the marker and the center of the map.
46
  * zoom [int] – the zoom level (1-19).
47
+ * type [string] – the starting map type. possible values are only ROADMAP, SATELLITE, HYBRID, or TERRAIN and must be in uppercase
48
  * directionsto [string] – the destination address for getting directions. obviously you want this to be the address of your latitude longitude coordinates.
49
+ * content [string] – what goes inside the infoWindow (speech bubble) that appears when the marker is clicked.
50
+ * icon [string] - url of an image to use a the map marker. must be a properly formatted URL with scheme. note the image must be properly sized.
51
 
52
  == Changelog ==
53
 
54
+ = 3.2.2 =
55
+ * Add custom map marker image with `icon` attribute
56
+ * Add default custom map marker image via plugin settings page
57
+ * Remove direction to address from info window.
58
+
59
  = 3.2.1 =
60
  * Revert arrays to long syntax for compatibility with PHP 5.3.
61
  * Move strip_last_chars function to base class.
admin/class-simple-google-map-admin.php CHANGED
@@ -61,12 +61,7 @@ class Simple_Google_Map_Admin {
61
 
62
  $this->plugin_name = $plugin_name;
63
  $this->version = $version;
64
- $this->default_options = array(
65
- 'zoom' => '12',
66
- 'type' => 'ROADMAP',
67
- 'directionsto' => '',
68
- 'content' => '',
69
- );
70
 
71
  }
72
 
@@ -113,6 +108,7 @@ class Simple_Google_Map_Admin {
113
 
114
  $new_options['zoom'] = is_numeric( $_POST['zoom'] ) ? sanitize_text_field( $_POST['zoom'] ) : '';
115
  $new_options['type'] = strtoupper( sanitize_text_field( $_POST['type'] ) );
 
116
  $new_options['content'] = $_POST['content'];
117
  if ( isset( $_POST['editCSS'] ) ) {
118
  $new_options['editCSS'] = $_POST['editCSS'];
@@ -131,6 +127,8 @@ class Simple_Google_Map_Admin {
131
  $message = '<div id="message" class="updated"><p>Simple Google Map settings updated.</p></div>';
132
  } else {
133
  $sgm_options = get_option( 'SGMoptions' );
 
 
134
  $sgm_css = get_option( 'SGMcss' );
135
  }
136
 
61
 
62
  $this->plugin_name = $plugin_name;
63
  $this->version = $version;
64
+ $this->default_options = Simple_Google_Map::$default_options;
 
 
 
 
 
65
 
66
  }
67
 
108
 
109
  $new_options['zoom'] = is_numeric( $_POST['zoom'] ) ? sanitize_text_field( $_POST['zoom'] ) : '';
110
  $new_options['type'] = strtoupper( sanitize_text_field( $_POST['type'] ) );
111
+ $new_options['icon'] = esc_url_raw( $_POST['icon'], array( 'http', 'https' ) );
112
  $new_options['content'] = $_POST['content'];
113
  if ( isset( $_POST['editCSS'] ) ) {
114
  $new_options['editCSS'] = $_POST['editCSS'];
127
  $message = '<div id="message" class="updated"><p>Simple Google Map settings updated.</p></div>';
128
  } else {
129
  $sgm_options = get_option( 'SGMoptions' );
130
+ $sgm_options = wp_parse_args( array_filter( $sgm_options ), $this->default_options );
131
+
132
  $sgm_css = get_option( 'SGMcss' );
133
  }
134
 
admin/partials/simple-google-map-admin-display.php CHANGED
@@ -15,6 +15,7 @@
15
  $message_value = isset( $message ) ? $message : '';
16
  $zoom_value = isset( $sgm_options['zoom'] ) ? $sgm_options['zoom'] : '';
17
  $type_value = isset( $sgm_options['type'] ) ? $sgm_options['type'] : '';
 
18
  $content_value = isset( $sgm_options['content'] ) ? $sgm_options['content'] : '';
19
  $editcss_value = isset( $sgm_options['editCSS'] ) ? 'checked="checked"' : '';
20
  $nostyle_value = isset( $sgm_options['nostyle'] ) ? 'checked="checked"' : '';
@@ -51,6 +52,12 @@ $nostyle_value = isset( $sgm_options['nostyle'] ) ? 'checked="checked"' : '';
51
  </td>
52
  </tr>
53
 
 
 
 
 
 
 
54
  <tr valign="top">
55
  <th><label for="content">Info Bubble Content</label></th>
56
  <td><textarea name="content"><?php echo $content_value ?></textarea></td>
15
  $message_value = isset( $message ) ? $message : '';
16
  $zoom_value = isset( $sgm_options['zoom'] ) ? $sgm_options['zoom'] : '';
17
  $type_value = isset( $sgm_options['type'] ) ? $sgm_options['type'] : '';
18
+ $icon_value = isset( $sgm_options['icon'] ) ? $sgm_options['icon'] : '';
19
  $content_value = isset( $sgm_options['content'] ) ? $sgm_options['content'] : '';
20
  $editcss_value = isset( $sgm_options['editCSS'] ) ? 'checked="checked"' : '';
21
  $nostyle_value = isset( $sgm_options['nostyle'] ) ? 'checked="checked"' : '';
52
  </td>
53
  </tr>
54
 
55
+ <tr>
56
+ <th><label for="icon">Icon</label></th>
57
+ <td><input name="icon" type="text"
58
+ value="<?php echo esc_url( $icon_value, array( 'http', 'https' ) ) ?>"/></td>
59
+ </tr>
60
+
61
  <tr valign="top">
62
  <th><label for="content">Info Bubble Content</label></th>
63
  <td><textarea name="content"><?php echo $content_value ?></textarea></td>
includes/class-simple-google-map-activator.php CHANGED
@@ -34,6 +34,7 @@ class Simple_Google_Map_Activator {
34
  $sgm_defaults = array(
35
  'zoom' => '12',
36
  'type' => 'ROADMAP',
 
37
  'directionsto' => '',
38
  'content' => '',
39
  );
34
  $sgm_defaults = array(
35
  'zoom' => '12',
36
  'type' => 'ROADMAP',
37
+ 'icon' => '',
38
  'directionsto' => '',
39
  'content' => '',
40
  );
includes/class-simple-google-map.php CHANGED
@@ -74,6 +74,14 @@ class Simple_Google_Map {
74
  */
75
  protected $version;
76
 
 
 
 
 
 
 
 
 
77
  /**
78
  * Define the core functionality of the plugin.
79
  *
@@ -86,7 +94,7 @@ class Simple_Google_Map {
86
  public function __construct() {
87
 
88
  $this->plugin_name = 'simple-google-map';
89
- $this->version = '3.0.0';
90
 
91
  $this->load_dependencies();
92
  $this->set_locale();
74
  */
75
  protected $version;
76
 
77
+ static $default_options = array(
78
+ 'zoom' => '12',
79
+ 'type' => 'ROADMAP',
80
+ 'icon' => '',
81
+ 'directionsto' => '',
82
+ 'content' => '',
83
+ );
84
+
85
  /**
86
  * Define the core functionality of the plugin.
87
  *
94
  public function __construct() {
95
 
96
  $this->plugin_name = 'simple-google-map';
97
+ $this->version = '3.2.2';
98
 
99
  $this->load_dependencies();
100
  $this->set_locale();
public/class-simple-google-map-public.php CHANGED
@@ -104,6 +104,7 @@ class Simple_Google_Map_Public {
104
  public function map( $atts ) {
105
 
106
  $sgm_options = get_option( 'SGMoptions' ); // get options defined in admin page
 
107
 
108
  $lat = isset( $atts['lat'] ) ? $atts['lat'] : '0';
109
  $lng = isset( $atts['lng'] ) ? $atts['lng'] : '0';
@@ -111,6 +112,10 @@ class Simple_Google_Map_Public {
111
  $type = isset( $atts['type'] ) ? strtoupper( $atts['type'] ) : $sgm_options['type'];
112
  $content = isset( $atts['content'] ) ? $atts['content'] : $sgm_options['content'];
113
  $directions_to = isset( $atts['directionsto'] ) ? $atts['directionsto'] : '';
 
 
 
 
114
 
115
  $content = Simple_Google_Map::strip_last_chars( htmlspecialchars_decode( $content ), array(
116
  '<br>',
@@ -123,7 +128,21 @@ class Simple_Google_Map_Public {
123
  $directions_form = '<form method="get" action="//maps.google.com/maps"><input type="hidden" name="daddr" value="' . $directions_to . '" /><input type="text" class="text" name="saddr" /><input type="submit" class="submit" value="Directions" /></form>';
124
  }
125
 
126
- $infowindow_arr = array( $content, $directions_to, $directions_form );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
128
 
129
  $map = '<script type="text/javascript">';
@@ -143,15 +162,12 @@ class Simple_Google_Map_Public {
143
  var infowindow = new google.maps.InfoWindow({
144
  content: contentstring
145
  });
146
- var marker = new google.maps.Marker({
147
- position: latlng,
148
- map: map,
149
- title: ''
150
- });
151
  google.maps.event.addListener(marker, 'click', function() {
152
  infowindow.open(map,marker);
153
  });
154
- }
155
  window.onload = makeMap;";
156
  $map .= '</script>';
157
  $map .= '<div id="SGM"></div>';
104
  public function map( $atts ) {
105
 
106
  $sgm_options = get_option( 'SGMoptions' ); // get options defined in admin page
107
+ $sgm_options = wp_parse_args( $sgm_options, Simple_Google_Map::$default_options );
108
 
109
  $lat = isset( $atts['lat'] ) ? $atts['lat'] : '0';
110
  $lng = isset( $atts['lng'] ) ? $atts['lng'] : '0';
112
  $type = isset( $atts['type'] ) ? strtoupper( $atts['type'] ) : $sgm_options['type'];
113
  $content = isset( $atts['content'] ) ? $atts['content'] : $sgm_options['content'];
114
  $directions_to = isset( $atts['directionsto'] ) ? $atts['directionsto'] : '';
115
+ $icon = isset( $atts['icon'] ) ? esc_url( $atts['icon'], array(
116
+ 'http',
117
+ 'https',
118
+ ) ) : $sgm_options['icon'];
119
 
120
  $content = Simple_Google_Map::strip_last_chars( htmlspecialchars_decode( $content ), array(
121
  '<br>',
128
  $directions_form = '<form method="get" action="//maps.google.com/maps"><input type="hidden" name="daddr" value="' . $directions_to . '" /><input type="text" class="text" name="saddr" /><input type="submit" class="submit" value="Directions" /></form>';
129
  }
130
 
131
+ $marker = "var marker = new google.maps.Marker({
132
+ position: latlng,
133
+ map: map,
134
+ title: '',";
135
+
136
+ if ( $icon ) {
137
+ $icon = "var image = {
138
+ url: '$icon',
139
+ };";
140
+ $marker .= "\n" . 'icon: image,' . "\n";
141
+ }
142
+
143
+ $marker .= '});';
144
+
145
+ $infowindow_arr = array( $content, $directions_form );
146
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
147
 
148
  $map = '<script type="text/javascript">';
162
  var infowindow = new google.maps.InfoWindow({
163
  content: contentstring
164
  });
165
+ $icon
166
+ $marker
 
 
 
167
  google.maps.event.addListener(marker, 'click', function() {
168
  infowindow.open(map,marker);
169
  });
170
+ };
171
  window.onload = makeMap;";
172
  $map .= '</script>';
173
  $map .= '<div id="SGM"></div>';
widgets/simple-google-map-widget.php CHANGED
@@ -149,7 +149,7 @@ class Simple_Google_Map_Widget extends WP_Widget {
149
  $directions_form = '<form method="get" action="//maps.google.com/maps"><input type="hidden" name="daddr" value="' . $directions_to . '" /><input type="text" class="text" name="saddr" /><input type="submit" class="submit" value="Directions" /></form>';
150
  }
151
 
152
- $infowindow_arr = array( $content, $directions_to, $directions_form );
153
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
154
 
155
  extract( $args );
149
  $directions_form = '<form method="get" action="//maps.google.com/maps"><input type="hidden" name="daddr" value="' . $directions_to . '" /><input type="text" class="text" name="saddr" /><input type="submit" class="submit" value="Directions" /></form>';
150
  }
151
 
152
+ $infowindow_arr = array( $content, $directions_form );
153
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
154
 
155
  extract( $args );