Simple Google Map - Version 4.1

Version Description

  • Add custom map marker to widget options
Download this release

Release Info

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

Code changes from version 4.0 to 4.1

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: 4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -53,6 +53,9 @@ The shortcode name is SGM and here are the options..
53
 
54
  == Changelog ==
55
 
 
 
 
56
  = 4.0 =
57
  * Add support for Google Maps API Key
58
 
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: 4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
53
 
54
  == Changelog ==
55
 
56
+ = 4.1 =
57
+ * Add custom map marker to widget options
58
+
59
  = 4.0 =
60
  * Add support for Google Maps API Key
61
 
simple-google-map.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: Simple Google Map
17
  * Plugin URI: http://clarknikdelpowell.com/wordpress/simple-google-map
18
  * Description: Embed a google map using shortcode or as a widget.
19
- * Version: 4.0
20
  * Author: Taylor Gorman, Glenn Welser
21
  * Author URI: http://clarknikdelpowell.com
22
  * License: GPL-2.0+
16
  * Plugin Name: Simple Google Map
17
  * Plugin URI: http://clarknikdelpowell.com/wordpress/simple-google-map
18
  * Description: Embed a google map using shortcode or as a widget.
19
+ * Version: 4.1
20
  * Author: Taylor Gorman, Glenn Welser
21
  * Author URI: http://clarknikdelpowell.com
22
  * License: GPL-2.0+
widgets/simple-google-map-widget.php CHANGED
@@ -41,6 +41,7 @@ class Simple_Google_Map_Widget extends WP_Widget {
41
  $type = isset( $instance['type'] ) ? esc_attr( $instance['type'] ) : '';
42
  $directionsto = isset( $instance['directionsto'] ) ? esc_attr( $instance['directionsto'] ) : '';
43
  $content = isset( $instance['content'] ) ? esc_attr( $instance['content'] ) : '';
 
44
 
45
  ?>
46
  <p>
@@ -70,6 +71,11 @@ class Simple_Google_Map_Widget extends WP_Widget {
70
  <input class="widefat" id="<?php echo $this->get_field_id( 'type' ) ?>"
71
  name="<?php echo $this->get_field_name( 'type' ) ?>" type="text" value="<?php echo $type ?>"/>
72
  </p>
 
 
 
 
 
73
  <p>
74
  <label
75
  for="<?php echo $this->get_field_id( 'directionsto' ) ?>"><?php _e( 'Address for directions:' ) ?></label>
@@ -101,6 +107,7 @@ class Simple_Google_Map_Widget extends WP_Widget {
101
  $instance['type'] = esc_attr( $new_instance['type'] );
102
  $instance['directionsto'] = esc_attr( $new_instance['directionsto'] );
103
  $instance['content'] = esc_attr( $new_instance['content'] );
 
104
 
105
  return $instance;
106
 
@@ -116,6 +123,7 @@ class Simple_Google_Map_Widget extends WP_Widget {
116
  extract( $instance );
117
 
118
  $sgm_options = get_option( 'SGMoptions' ); // get options defined in admin page
 
119
 
120
  if ( ! $lat ) {
121
  $lat = '0';
@@ -129,6 +137,9 @@ class Simple_Google_Map_Widget extends WP_Widget {
129
  if ( ! $type ) {
130
  $type = $sgm_options['type'];
131
  } // ROADMAP, SATELLITE, HYBRID, TERRAIN
 
 
 
132
  if ( ! $content ) {
133
  $content = $sgm_options['content'];
134
  }
@@ -149,6 +160,20 @@ 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_form );
153
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
154
 
@@ -175,11 +200,8 @@ class Simple_Google_Map_Widget extends WP_Widget {
175
  var infowindow = new google.maps.InfoWindow({
176
  content: contentstring
177
  });
178
- var marker = new google.maps.Marker({
179
- position: latlng,
180
- map: map,
181
- title: ''
182
- });
183
  google.maps.event.addListener(marker, 'click', function() {
184
  infowindow.open(map,marker);
185
  });
41
  $type = isset( $instance['type'] ) ? esc_attr( $instance['type'] ) : '';
42
  $directionsto = isset( $instance['directionsto'] ) ? esc_attr( $instance['directionsto'] ) : '';
43
  $content = isset( $instance['content'] ) ? esc_attr( $instance['content'] ) : '';
44
+ $icon = isset( $instance['icon'] ) ? esc_url( $instance['icon'] ) : '';
45
 
46
  ?>
47
  <p>
71
  <input class="widefat" id="<?php echo $this->get_field_id( 'type' ) ?>"
72
  name="<?php echo $this->get_field_name( 'type' ) ?>" type="text" value="<?php echo $type ?>"/>
73
  </p>
74
+ <p>
75
+ <label for="<?php echo $this->get_field_id( 'icon' ) ?>"><?php _e( 'Icon:' ) ?></label>
76
+ <input class="widefat" id="<?php echo $this->get_field_id( 'icon' ) ?>"
77
+ name="<?php echo $this->get_field_name( 'icon' ) ?>" type="text" value="<?php echo $icon ?>"/>
78
+ </p>
79
  <p>
80
  <label
81
  for="<?php echo $this->get_field_id( 'directionsto' ) ?>"><?php _e( 'Address for directions:' ) ?></label>
107
  $instance['type'] = esc_attr( $new_instance['type'] );
108
  $instance['directionsto'] = esc_attr( $new_instance['directionsto'] );
109
  $instance['content'] = esc_attr( $new_instance['content'] );
110
+ $instance['icon'] = esc_attr( $new_instance['icon'] );
111
 
112
  return $instance;
113
 
123
  extract( $instance );
124
 
125
  $sgm_options = get_option( 'SGMoptions' ); // get options defined in admin page
126
+ $sgm_options = wp_parse_args( $sgm_options, Simple_Google_Map::$default_options );
127
 
128
  if ( ! $lat ) {
129
  $lat = '0';
137
  if ( ! $type ) {
138
  $type = $sgm_options['type'];
139
  } // ROADMAP, SATELLITE, HYBRID, TERRAIN
140
+ if ( ! $icon ) {
141
+ $icon = $sgm_options['icon'];
142
+ }
143
  if ( ! $content ) {
144
  $content = $sgm_options['content'];
145
  }
160
  $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>';
161
  }
162
 
163
+ $marker = "var marker = new google.maps.Marker({
164
+ position: latlng,
165
+ map: map,
166
+ title: '',";
167
+
168
+ if ( $icon ) {
169
+ $icon = "var image = {
170
+ url: '$icon',
171
+ };";
172
+ $marker .= "\n" . 'icon: image,' . "\n";
173
+ }
174
+
175
+ $marker .= '});';
176
+
177
  $infowindow_arr = array( $content, $directions_form );
178
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
179
 
200
  var infowindow = new google.maps.InfoWindow({
201
  content: contentstring
202
  });
203
+ $icon
204
+ $marker
 
 
 
205
  google.maps.event.addListener(marker, 'click', function() {
206
  infowindow.open(map,marker);
207
  });