Flexible Map - Version 1.6.0

Version Description

[2012-12-30] = * added: themes can call function flexmap_load_scripts() to force load of scripts, e.g. on single-page AJAX websites * added: can add HTML block to infowindow, e.g. images * fixed: no auto-focus on directions search field, thus no auto-scroll page to last directions search field!

Download this release

Release Info

Developer webaware
Plugin Icon 128x128 Flexible Map
Version 1.6.0
Comparing to
See all releases

Code changes from version 1.5.3 to 1.6.0

class.FlxMapAdmin.php CHANGED
@@ -43,7 +43,7 @@ class FlxMapAdmin {
43
  // add settings link
44
  if ($file == FLXMAP_PLUGIN_NAME) {
45
  $links[] = '<a href="admin.php?page=' . self::MENU_PAGE . '-instructions">' . __('Instructions') . '</a>';
46
- $links[] = '<a href="http://wordpress.org/support/plugin/wp-flexible-map">' . __('Get Help') . '</a>';
47
  $links[] = '<a href="http://wordpress.org/extend/plugins/wp-flexible-map/">' . __('Rating') . '</a>';
48
  $links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=6ZCY9PST8E4GQ">' . __('Donate') . '</a>';
49
  }
43
  // add settings link
44
  if ($file == FLXMAP_PLUGIN_NAME) {
45
  $links[] = '<a href="admin.php?page=' . self::MENU_PAGE . '-instructions">' . __('Instructions') . '</a>';
46
+ $links[] = '<a href="http://wordpress.org/support/plugin/wp-flexible-map">' . __('Get help') . '</a>';
47
  $links[] = '<a href="http://wordpress.org/extend/plugins/wp-flexible-map/">' . __('Rating') . '</a>';
48
  $links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=6ZCY9PST8E4GQ">' . __('Donate') . '</a>';
49
  }
class.FlxMapPlugin.php CHANGED
@@ -5,7 +5,6 @@
5
  class FlxMapPlugin {
6
  public $urlBase; // string: base URL path to files in plugin
7
 
8
- private $loadScripts = FALSE; // true when scripts should be loaded
9
  private $locales; // hash map of locales required for i18n
10
  private $locale;
11
 
@@ -15,10 +14,10 @@ class FlxMapPlugin {
15
  * @return FlxMapPlugin
16
  */
17
  public static function getInstance() {
18
- static $instance = NULL;
19
 
20
  if (is_null($instance)) {
21
- $instance = new self;
22
  }
23
 
24
  return $instance;
@@ -38,16 +37,18 @@ class FlxMapPlugin {
38
  new FlxMapAdmin($this);
39
  }
40
  else {
41
- // add shortcodes
42
- add_shortcode(FLXMAP_PLUGIN_TAG_MAP, array($this, 'shortcodeMap'));
43
-
44
  // non-admin actions and filters for this plugin
45
- add_action('wp_footer', array($this, 'actionFooter'));
46
- add_action('wp_enqueue_scripts', array($this, 'actionEnqueueStyles'));
47
 
48
  // custom actions and filters for this plugin
49
  add_filter('flexmap_getmap', array($this, 'getMap'), 10, 1);
50
  }
 
 
 
 
 
51
  }
52
 
53
  /**
@@ -58,47 +59,54 @@ class FlxMapPlugin {
58
  $this->locales = array();
59
  $this->locale = get_locale();
60
  if ($this->locale != '' && $this->locale != 'en_US') {
61
- $this->locales[str_replace('_', '-', $this->locale)] = 1;
62
  }
63
  }
64
 
65
  /**
66
- * enqueue any styles we require
 
67
  */
68
- public function actionEnqueueStyles() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  // theme writers: you can remove this stylesheet by calling wp_dequeue_script('flxmap');
70
- wp_enqueue_style('flxmap', "{$this->urlBase}styles.css", FALSE, FLXMAP_PLUGIN_VERSION);
71
  }
72
 
73
  /**
74
  * output anything we need in the footer
75
  */
76
  public function actionFooter() {
77
- if ($this->loadScripts) {
78
- // load required scripts
79
- $url = parse_url($this->urlBase, PHP_URL_PATH);
80
- $version = FLXMAP_PLUGIN_VERSION;
81
 
82
- // allow others to override the Google Maps API URL
83
- $apiURL = apply_filters('flexmap_google_maps_api_url', '//maps.google.com/maps/api/js?v=3.10&amp;sensor=false');
84
- if (!empty($apiURL)) {
85
- echo "<script src=\"$apiURL\"></script>\n";
 
86
  }
87
-
88
- echo "<script src=\"{$url}flexible-map.min.js?v=$version\"></script>\n";
89
-
90
- // see if we need to load i18n messages
91
- foreach (array_keys($this->locales) as $locale) {
92
- // check for specific locale first, e.g. 'zh-CN'
93
  if (file_exists(FLXMAP_PLUGIN_ROOT . "i18n/$locale.js")) {
94
- echo "<script charset='utf-8' src=\"{$url}i18n/$locale.js?v=$version\"></script>\n";
95
- }
96
- else {
97
- // not found, so check for generic locale, e.g. 'zh'
98
- $locale = substr($locale, 0, 2);
99
- if (file_exists(FLXMAP_PLUGIN_ROOT . "i18n/$locale.js")) {
100
- echo "<script charset='utf-8' src=\"{$url}i18n/$locale.js?v=$version\"></script>\n";
101
- }
102
  }
103
  }
104
  }
@@ -127,7 +135,7 @@ class FlxMapPlugin {
127
  $attrs = apply_filters('flexmap_shortcode_attrs', $attrs);
128
 
129
  if (!empty($attrs['src']) || !empty($attrs['center']) || !empty($attrs['address'])) {
130
- $this->loadScripts = TRUE;
131
  if (empty($attrs['id'])) {
132
  $ID = uniqid();
133
  $divID = 'flxmap-' . $ID;
@@ -157,13 +165,13 @@ class FlxMapPlugin {
157
  // test for any conditions that show directions (thus requiring the directions div)
158
  $directions = FALSE;
159
  if (isset($attrs['directions']) && !self::isNo($attrs['directions'])) {
160
- $directions = TRUE;
161
  }
162
  if (isset($attrs['showdirections']) && self::isYes($attrs['showdirections'])) {
163
- $directions = TRUE;
164
  }
165
  if (isset($attrs['directionsfrom'])) {
166
- $directions = TRUE;
167
  }
168
 
169
  // build the directions div, if required
@@ -180,80 +188,74 @@ class FlxMapPlugin {
180
 
181
  $html = <<<HTML
182
  <div id="$divID" class='flxmap-container' data-flxmap='$varID' $inlinestyles></div>$divDirections
183
- <script>
184
- //<![CDATA[
185
- var $varID = false;
186
- (function(w, fn) {
187
- if (w.addEventListener) w.addEventListener("DOMContentLoaded", fn, false);
188
- else if (w.attachEvent) w.attachEvent("onload", fn);
189
- })(window, function() {
190
- var f = new FlexibleMap();
191
 
192
  HTML;
193
 
 
 
194
  if (isset($attrs['hidemaptype']) && self::isYes($attrs['hidemaptype'])) {
195
- $html .= " f.mapTypeControl = false;\n";
196
  }
197
 
198
  if (isset($attrs['hidescale']) && self::isNo($attrs['hidescale'])) {
199
- $html .= " f.scaleControl = true;\n";
200
  }
201
 
202
  if (isset($attrs['hidepanning']) && self::isNo($attrs['hidepanning'])) {
203
- $html .= " f.panControl = true;\n";
204
  }
205
 
206
  if (isset($attrs['hidezooming']) && self::isYes($attrs['hidezooming'])) {
207
- $html .= " f.zoomControl = false;\n";
208
  }
209
 
210
  if (isset($attrs['hidestreetview']) && self::isNo($attrs['hidestreetview'])) {
211
- $html .= " f.streetViewControl = true;\n";
212
  }
213
 
214
  if (isset($attrs['showinfo']) && self::isNo($attrs['showinfo'])) {
215
- $html .= " f.markerShowInfo = false;\n";
216
  }
217
 
218
  if (isset($attrs['scrollwheel']) && self::isYes($attrs['scrollwheel'])) {
219
- $html .= " f.scrollwheel = true;\n";
220
  }
221
 
222
  if (isset($attrs['draggable']) && self::isNo($attrs['draggable'])) {
223
- $html .= " f.draggable = false;\n";
224
  }
225
 
226
  if (isset($attrs['dblclickzoom']) && self::isNo($attrs['dblclickzoom'])) {
227
- $html .= " f.dblclickZoom = false;\n";
228
  }
229
 
230
  if ($directions) {
231
- $html .= " f.markerDirections = \"$divDirectionsID\";\n";
232
  }
233
 
234
  if (isset($attrs['showdirections']) && self::isYes($attrs['showdirections'])) {
235
- $html .= " f.markerDirectionsShow = true;\n";
236
  }
237
 
238
  if (isset($attrs['directionsfrom'])) {
239
- $html .= " f.markerDirectionsDefault = \"{$this->str2js($attrs['directionsfrom'])}\";\n";
240
  }
241
 
242
  if (isset($attrs['maptype'])) {
243
- $html .= " f.mapTypeId = \"{$this->str2js($attrs['maptype'])}\";\n";
244
  }
245
 
246
  if (isset($attrs['region'])) {
247
- $html .= " f.region = \"{$this->str2js($attrs['region'])}\";\n";
248
  }
249
 
250
  if (isset($attrs['locale'])) {
251
- $html .= " f.setlocale(\"{$this->str2js($attrs['locale'])}\");\n";
252
  $this->locales[$attrs['locale']] = 1;
253
  }
254
  else if ($this->locale != '' || $this->locale != 'en-US') {
255
  $locale = self::str2js(str_replace('_', '-', $this->locale));
256
- $html .= " f.setlocale(\"$locale\");\n";
257
  $this->locales[$locale] = 1;
258
  }
259
 
@@ -264,71 +266,99 @@ HTML;
264
  $marker = self::str2js($attrs['marker']);
265
 
266
  if (isset($attrs['zoom']))
267
- $html .= " f.zoom = " . preg_replace('/\D/', '', $attrs['zoom']) . ";\n";
268
 
269
  if (!empty($attrs['title']))
270
- $html .= " f.markerTitle = \"{$this->unhtml($attrs['title'])}\";\n";
271
 
272
  if (!empty($attrs['description']))
273
- $html .= " f.markerDescription = \"{$this->unhtml($attrs['description'])}\";\n";
 
 
 
274
 
275
  if (!empty($attrs['address']))
276
- $html .= " f.markerAddress = \"{$this->unhtml($attrs['address'])}\";\n";
277
 
278
  if (!empty($attrs['link'])) {
279
  $link = self::str2js($attrs['link']);
280
- $html .= " f.markerLink = \"$link\";\n";
281
  }
282
 
283
- $html .= " f.showMarker(\"$divID\", [{$attrs['center']}], [{$marker}]);\n";
284
  }
285
 
286
  // add map based on address query
287
  else if (isset($attrs['address'])) {
288
  if (isset($attrs['zoom']))
289
- $html .= " f.zoom = " . preg_replace('/\D/', '', $attrs['zoom']) . ";\n";
290
 
291
  if (!empty($attrs['title']))
292
- $html .= " f.markerTitle = \"{$this->unhtml($attrs['title'])}\";\n";
293
 
294
  if (!empty($attrs['description']))
295
- $html .= " f.markerDescription = \"{$this->unhtml($attrs['description'])}\";\n";
296
 
297
  if (!empty($attrs['link'])) {
298
  $link = self::str2js($attrs['link']);
299
- $html .= " f.markerLink = \"$link\";\n";
300
  }
301
 
302
- $html .= " f.showAddress(\"$divID\", \"{$this->unhtml($attrs['address'])}\");\n";
303
  }
304
 
305
  // add map based on KML file
306
  else if (isset($attrs['src'])) {
307
  if (isset($attrs['targetfix']) && self::isNo($attrs['targetfix'])) {
308
- $html .= " f.targetFix = false;\n";
309
  }
310
 
311
  $kmlfile = self::str2js($attrs['src']);
312
- $html .= " f.showKML(\"$divID\", \"$kmlfile\"";
313
 
314
  if (isset($attrs['zoom']))
315
- $html .= ', ' . preg_replace('/\D/', '', $attrs['zoom']);
316
 
317
- $html .= ");\n";
318
  }
319
 
320
- $html .= <<<HTML
321
- $varID = f;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  });
323
- //]]>
324
  </script>
325
 
326
  HTML;
 
 
327
  }
328
 
329
  // allow others to change the generated html
330
  $html = apply_filters('flexmap_shortcode_html', $html, $attrs);
331
 
 
 
332
  return $html;
333
  }
334
 
5
  class FlxMapPlugin {
6
  public $urlBase; // string: base URL path to files in plugin
7
 
 
8
  private $locales; // hash map of locales required for i18n
9
  private $locale;
10
 
14
  * @return FlxMapPlugin
15
  */
16
  public static function getInstance() {
17
+ static $instance = null;
18
 
19
  if (is_null($instance)) {
20
+ $instance = new self();
21
  }
22
 
23
  return $instance;
37
  new FlxMapAdmin($this);
38
  }
39
  else {
 
 
 
40
  // non-admin actions and filters for this plugin
41
+ add_action('wp_footer', array($this, 'actionFooter'), 100); // NB: must come after footer enqueued scripts!
42
+ add_action('wp_enqueue_scripts', array($this, 'actionEnqueueScripts'));
43
 
44
  // custom actions and filters for this plugin
45
  add_filter('flexmap_getmap', array($this, 'getMap'), 10, 1);
46
  }
47
+
48
+ if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
49
+ // add shortcodes
50
+ add_shortcode(FLXMAP_PLUGIN_TAG_MAP, array($this, 'shortcodeMap'));
51
+ }
52
  }
53
 
54
  /**
59
  $this->locales = array();
60
  $this->locale = get_locale();
61
  if ($this->locale != '' && $this->locale != 'en_US') {
62
+ $this->setLocales(array($this->locale));
63
  }
64
  }
65
 
66
  /**
67
+ * set the reqired locales so that appropriate scripts will be loaded
68
+ * @param array $locales a list of locale names
69
  */
70
+ public function setLocales($locales) {
71
+ foreach ($locales as $locale) {
72
+ $this->locales[strtr($locale, '_', '-')] = 1;
73
+ }
74
+ }
75
+
76
+ /**
77
+ * register and enqueue any scripts and styles we require
78
+ */
79
+ public function actionEnqueueScripts() {
80
+ // allow others to override the Google Maps API URL
81
+ $protocol = is_ssl() ? 'https' : 'http';
82
+ $apiURL = apply_filters('flexmap_google_maps_api_url', "$protocol://maps.google.com/maps/api/js?v=3.10&sensor=false");
83
+ if (!empty($apiURL)) {
84
+ wp_register_script('google-maps', $apiURL, false, null, true);
85
+ }
86
+
87
+ wp_register_script('flxmap', $this->urlBase . 'flexible-map.min.js', array('google-maps'), FLXMAP_PLUGIN_VERSION, true);
88
+
89
  // theme writers: you can remove this stylesheet by calling wp_dequeue_script('flxmap');
90
+ wp_enqueue_style('flxmap', $this->urlBase . 'styles.css', false, FLXMAP_PLUGIN_VERSION);
91
  }
92
 
93
  /**
94
  * output anything we need in the footer
95
  */
96
  public function actionFooter() {
97
+ $version = FLXMAP_PLUGIN_VERSION;
 
 
 
98
 
99
+ // see if we need to load i18n messages
100
+ foreach (array_keys($this->locales) as $locale) {
101
+ // check for specific locale first, e.g. 'zh-CN'
102
+ if (file_exists(FLXMAP_PLUGIN_ROOT . "i18n/$locale.js")) {
103
+ echo "<script charset='utf-8' src=\"{$this->urlBase}i18n/$locale.js?v=$version\"></script>\n";
104
  }
105
+ else {
106
+ // not found, so check for generic locale, e.g. 'zh'
107
+ $locale = substr($locale, 0, 2);
 
 
 
108
  if (file_exists(FLXMAP_PLUGIN_ROOT . "i18n/$locale.js")) {
109
+ echo "<script charset='utf-8' src=\"{$this->urlBase}i18n/$locale.js?v=$version\"></script>\n";
 
 
 
 
 
 
 
110
  }
111
  }
112
  }
135
  $attrs = apply_filters('flexmap_shortcode_attrs', $attrs);
136
 
137
  if (!empty($attrs['src']) || !empty($attrs['center']) || !empty($attrs['address'])) {
138
+ $this->loadScripts = true;
139
  if (empty($attrs['id'])) {
140
  $ID = uniqid();
141
  $divID = 'flxmap-' . $ID;
165
  // test for any conditions that show directions (thus requiring the directions div)
166
  $directions = FALSE;
167
  if (isset($attrs['directions']) && !self::isNo($attrs['directions'])) {
168
+ $directions = true;
169
  }
170
  if (isset($attrs['showdirections']) && self::isYes($attrs['showdirections'])) {
171
+ $directions = true;
172
  }
173
  if (isset($attrs['directionsfrom'])) {
174
+ $directions = true;
175
  }
176
 
177
  // build the directions div, if required
188
 
189
  $html = <<<HTML
190
  <div id="$divID" class='flxmap-container' data-flxmap='$varID' $inlinestyles></div>$divDirections
 
 
 
 
 
 
 
 
191
 
192
  HTML;
193
 
194
+ $script = " var f = new FlexibleMap();\n";
195
+
196
  if (isset($attrs['hidemaptype']) && self::isYes($attrs['hidemaptype'])) {
197
+ $script .= " f.mapTypeControl = false;\n";
198
  }
199
 
200
  if (isset($attrs['hidescale']) && self::isNo($attrs['hidescale'])) {
201
+ $script .= " f.scaleControl = true;\n";
202
  }
203
 
204
  if (isset($attrs['hidepanning']) && self::isNo($attrs['hidepanning'])) {
205
+ $script .= " f.panControl = true;\n";
206
  }
207
 
208
  if (isset($attrs['hidezooming']) && self::isYes($attrs['hidezooming'])) {
209
+ $script .= " f.zoomControl = false;\n";
210
  }
211
 
212
  if (isset($attrs['hidestreetview']) && self::isNo($attrs['hidestreetview'])) {
213
+ $script .= " f.streetViewControl = true;\n";
214
  }
215
 
216
  if (isset($attrs['showinfo']) && self::isNo($attrs['showinfo'])) {
217
+ $script .= " f.markerShowInfo = false;\n";
218
  }
219
 
220
  if (isset($attrs['scrollwheel']) && self::isYes($attrs['scrollwheel'])) {
221
+ $script .= " f.scrollwheel = true;\n";
222
  }
223
 
224
  if (isset($attrs['draggable']) && self::isNo($attrs['draggable'])) {
225
+ $script .= " f.draggable = false;\n";
226
  }
227
 
228
  if (isset($attrs['dblclickzoom']) && self::isNo($attrs['dblclickzoom'])) {
229
+ $script .= " f.dblclickZoom = false;\n";
230
  }
231
 
232
  if ($directions) {
233
+ $script .= " f.markerDirections = \"$divDirectionsID\";\n";
234
  }
235
 
236
  if (isset($attrs['showdirections']) && self::isYes($attrs['showdirections'])) {
237
+ $script .= " f.markerDirectionsShow = true;\n";
238
  }
239
 
240
  if (isset($attrs['directionsfrom'])) {
241
+ $script .= " f.markerDirectionsDefault = \"{$this->str2js($attrs['directionsfrom'])}\";\n";
242
  }
243
 
244
  if (isset($attrs['maptype'])) {
245
+ $script .= " f.mapTypeId = \"{$this->str2js($attrs['maptype'])}\";\n";
246
  }
247
 
248
  if (isset($attrs['region'])) {
249
+ $script .= " f.region = \"{$this->str2js($attrs['region'])}\";\n";
250
  }
251
 
252
  if (isset($attrs['locale'])) {
253
+ $script .= " f.setlocale(\"{$this->str2js($attrs['locale'])}\");\n";
254
  $this->locales[$attrs['locale']] = 1;
255
  }
256
  else if ($this->locale != '' || $this->locale != 'en-US') {
257
  $locale = self::str2js(str_replace('_', '-', $this->locale));
258
+ $script .= " f.setlocale(\"$locale\");\n";
259
  $this->locales[$locale] = 1;
260
  }
261
 
266
  $marker = self::str2js($attrs['marker']);
267
 
268
  if (isset($attrs['zoom']))
269
+ $script .= " f.zoom = " . preg_replace('/\D/', '', $attrs['zoom']) . ";\n";
270
 
271
  if (!empty($attrs['title']))
272
+ $script .= " f.markerTitle = \"{$this->unhtml($attrs['title'])}\";\n";
273
 
274
  if (!empty($attrs['description']))
275
+ $script .= " f.markerDescription = \"{$this->unhtml($attrs['description'])}\";\n";
276
+
277
+ if (!empty($attrs['html']))
278
+ $script .= " f.markerHTML = \"{$this->str2js($attrs['html'])}\";\n";
279
 
280
  if (!empty($attrs['address']))
281
+ $script .= " f.markerAddress = \"{$this->unhtml($attrs['address'])}\";\n";
282
 
283
  if (!empty($attrs['link'])) {
284
  $link = self::str2js($attrs['link']);
285
+ $script .= " f.markerLink = \"$link\";\n";
286
  }
287
 
288
+ $script .= " f.showMarker(\"$divID\", [{$attrs['center']}], [{$marker}]);\n";
289
  }
290
 
291
  // add map based on address query
292
  else if (isset($attrs['address'])) {
293
  if (isset($attrs['zoom']))
294
+ $script .= " f.zoom = " . preg_replace('/\D/', '', $attrs['zoom']) . ";\n";
295
 
296
  if (!empty($attrs['title']))
297
+ $script .= " f.markerTitle = \"{$this->unhtml($attrs['title'])}\";\n";
298
 
299
  if (!empty($attrs['description']))
300
+ $script .= " f.markerDescription = \"{$this->unhtml($attrs['description'])}\";\n";
301
 
302
  if (!empty($attrs['link'])) {
303
  $link = self::str2js($attrs['link']);
304
+ $script .= " f.markerLink = \"$link\";\n";
305
  }
306
 
307
+ $script .= " f.showAddress(\"$divID\", \"{$this->unhtml($attrs['address'])}\");\n";
308
  }
309
 
310
  // add map based on KML file
311
  else if (isset($attrs['src'])) {
312
  if (isset($attrs['targetfix']) && self::isNo($attrs['targetfix'])) {
313
+ $script .= " f.targetFix = false;\n";
314
  }
315
 
316
  $kmlfile = self::str2js($attrs['src']);
317
+ $script .= " f.showKML(\"$divID\", \"$kmlfile\"";
318
 
319
  if (isset($attrs['zoom']))
320
+ $script .= ', ' . preg_replace('/\D/', '', $attrs['zoom']);
321
 
322
+ $script .= ");\n";
323
  }
324
 
325
+ if ((defined('DOING_AJAX') && DOING_AJAX) || (isset($attrs['isajax']) && self::isYes($attrs['isajax']))) {
326
+ // wrap it up for AJAX load, no event trigger
327
+ $html .= <<<HTML
328
+ <script>
329
+ /* <![CDATA[ */
330
+ var $varID = (function() {
331
+ $script return f;
332
+ })();
333
+ /* ]]> */
334
+ </script>
335
+
336
+ HTML;
337
+ }
338
+ else {
339
+ // wrap it up for standard page load, with "content ready" trigger
340
+ $html .= <<<HTML
341
+ <script>
342
+ /* <![CDATA[ */
343
+ (function(w, fn) {
344
+ if (w.addEventListener) w.addEventListener("DOMContentLoaded", fn, false);
345
+ else if (w.attachEvent) w.attachEvent("onload", fn);
346
+ })(window, function() {
347
+ $script window.$varID = f;
348
  });
349
+ /* ]]> */
350
  </script>
351
 
352
  HTML;
353
+ }
354
+
355
  }
356
 
357
  // allow others to change the generated html
358
  $html = apply_filters('flexmap_shortcode_html', $html, $attrs);
359
 
360
+ wp_enqueue_script('flxmap');
361
+
362
  return $html;
363
  }
364
 
flexible-map.js CHANGED
@@ -112,6 +112,7 @@ function FlexibleMap() {
112
  this.zoom = 16; // zoom level, smaller is closer
113
  this.markerTitle = ''; // title for marker info window
114
  this.markerDescription = ''; // description for marker info window
 
115
  this.markerLink = ''; // link for marker title
116
  this.markerShowInfo = true; // if have infowin for marker, show it immediately
117
  this.markerDirections = false; // show directions link in info window
@@ -253,7 +254,7 @@ FlexibleMap.prototype = (function() {
253
  if (key in phrases)
254
  return phrases[key];
255
 
256
- return "";
257
  },
258
 
259
  /**
@@ -355,6 +356,13 @@ FlexibleMap.prototype = (function() {
355
  element.appendChild(document.createTextNode(this.markerTitle));
356
  container.appendChild(element);
357
 
 
 
 
 
 
 
 
358
  // body of info window, with link
359
  if (this.markerDescription || this.markerLink) {
360
  element = document.createElement("DIV");
@@ -508,7 +516,7 @@ FlexibleMap.prototype = (function() {
508
  p.appendChild(input);
509
  form.appendChild(p);
510
  panel.appendChild(form);
511
- from.focus();
512
 
513
  // hack to fix IE<=7 name weirdness for dynamically created form elements;
514
  // see http://msdn.microsoft.com/en-us/library/ms534184.aspx but have a hanky ready
112
  this.zoom = 16; // zoom level, smaller is closer
113
  this.markerTitle = ''; // title for marker info window
114
  this.markerDescription = ''; // description for marker info window
115
+ this.markerHTML = ''; // HTML for marker info window (overrides title and description)
116
  this.markerLink = ''; // link for marker title
117
  this.markerShowInfo = true; // if have infowin for marker, show it immediately
118
  this.markerDirections = false; // show directions link in info window
254
  if (key in phrases)
255
  return phrases[key];
256
 
257
+ return key;
258
  },
259
 
260
  /**
356
  element.appendChild(document.createTextNode(this.markerTitle));
357
  container.appendChild(element);
358
 
359
+ // add precomposed HTML for infowindow
360
+ if (this.markerHTML) {
361
+ element = document.createElement("DIV");
362
+ element.innerHTML = this.markerHTML;
363
+ container.appendChild(element);
364
+ }
365
+
366
  // body of info window, with link
367
  if (this.markerDescription || this.markerLink) {
368
  element = document.createElement("DIV");
516
  p.appendChild(input);
517
  form.appendChild(p);
518
  panel.appendChild(form);
519
+ //~ from.focus(); // -- removed because causing problems autofocusing on elements and scrolling the page!
520
 
521
  // hack to fix IE<=7 name weirdness for dynamically created form elements;
522
  // see http://msdn.microsoft.com/en-us/library/ms534184.aspx but have a hanky ready
flexible-map.min.js CHANGED
@@ -2,4 +2,4 @@
2
  JavaScript for the WordPress plugin wp-flexible-map
3
  copyright (c) 2011-2012 WebAware Pty Ltd, released under LGPL v2.1
4
  */
5
- function FlexibleMap(){var d,b,c,a=false;this.getMap=function(){return d};this.getCenter=function(){return b};this.setCenter=function(e){b=e;d.setCenter(b)};this.getKmlLayer=function(){return c};this.redrawOnce=function(){if(!a){a=true;this.redraw()}};this.showMap=function(e,f){b=new google.maps.LatLng(f[0],f[1]);d=new google.maps.Map(document.getElementById(e),{mapTypeId:this.mapTypeId,mapTypeControl:this.mapTypeControl,scaleControl:this.scaleControl,panControl:this.panControl,zoomControl:this.zoomControl,draggable:this.draggable,disableDoubleClickZoom:!this.dblclickZoom,scrollwheel:this.scrollwheel,streetViewControl:this.streetViewControl,navigationControlOptions:this.navigationControlOptions,center:b,zoom:this.zoom});return d};this.loadKmlMap=function(e){c=new google.maps.KmlLayer(e);c.setMap(d);google.maps.event.addListenerOnce(c,"defaultviewport_changed",function(){b=c.getDefaultViewport().getCenter()});return c};this.mapTypeId=google.maps.MapTypeId.ROADMAP;this.mapTypeControl=true;this.scaleControl=false;this.panControl=false;this.zoomControl=true;this.streetViewControl=false;this.scrollwheel=false;this.draggable=true;this.dblclickZoom=true;this.zoom=16;this.markerTitle="";this.markerDescription="";this.markerLink="";this.markerShowInfo=true;this.markerDirections=false;this.markerDirectionsShow=false;this.markerDirectionsDefault="";this.markerAddress="";this.targetFix=true;this.navigationControlOptions={style:google.maps.NavigationControlStyle.SMALL};this.dirService=false;this.dirPanel=false;this.region="";this.locale="en";this.localeActive="en"}FlexibleMap.prototype=(function(){var d,c,b;if(document.addEventListener){d=function(f,e,g){f.addEventListener(e,g,false)};c=function(e){e.stopPropagation();e.preventDefault()};b=function(f,e){var g=document.createEvent("HTMLEvents");g.initEvent(e,true,true);f.dispatchEvent(g)}}else{if(document.attachEvent){d=function(e,f,g){e.attachEvent("on"+f,function(){g.call(e,window.event)})};c=function(e){e.cancelBubble=true;e.returnValue=0};b=function(f,e){var g=document.createEventObject();g.eventType=e;f.fireEvent("on"+e,g)}}}var a=(function(){function e(g){var h=g.charCodeAt(0),f=h.toString(16);if(h<256){return"\\x"+("00"+f).slice(-2)}return"\\u"+("0000"+f).slice(-4)}return function(f){return f.replace(/[\\\/"'&<>\x00-\x1f\x7f-\xa0\u2000-\u200f\u2028-\u202f]/g,e)}})();return{constructor:FlexibleMap,i18n:{en:{"Click for details":"Click for details",Directions:"Directions",From:"From","Get directions":"Get directions"}},setlocale:function(e){this.locale=e;if(e in this.i18n){this.localeActive=e}else{e=e.substr(0,2);if(e in this.i18n){this.localeActive=e}else{this.localeActive="en"}}return this.localeActive},gettext:function(f){var e=this.i18n[this.localeActive];if(f in e){return e[f]}return""},showKML:function(e,h,i){var g=this,f=document.getElementById(e),l=f.getAttribute("data-flxmap"),k=this.showMap(e,[0,0]),j=this.loadKmlMap(h);if(typeof i!="undefined"){google.maps.event.addListenerOnce(k,"tilesloaded",function(){k.setZoom(i);g.zoom=i})}if(this.markerDirections){this.startDirService(k)}google.maps.event.addListener(j,"click",function(r){var p=r.featureData;if(!p._flxmapOnce){p._flxmapOnce=true;if(g.targetFix){var o=/ target="_blank"/ig;p.description=p.description.replace(o,"");p.infoWindowHtml=p.infoWindowHtml.replace(o,"")}if(g.markerDirections){var n=r.latLng,q=n.lat()+","+n.lng()+",'"+a(p.name)+"'",m='<br /><a href="#" data-flxmap-fix-opera="1" onclick="'+l+".showDirections("+q+'); return false;">'+g.gettext("Directions")+"</a>";p.infoWindowHtml=p.infoWindowHtml.replace(/<\/div><\/div>$/i,m+"</div></div>")}}});if(window.opera&&this.markerDirections){d(f,"click",function(m){if(m.target.getAttribute("data-flxmap-fix-opera")){c(m)}})}},showMarker:function(h,g,m){var f=this.showMap(h,g),p=new google.maps.Marker({map:f,position:new google.maps.LatLng(m[0],m[1])});if(!this.markerTitle){this.markerTitle=this.markerAddress}if(this.markerTitle){var l,n,r,j,k,o,q=this,e=document.createElement("DIV");e.className="flxmap-infowin";p.setTitle(this.markerTitle);k=document.createElement("DIV");k.className="flxmap-marker-title";k.appendChild(document.createTextNode(this.markerTitle));e.appendChild(k);if(this.markerDescription||this.markerLink){k=document.createElement("DIV");k.className="flxmap-marker-link";if(this.markerDescription){r=this.markerDescription.split("\n");for(l=0,n=r.length;l<n;l++){if(l>0){k.appendChild(document.createElement("BR"))}k.appendChild(document.createTextNode(r[l]))}if(this.markerLink){k.appendChild(document.createElement("BR"))}}if(this.markerLink){o=document.createElement("A");o.href=this.markerLink;o.appendChild(document.createTextNode(this.gettext("Click for details")));k.appendChild(o)}e.appendChild(k)}if(this.markerDirections){k=document.createElement("DIV");k.className="flxmap-directions-link";o=document.createElement("A");o.href="#";o.dataLatitude=m[0];o.dataLongitude=m[1];o.dataTitle=this.markerTitle;d(o,"click",function(i){c(i);q.showDirections(this.dataLatitude,this.dataLongitude,this.dataTitle)});o.appendChild(document.createTextNode(this.gettext("Directions")));k.appendChild(o);e.appendChild(k)}if(this.markerDirections||this.markerDirectionsShow){this.startDirService(f);if(this.markerDirectionsShow){this.showDirections(m[0],m[1],this.markerTitle)}}j=new google.maps.InfoWindow({content:e});if(this.markerShowInfo){j.open(f,p)}google.maps.event.addListener(p,"click",function(){j.open(f,p)})}},showAddress:function(e,f){var g=this,h=new google.maps.Geocoder();this.markerAddress=f;if(this.markerTitle===""){this.markerTitle=f}h.geocode({address:f,region:this.region},function(k,j){if(j==google.maps.GeocoderStatus.OK){var i=k[0].geometry.location,l=[i.lat(),i.lng()];g.showMarker(e,l,l)}else{alert("Map address returns error: "+j)}})},redraw:function(){var f=this.getMap(),e=this.getKmlLayer();google.maps.event.trigger(f,"resize");if(e){f.fitBounds(e.getDefaultViewport())}else{f.setCenter(this.getCenter());f.setZoom(this.zoom)}},startDirService:function(e){if(!this.dirService){this.dirService=new google.maps.DirectionsService()}if(!this.dirPanel){this.dirPanel=new google.maps.DirectionsRenderer({map:e,panel:document.getElementById(this.markerDirections)})}},showDirections:function(i,e,k){var f=document.getElementById(this.markerDirections),h=document.createElement("form"),n=this,j=this.region||"",l,g,m;while(!!(g=f.lastChild)){f.removeChild(g)}g=document.createElement("p");g.appendChild(document.createTextNode(this.gettext("From")+": "));m=document.createElement("input");m.type="text";m.name="from";m.value=this.markerDirectionsDefault;g.appendChild(m);l=document.createElement("input");l.type="submit";l.value=this.gettext("Get directions");g.appendChild(l);h.appendChild(g);f.appendChild(h);m.focus();if(typeof h.elements.from=="undefined"){h.elements.from=m}d(h,"submit",function(q){c(q);var r=this.elements.from.value;if(/\S/.test(r)){var o=(n.markerAddress==="")?new google.maps.LatLng(i,e):n.markerAddress,p={origin:r,region:j,destination:o,travelMode:google.maps.DirectionsTravelMode.DRIVING};n.dirService.route(p,function(u,s){var t=google.maps.DirectionsStatus;switch(s){case t.OK:n.dirPanel.setDirections(u);break;case t.ZERO_RESULTS:alert("No route could be found between the origin and destination.");break;case t.OVER_QUERY_LIMIT:alert("The webpage has gone over the requests limit in too short a period of time.");break;case t.REQUEST_DENIED:alert("The webpage is not allowed to use the directions service.");break;case t.INVALID_REQUEST:alert("Invalid directions request.");break;case t.NOT_FOUND:alert("Origin or destination was not found.");break;default:alert("A directions request could not be processed due to a server error. The request may succeed if you try again.");break}})}});if(m.value){b(h,"submit")}}}})();
2
  JavaScript for the WordPress plugin wp-flexible-map
3
  copyright (c) 2011-2012 WebAware Pty Ltd, released under LGPL v2.1
4
  */
5
+ function FlexibleMap(){var d,b,c,a=false;this.getMap=function(){return d};this.getCenter=function(){return b};this.setCenter=function(e){b=e;d.setCenter(b)};this.getKmlLayer=function(){return c};this.redrawOnce=function(){if(!a){a=true;this.redraw()}};this.showMap=function(e,f){b=new google.maps.LatLng(f[0],f[1]);d=new google.maps.Map(document.getElementById(e),{mapTypeId:this.mapTypeId,mapTypeControl:this.mapTypeControl,scaleControl:this.scaleControl,panControl:this.panControl,zoomControl:this.zoomControl,draggable:this.draggable,disableDoubleClickZoom:!this.dblclickZoom,scrollwheel:this.scrollwheel,streetViewControl:this.streetViewControl,navigationControlOptions:this.navigationControlOptions,center:b,zoom:this.zoom});return d};this.loadKmlMap=function(e){c=new google.maps.KmlLayer(e);c.setMap(d);google.maps.event.addListenerOnce(c,"defaultviewport_changed",function(){b=c.getDefaultViewport().getCenter()});return c};this.mapTypeId=google.maps.MapTypeId.ROADMAP;this.mapTypeControl=true;this.scaleControl=false;this.panControl=false;this.zoomControl=true;this.streetViewControl=false;this.scrollwheel=false;this.draggable=true;this.dblclickZoom=true;this.zoom=16;this.markerTitle="";this.markerDescription="";this.markerHTML="";this.markerLink="";this.markerShowInfo=true;this.markerDirections=false;this.markerDirectionsShow=false;this.markerDirectionsDefault="";this.markerAddress="";this.targetFix=true;this.navigationControlOptions={style:google.maps.NavigationControlStyle.SMALL};this.dirService=false;this.dirPanel=false;this.region="";this.locale="en";this.localeActive="en"}FlexibleMap.prototype=(function(){var d,c,b;if(document.addEventListener){d=function(f,e,g){f.addEventListener(e,g,false)};c=function(e){e.stopPropagation();e.preventDefault()};b=function(f,e){var g=document.createEvent("HTMLEvents");g.initEvent(e,true,true);f.dispatchEvent(g)}}else{if(document.attachEvent){d=function(e,f,g){e.attachEvent("on"+f,function(){g.call(e,window.event)})};c=function(e){e.cancelBubble=true;e.returnValue=0};b=function(f,e){var g=document.createEventObject();g.eventType=e;f.fireEvent("on"+e,g)}}}var a=(function(){function e(g){var h=g.charCodeAt(0),f=h.toString(16);if(h<256){return"\\x"+("00"+f).slice(-2)}return"\\u"+("0000"+f).slice(-4)}return function(f){return f.replace(/[\\\/"'&<>\x00-\x1f\x7f-\xa0\u2000-\u200f\u2028-\u202f]/g,e)}})();return{constructor:FlexibleMap,i18n:{en:{"Click for details":"Click for details",Directions:"Directions",From:"From","Get directions":"Get directions"}},setlocale:function(e){this.locale=e;if(e in this.i18n){this.localeActive=e}else{e=e.substr(0,2);if(e in this.i18n){this.localeActive=e}else{this.localeActive="en"}}return this.localeActive},gettext:function(f){var e=this.i18n[this.localeActive];if(f in e){return e[f]}return f},showKML:function(e,h,i){var g=this,f=document.getElementById(e),l=f.getAttribute("data-flxmap"),k=this.showMap(e,[0,0]),j=this.loadKmlMap(h);if(typeof i!="undefined"){google.maps.event.addListenerOnce(k,"tilesloaded",function(){k.setZoom(i);g.zoom=i})}if(this.markerDirections){this.startDirService(k)}google.maps.event.addListener(j,"click",function(r){var p=r.featureData;if(!p._flxmapOnce){p._flxmapOnce=true;if(g.targetFix){var o=/ target="_blank"/ig;p.description=p.description.replace(o,"");p.infoWindowHtml=p.infoWindowHtml.replace(o,"")}if(g.markerDirections){var n=r.latLng,q=n.lat()+","+n.lng()+",'"+a(p.name)+"'",m='<br /><a href="#" data-flxmap-fix-opera="1" onclick="'+l+".showDirections("+q+'); return false;">'+g.gettext("Directions")+"</a>";p.infoWindowHtml=p.infoWindowHtml.replace(/<\/div><\/div>$/i,m+"</div></div>")}}});if(window.opera&&this.markerDirections){d(f,"click",function(m){if(m.target.getAttribute("data-flxmap-fix-opera")){c(m)}})}},showMarker:function(h,g,m){var f=this.showMap(h,g),p=new google.maps.Marker({map:f,position:new google.maps.LatLng(m[0],m[1])});if(!this.markerTitle){this.markerTitle=this.markerAddress}if(this.markerTitle){var l,n,r,j,k,o,q=this,e=document.createElement("DIV");e.className="flxmap-infowin";p.setTitle(this.markerTitle);k=document.createElement("DIV");k.className="flxmap-marker-title";k.appendChild(document.createTextNode(this.markerTitle));e.appendChild(k);if(this.markerHTML){k=document.createElement("DIV");k.innerHTML=this.markerHTML;e.appendChild(k)}if(this.markerDescription||this.markerLink){k=document.createElement("DIV");k.className="flxmap-marker-link";if(this.markerDescription){r=this.markerDescription.split("\n");for(l=0,n=r.length;l<n;l++){if(l>0){k.appendChild(document.createElement("BR"))}k.appendChild(document.createTextNode(r[l]))}if(this.markerLink){k.appendChild(document.createElement("BR"))}}if(this.markerLink){o=document.createElement("A");o.href=this.markerLink;o.appendChild(document.createTextNode(this.gettext("Click for details")));k.appendChild(o)}e.appendChild(k)}if(this.markerDirections){k=document.createElement("DIV");k.className="flxmap-directions-link";o=document.createElement("A");o.href="#";o.dataLatitude=m[0];o.dataLongitude=m[1];o.dataTitle=this.markerTitle;d(o,"click",function(i){c(i);q.showDirections(this.dataLatitude,this.dataLongitude,this.dataTitle)});o.appendChild(document.createTextNode(this.gettext("Directions")));k.appendChild(o);e.appendChild(k)}if(this.markerDirections||this.markerDirectionsShow){this.startDirService(f);if(this.markerDirectionsShow){this.showDirections(m[0],m[1],this.markerTitle)}}j=new google.maps.InfoWindow({content:e});if(this.markerShowInfo){j.open(f,p)}google.maps.event.addListener(p,"click",function(){j.open(f,p)})}},showAddress:function(e,f){var g=this,h=new google.maps.Geocoder();this.markerAddress=f;if(this.markerTitle===""){this.markerTitle=f}h.geocode({address:f,region:this.region},function(k,j){if(j==google.maps.GeocoderStatus.OK){var i=k[0].geometry.location,l=[i.lat(),i.lng()];g.showMarker(e,l,l)}else{alert("Map address returns error: "+j)}})},redraw:function(){var f=this.getMap(),e=this.getKmlLayer();google.maps.event.trigger(f,"resize");if(e){f.fitBounds(e.getDefaultViewport())}else{f.setCenter(this.getCenter());f.setZoom(this.zoom)}},startDirService:function(e){if(!this.dirService){this.dirService=new google.maps.DirectionsService()}if(!this.dirPanel){this.dirPanel=new google.maps.DirectionsRenderer({map:e,panel:document.getElementById(this.markerDirections)})}},showDirections:function(i,e,k){var f=document.getElementById(this.markerDirections),h=document.createElement("form"),n=this,j=this.region||"",l,g,m;while(!!(g=f.lastChild)){f.removeChild(g)}g=document.createElement("p");g.appendChild(document.createTextNode(this.gettext("From")+": "));m=document.createElement("input");m.type="text";m.name="from";m.value=this.markerDirectionsDefault;g.appendChild(m);l=document.createElement("input");l.type="submit";l.value=this.gettext("Get directions");g.appendChild(l);h.appendChild(g);f.appendChild(h);if(typeof h.elements.from=="undefined"){h.elements.from=m}d(h,"submit",function(q){c(q);var r=this.elements.from.value;if(/\S/.test(r)){var o=(n.markerAddress==="")?new google.maps.LatLng(i,e):n.markerAddress,p={origin:r,region:j,destination:o,travelMode:google.maps.DirectionsTravelMode.DRIVING};n.dirService.route(p,function(u,s){var t=google.maps.DirectionsStatus;switch(s){case t.OK:n.dirPanel.setDirections(u);break;case t.ZERO_RESULTS:alert("No route could be found between the origin and destination.");break;case t.OVER_QUERY_LIMIT:alert("The webpage has gone over the requests limit in too short a period of time.");break;case t.REQUEST_DENIED:alert("The webpage is not allowed to use the directions service.");break;case t.INVALID_REQUEST:alert("Invalid directions request.");break;case t.NOT_FOUND:alert("Origin or destination was not found.");break;default:alert("A directions request could not be processed due to a server error. The request may succeed if you try again.");break}})}});if(m.value){b(h,"submit")}}}})();
flexible-map.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Flexible Map
4
  Plugin URI: http://snippets.webaware.com.au/wordpress-plugins/wp-flexible-map/
5
  Description: Embed Google Maps in pages and posts, either by centre coodinates or street address, or by URL to a Google Earth KML file.
6
- Version: 1.5.3
7
  Author: WebAware
8
  Author URI: http://www.webaware.com.au/
9
  */
@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
  if (!defined('FLXMAP_PLUGIN_ROOT')) {
29
  define('FLXMAP_PLUGIN_ROOT', dirname(__FILE__) . '/');
30
  define('FLXMAP_PLUGIN_NAME', basename(dirname(__FILE__)) . '/' . basename(__FILE__));
31
- define('FLXMAP_PLUGIN_VERSION', '1.5.3');
32
 
33
  // shortcode tags
34
  define('FLXMAP_PLUGIN_TAG_MAP', 'flexiblemap');
@@ -64,3 +64,16 @@ function flexmap_show_map($attrs) {
64
  $plugin = FlxMapPlugin::getInstance();
65
  echo $plugin->getMap($attrs);
66
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: Flexible Map
4
  Plugin URI: http://snippets.webaware.com.au/wordpress-plugins/wp-flexible-map/
5
  Description: Embed Google Maps in pages and posts, either by centre coodinates or street address, or by URL to a Google Earth KML file.
6
+ Version: 1.6.0
7
  Author: WebAware
8
  Author URI: http://www.webaware.com.au/
9
  */
28
  if (!defined('FLXMAP_PLUGIN_ROOT')) {
29
  define('FLXMAP_PLUGIN_ROOT', dirname(__FILE__) . '/');
30
  define('FLXMAP_PLUGIN_NAME', basename(dirname(__FILE__)) . '/' . basename(__FILE__));
31
+ define('FLXMAP_PLUGIN_VERSION', '1.6.0');
32
 
33
  // shortcode tags
34
  define('FLXMAP_PLUGIN_TAG_MAP', 'flexiblemap');
64
  $plugin = FlxMapPlugin::getInstance();
65
  echo $plugin->getMap($attrs);
66
  }
67
+
68
+ /**
69
+ * load the scripts required for the maps to work, e.g. for single-page AJAX websites
70
+ * @param array $locales optional: an array of required locale scripts
71
+ */
72
+ function flexmap_load_scripts($locales = array()) {
73
+ wp_enqueue_script('flxmap');
74
+
75
+ if (count($locales) > 0) {
76
+ $plugin = FlxMapPlugin::getInstance();
77
+ $plugin->setLocales($locales);
78
+ }
79
+ }
instructions.html CHANGED
@@ -59,6 +59,8 @@ many different markers all on the one map.</p>
59
  <dd>URL to link from the marker title, e.g. <em>link=&quot;http://example.com/&quot;</em></dd>
60
  <dt>description</dt>
61
  <dd>a description of the marker location (can have HTML links), e.g. <em>description=&quot;Lorem ipsum dolor sit amet&quot;</em></dd>
 
 
62
  <dt>directions</dt>
63
  <dd>show directions link in text bubble; by default, directions will be displayed underneath map, but you can specify the element ID for directions here.</dd>
64
  <dt>showdirections</dt>
59
  <dd>URL to link from the marker title, e.g. <em>link=&quot;http://example.com/&quot;</em></dd>
60
  <dt>description</dt>
61
  <dd>a description of the marker location (can have HTML links), e.g. <em>description=&quot;Lorem ipsum dolor sit amet&quot;</em></dd>
62
+ <dt>html</dt>
63
+ <dd>some simple HTML to add to the info window, e.g. <em>&lt;img src='http://example.com/logo.img' /&gt;</em></dd>
64
  <dt>directions</dt>
65
  <dd>show directions link in text bubble; by default, directions will be displayed underneath map, but you can specify the element ID for directions here.</dd>
66
  <dt>showdirections</dt>
readme.txt CHANGED
@@ -6,8 +6,8 @@ Author URI: http://www.webaware.com.au/
6
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6ZCY9PST8E4GQ
7
  Tags: google, maps, google maps, shortcode, kml
8
  Requires at least: 3.2.1
9
- Tested up to: 3.4.2
10
- Stable tag: 1.5.3
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -82,7 +82,8 @@ Either the center or the address paramater is required. If you provide both, the
82
  * **title**: title of the marker, displayed in a text bubble, e.g. *title="Adelaide Hills"*
83
  * **link**: URL to link from the marker title, e.g. *link="http://example.com/"*
84
  * **description**: a description of the marker location (can have HTML links), e.g. *description="Lorem ipsum dolor sit amet"*
85
- * **showinfo**: show the marker's info window when the map loads, from [true, false], e.g. *showinfo="true"*; default=true
 
86
  * **showdirections**: show directions when the map loads, e.g. *showdirections="true"*; default=false
87
  * **directionsfrom**: initial from: location for directions, e.g. *directionsfrom="Sydney"*
88
 
@@ -135,7 +136,11 @@ Using a KML file, you can have as many markers on a map as you like, with as muc
135
 
136
  = Why won't my KML map update when I edit the KML file? =
137
 
138
- Google Maps API caches the KML file, so it often won't get your new changes. To force a change, append a URL query parameter with a number and increment the number each time you change the KML file (known as a cache buster). A nice simple and commonly used parameter name is v (for version), like this: http://example.com/my-map.kml?v=2
 
 
 
 
139
 
140
  = Why won't the map show my place when I use the address parameter? =
141
 
@@ -192,8 +197,40 @@ And here's some sample jQuery code:
192
  // ... use map ...
193
  });`
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  == Changelog ==
196
 
 
 
 
 
 
197
  = 1.5.3 [2012-11-30] =
198
  * fixed: when parameters showdirections or directionsfrom were specified, but not directions, the directions panel was not added to page and a JavaScript error was generated
199
  * changed: bump version of Google Maps API to 3.10
6
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6ZCY9PST8E4GQ
7
  Tags: google, maps, google maps, shortcode, kml
8
  Requires at least: 3.2.1
9
+ Tested up to: 3.5.0
10
+ Stable tag: 1.6.0
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
82
  * **title**: title of the marker, displayed in a text bubble, e.g. *title="Adelaide Hills"*
83
  * **link**: URL to link from the marker title, e.g. *link="http://example.com/"*
84
  * **description**: a description of the marker location (can have HTML links), e.g. *description="Lorem ipsum dolor sit amet"*
85
+ * **html**: some simple HTML to add to the info window, e.g. *`<img src='http://example.com/logo.img' />`*
86
+ * **showinfo**: show the marker's info window when the map loads, from [true, false], e.g. *showinfo="true"*; default=true <dt>html</dt>
87
  * **showdirections**: show directions when the map loads, e.g. *showdirections="true"*; default=false
88
  * **directionsfrom**: initial from: location for directions, e.g. *directionsfrom="Sydney"*
89
 
136
 
137
  = Why won't my KML map update when I edit the KML file? =
138
 
139
+ Google Maps API caches the KML file, so it often won't get your new changes. To force a change, append a URL query parameter with a number (known as a cache buster) and increment the number each time you change the KML file. A nice simple and commonly used parameter name is v (for version), like this: http://example.com/my-map.kml?v=2
140
+
141
+ = What parts of KML are supported? =
142
+
143
+ The Google Maps API supports many commonly used KML elements, but has some restrictions. Read about [Google Maps support for KML](https://developers.google.com/kml/documentation/mapsSupport) in the developers' guide, and also see the list of [KML elements supported in Google Maps](https://developers.google.com/kml/documentation/kmlelementsinmaps).
144
 
145
  = Why won't the map show my place when I use the address parameter? =
146
 
197
  // ... use map ...
198
  });`
199
 
200
+ = Why won't the map load on my AJAX single-page website? =
201
+
202
+ The plugin only loads the required JavaScript scripts when it knows that they are needed. When your website uses AJAX to load a page, the normal WordPress footer action for that page doesn't happen, and the scripts aren't loaded. You can make the scripts load on every page by adding this snippet to the functions.php file in your theme:
203
+
204
+ `function my_preload_map_scripts() {
205
+ if (function_exists('flexmap_load_scripts')) {
206
+ flexmap_load_scripts();
207
+ }
208
+ }
209
+ add_action('wp_enqueue_scripts', 'my_preload_map_scripts', 20);`
210
+
211
+ To make it load locale scripts as well, e.g. for French and Chinese language text, add them to the function call like this:
212
+
213
+ `flexmap_load_scripts(array('fr', 'zh'));`
214
+
215
+ The plugin will detect when AJAX is being used via the [WordPress standard method](http://codex.wordpress.org/AJAX_in_Plugins), and adjust accordingly (but you still need to load the scripts as above). If another method is used, add `isajax='true'` to the shortcode parameters.
216
+
217
+ NB: currently, only AJAX methods that parse script tags will work correctly; this includes some [jQuery methods](http://stackoverflow.com/q/2203762/911083) (but [not all](http://stackoverflow.com/a/2699905/911083)). A future version of the plugin will be more AJAX friendly.
218
+
219
+
220
+ == Screenshots ==
221
+
222
+ 1. `[flexiblemap center="-32.918657,151.797894" title="Nobby's Head" zoom="14" width="500" height="400" directions="true" maptype="satellite"]`
223
+ 2. `[flexiblemap address="116 Beaumont Street Hamilton NSW Australia" title="Raj's Corner" description="SWMBO's favourite Indian diner" width="500" height="400" directions="true"]`
224
+ 3. `[flexiblemap src="http://snippets.webaware.com.au/maps/example-toronto.kml?v=2" width="500" height="400" maptype="satellite"]`
225
+ 4. `[flexiblemap center="-34.916721,138.828878" width="500" height="400" title="Adelaide Hills" directions="true" showdirections="true" directionsfrom="Adelaide"]`
226
+
227
  == Changelog ==
228
 
229
+ = 1.6.0 [2012-12-30] =
230
+ * added: themes can call function flexmap_load_scripts() to force load of scripts, e.g. on single-page AJAX websites
231
+ * added: can add HTML block to infowindow, e.g. images
232
+ * fixed: no auto-focus on directions search field, thus no auto-scroll page to last directions search field!
233
+
234
  = 1.5.3 [2012-11-30] =
235
  * fixed: when parameters showdirections or directionsfrom were specified, but not directions, the directions panel was not added to page and a JavaScript error was generated
236
  * changed: bump version of Google Maps API to 3.10
screenshot-1.jpg ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.jpg ADDED
Binary file
screenshot-4.png ADDED
Binary file