Flexible Map - Version 1.17.1

Version Description

Download this release

Release Info

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

Code changes from version 1.17.0 to 1.17.1

changelog.md CHANGED
@@ -2,6 +2,13 @@
2
 
3
  ## Changelog
4
 
 
 
 
 
 
 
 
5
  ### 1.17.0
6
 
7
  Released 2018-11-19
2
 
3
  ## Changelog
4
 
5
+ ### 1.17.1
6
+
7
+ Released 2019-05-04
8
+
9
+ * fixed: KML map with center but no zoom breaks the map
10
+ * fixed: recognize center coodinates with whitespace before and after the separating comma
11
+
12
  ### 1.17.0
13
 
14
  Released 2018-11-19
flexible-map.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Flexible Map
4
  Plugin URI: https://flexible-map.webaware.net.au/
5
  Description: Embed Google Maps shortcodes in pages and posts, either by centre coordinates or street address, or by URL to a Google Earth KML file. <a href="https://flexible-map.webaware.net.au/manual/getting-started/">Get started</a> with a simple shortcode. See the <a href="https://flexible-map.webaware.net.au/manual/attribute-reference/">complete attribute reference</a> for more details.
6
- Version: 1.17.0
7
  Author: WebAware
8
  Author URI: https://shop.webaware.com.au/
9
  Text Domain: wp-flexible-map
@@ -11,7 +11,7 @@ Domain Path: /languages/
11
  */
12
 
13
  /*
14
- copyright (c) 2011-2018 WebAware Pty Ltd (email : support@webaware.com.au)
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -37,7 +37,7 @@ define('FLXMAP_PLUGIN_FILE', __FILE__);
37
  define('FLXMAP_PLUGIN_ROOT', dirname(__FILE__) . '/');
38
  define('FLXMAP_PLUGIN_NAME', basename(dirname(__FILE__)) . '/' . basename(__FILE__));
39
  define('FLXMAP_PLUGIN_OPTIONS', 'flexible_map');
40
- define('FLXMAP_PLUGIN_VERSION', '1.17.0');
41
 
42
  // shortcode tags
43
  define('FLXMAP_PLUGIN_TAG_MAP', 'flexiblemap');
3
  Plugin Name: Flexible Map
4
  Plugin URI: https://flexible-map.webaware.net.au/
5
  Description: Embed Google Maps shortcodes in pages and posts, either by centre coordinates or street address, or by URL to a Google Earth KML file. <a href="https://flexible-map.webaware.net.au/manual/getting-started/">Get started</a> with a simple shortcode. See the <a href="https://flexible-map.webaware.net.au/manual/attribute-reference/">complete attribute reference</a> for more details.
6
+ Version: 1.17.1
7
  Author: WebAware
8
  Author URI: https://shop.webaware.com.au/
9
  Text Domain: wp-flexible-map
11
  */
12
 
13
  /*
14
+ copyright (c) 2011-2019 WebAware Pty Ltd (email : support@webaware.com.au)
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
37
  define('FLXMAP_PLUGIN_ROOT', dirname(__FILE__) . '/');
38
  define('FLXMAP_PLUGIN_NAME', basename(dirname(__FILE__)) . '/' . basename(__FILE__));
39
  define('FLXMAP_PLUGIN_OPTIONS', 'flexible_map');
40
+ define('FLXMAP_PLUGIN_VERSION', '1.17.1');
41
 
42
  // shortcode tags
43
  define('FLXMAP_PLUGIN_TAG_MAP', 'flexiblemap');
includes/class.FlxMapPlugin.php CHANGED
@@ -366,7 +366,7 @@ HTML;
366
  $marker = self::str2js(self::getCoordinates($attrs['marker']));
367
 
368
  if (isset($attrs['zoom']))
369
- $script .= " f.zoom = " . preg_replace('/\D/', '', $attrs['zoom']) . ";\n";
370
 
371
  if (!empty($attrs['title']))
372
  $script .= " f.markerTitle = \"{$this->unhtml($attrs['title'])}\";\n";
@@ -404,7 +404,7 @@ HTML;
404
  // add map based on address query
405
  else if (isset($attrs['address'])) {
406
  if (isset($attrs['zoom']))
407
- $script .= " f.zoom = " . preg_replace('/\D/', '', $attrs['zoom']) . ";\n";
408
 
409
  if (!empty($attrs['title']))
410
  $script .= " f.markerTitle = \"{$this->unhtml($attrs['title'])}\";\n";
@@ -575,9 +575,9 @@ HTML;
575
 
576
  if ($result->status !== 'OK') {
577
  if (!empty($result->error_message)) {
578
- throw new Exception(sprintf("error retrieving address: %s; %s", $result->status, $result->error_message));
579
  }
580
- throw new Exception(sprintf("error retrieving address: %s", $result->status));
581
  }
582
 
583
  // success, return array with latitude and longitude
@@ -629,7 +629,7 @@ HTML;
629
  */
630
  public static function isCoordinates($text) {
631
  // TODO: handle degrees minutes seconds, degrees minutes.decimal, NSEW
632
- return preg_match('/^-?[0-9]+(?:\.[0-9]+),\s*-?[0-9]+(?:\.[0-9]+)$/', $text);
633
  }
634
 
635
  /**
366
  $marker = self::str2js(self::getCoordinates($attrs['marker']));
367
 
368
  if (isset($attrs['zoom']))
369
+ $script .= ' f.zoom = ' . preg_replace('/\D/', '', $attrs['zoom']) . ";\n";
370
 
371
  if (!empty($attrs['title']))
372
  $script .= " f.markerTitle = \"{$this->unhtml($attrs['title'])}\";\n";
404
  // add map based on address query
405
  else if (isset($attrs['address'])) {
406
  if (isset($attrs['zoom']))
407
+ $script .= ' f.zoom = ' . preg_replace('/\D/', '', $attrs['zoom']) . ";\n";
408
 
409
  if (!empty($attrs['title']))
410
  $script .= " f.markerTitle = \"{$this->unhtml($attrs['title'])}\";\n";
575
 
576
  if ($result->status !== 'OK') {
577
  if (!empty($result->error_message)) {
578
+ throw new Exception(sprintf('error retrieving address: %s; %s', $result->status, $result->error_message));
579
  }
580
+ throw new Exception(sprintf('error retrieving address: %s', $result->status));
581
  }
582
 
583
  // success, return array with latitude and longitude
629
  */
630
  public static function isCoordinates($text) {
631
  // TODO: handle degrees minutes seconds, degrees minutes.decimal, NSEW
632
+ return preg_match('/^-?[0-9]+(?:\.[0-9]+)\s*,\s*-?[0-9]+(?:\.[0-9]+)$/', $text);
633
  }
634
 
635
  /**
js/flexible-map.js CHANGED
@@ -238,6 +238,10 @@ window.FlexibleMap = function () {
238
  */
239
 
240
  function resetCentre() {
 
 
 
 
241
  self.setCenter(new google.maps.LatLng(self.kmlCentre[0], self.kmlCentre[1]));
242
  }
243
  /**
238
  */
239
 
240
  function resetCentre() {
241
+ if (!self.zoom) {
242
+ map.fitBounds(kmlLayer.getDefaultViewport());
243
+ }
244
+
245
  self.setCenter(new google.maps.LatLng(self.kmlCentre[0], self.kmlCentre[1]));
246
  }
247
  /**
js/flexible-map.min.js CHANGED
@@ -1,4 +1,4 @@
1
  // Flexible Map
2
  // https://flexible-map.webaware.net.au/
3
 
4
- "use strict";window.FlexibleMap=function(){var e,t,i,r,o,n,a=!1;this.getMap=function(){return e},this.getCenter=function(){return t},this.setCenter=function(i){t=i,e.setCenter(t)},this.setMarkerLocation=function(e){i=e},this.getMarkerLocation=function(){return i},this.setMarkerPoint=function(e){r=e},this.getMarkerPoint=function(){return r},this.setMarkerInfowin=function(e){o=e},this.getMarkerInfowin=function(){return o},this.getKmlLayer=function(){return n},this.redrawOnce=function(){a||(a=!0,this.redraw())},this.showMap=function(i,r){t=new google.maps.LatLng(r[0],r[1]);var o={small:google.maps.ZoomControlStyle.SMALL,large:google.maps.ZoomControlStyle.LARGE,default:google.maps.ZoomControlStyle.DEFAULT},n=o.small;this.zoomControlStyle in o&&(n=o[this.zoomControlStyle]);var a={mapTypeId:this.mapTypeId,mapTypeControl:this.mapTypeControl,scaleControl:this.scaleControl,panControl:this.panControl,streetViewControl:this.streetViewControl,zoomControl:this.zoomControl,zoomControlOptions:{style:n},fullscreenControl:this.fullscreen,center:t,zoom:this.zoom};return a=function(e,t){if(void 0!==t.gestureHandling)e.gestureHandling=t.gestureHandling;else if(void 0===t.draggable&&void 0===t.dblclickZoom&&void 0===t.scrollwheel)e.gestureHandling="cooperative";else{var i=void 0===t.draggable||t.draggable,r=void 0!==t.dblclickZoom&&!t.draggable,o=void 0!==t.scrollwheel&&t.scrollwheel;i||!r||o?i&&!r&&o?e.gestureHandling="greedy":(e.draggable=i,e.disableDoubleClickZoom=r,e.scrollwheel=o):e.gestureHandling="none"}return e}(a,this),this.mapTypeIds&&(a.mapTypeControlOptions={mapTypeIds:this.mapTypeIds.split(",")}),e=new google.maps.Map(document.getElementById(i),a),this.mapTypeId in this.mapTypes&&e.mapTypes.set(this.mapTypeId,this.mapTypes[this.mapTypeId]._styled_map),e},this.loadKmlMap=function(i){var r=this,o={map:e,url:i};return this.kmlCentre&&(o.preserveViewport=!0,o.center=new google.maps.LatLng(this.kmlCentre[0],this.kmlCentre[1])),n=new google.maps.KmlLayer(o),google.maps.event.addListenerOnce(n,"defaultviewport_changed",this.kmlCentre?function(){r.setCenter(new google.maps.LatLng(r.kmlCentre[0],r.kmlCentre[1]))}:function(){t=n.getDefaultViewport().getCenter()}),n},!this.localised&&"flxmap"in window&&this.localise(),this.mapTypeId=google.maps.MapTypeId.ROADMAP,this.mapTypeControl=!0,this.scaleControl=!1,this.panControl=!1,this.zoomControl=!0,this.zoomControlStyle="small",this.streetViewControl=!1,this.fullscreen=!0,this.gestureHandling=void 0,this.scrollwheel=void 0,this.draggable=void 0,this.dblclickZoom=void 0,this.zoom=16,this.markerTitle="",this.markerDescription="",this.markerHTML="",this.markerLink="",this.markerLinkTarget="",this.markerLinkText=!1,this.markerIcon="",this.markerShowInfo=!0,this.markerAnimation="drop",this.markerDirections=!1,this.markerDirectionsShow=!1,this.markerDirectionsDefault="",this.markerAddress="",this.targetFix=!0,this.dirService=!1,this.dirRenderer=!1,this.dirDraggable=!1,this.dirSuppressMarkers=!1,this.dirShowSteps=!0,this.dirShowSearch=!0,this.dirTravelMode="driving",this.dirUnitSystem=void 0,this.region="",this.locale="en",this.localeActive=!1,this.kmlCentre=!1,this.kmlcache="none"},FlexibleMap.prototype=function(){function e(e){e.stopPropagation(),e.preventDefault()}var t="undefined"==typeof MutationObserver?function(){}:function(e,t){var i=document.getElementById(t).parentNode;function r(e){var t=window.getComputedStyle(e);return"none"===t.display||"hidden"===t.visibility}r(i)&&new MutationObserver(function(t,o){r(i)||(e.redrawOnce(),o.disconnect())}).observe(i,{attributes:!0,attributeFilter:["style"]})};return{constructor:FlexibleMap,i18n:{},mapTypes:{},localised:!1,localise:function(){if("i18n"in flxmap&&(FlexibleMap.prototype.i18n=flxmap.i18n),"mapTypes"in flxmap){var e=flxmap.mapTypes;for(var t in e)e[t]._styled_map=new google.maps.StyledMapType(e[t].styles,e[t].options);FlexibleMap.prototype.mapTypes=e}FlexibleMap.prototype.localised=!0},setlocale:function(e){return this.locale=e,e in this.i18n?this.localeActive=e:e.substr(0,2)in this.i18n?this.localeActive=e:this.localeActive=!1,this.localeActive},gettext:function(e){var t=this.localeActive;return t&&e in this.i18n[t]?this.i18n[t][e]:e},showKML:function(e,i,r){this.zoom=r;var o=this,n=document.getElementById(e).getAttribute("data-flxmap"),a=this.showMap(e,[0,0]),s=this.loadKmlMap(function(e,t){var i,r=/^(\d+)\s*(minute|hour|day)s?$/.exec(t);if(r){var o=(new Date).getTime(),n=+r[1];switch(r[2]){case"minute":n<5&&(n=5),i=o/(6e4*n);break;case"hour":i=o/(36e5*n);break;case"day":i=o/(864e5*n);break;default:i=!1}i&&(i=Math.floor(i),e+=(e.indexOf("?")>-1?"&":"?")+"nocache="+i)}return e}(i,this.kmlcache));t(this,e),void 0!==r&&google.maps.event.addListenerOnce(a,"zoom_changed",function(){a.setZoom(r),o.zoom=r}),(this.markerDirections||this.markerDirectionsShow)&&this.startDirService(a),google.maps.event.addListener(s,"click",function(e){var t=e.featureData;if(!t._flxmapOnce){if(t._flxmapOnce=!0,o.targetFix&&t.description){var i=/ target="_blank"/gi;t.description=t.description.replace(i,""),t.infoWindowHtml=t.infoWindowHtml.replace(i,"")}if(o.markerDirections){var r=e.latLng,a=r.lat()+","+r.lng()+",'"+function(){function e(e){var t=e.charCodeAt(0),i=t.toString(16);return t<256?"\\x"+("00"+i).slice(-2):"\\u"+("0000"+i).slice(-4)}return function(t){return t.replace(/[\\/"'&<>\x00-\x1f\x7f-\xa0\u2000-\u200f\u2028-\u202f]/g,e)}}(t.name)+"',true",s='<br /><a href="#" onclick="'+n+".showDirections("+a+'); return false;">'+o.gettext("Directions")+"</a>";t.infoWindowHtml=t.infoWindowHtml.replace(/<\/div><\/div>$/i,s+"</div></div>")}}})},showMarker:function(i,r,o){var n=this.showMap(i,r),a=new google.maps.LatLng(o[0],o[1]),s={map:n,position:a,icon:this.markerIcon},l=google.maps.Animation;switch(this.markerAnimation){case"drop":s.animation=l.DROP;break;case"bounce":s.animation=l.BOUNCE}var d=new google.maps.Marker(s);if(this.setMarkerPoint(d),this.setMarkerLocation(a),t(this,i),this.markerTitle||(this.markerTitle=this.markerAddress),this.markerTitle||this.markerHTML||this.markerDescription||this.markerLink||this.markerDirections){var c,m,h=this,p=document.createElement("DIV");if(p.className="flxmap-infowin",(c=document.createElement("DIV")).className="flxmap-marker-title",this.markerTitle&&(c.appendChild(document.createTextNode(this.markerTitle)),d.setTitle(this.markerTitle)),p.appendChild(c),this.markerHTML&&((c=document.createElement("DIV")).innerHTML=this.markerHTML,p.appendChild(c)),this.markerDescription||this.markerLink){if((c=document.createElement("DIV")).className="flxmap-marker-link",this.markerDescription){for(var g=this.markerDescription.split("\n"),u=0,f=g.length;u<f;u++)u>0&&c.appendChild(document.createElement("BR")),c.appendChild(document.createTextNode(g[u]));this.markerLink&&c.appendChild(document.createElement("BR"))}this.markerLink&&((m=document.createElement("A")).href=this.markerLink,this.markerLinkTarget&&(m.target=this.markerLinkTarget),m.appendChild(document.createTextNode(this.markerLinkText||this.gettext("Click for details"))),c.appendChild(m)),p.appendChild(c)}this.markerDirections&&((c=document.createElement("DIV")).className="flxmap-directions-link",(m=document.createElement("A")).href="#",m.dataLatitude=o[0],m.dataLongitude=o[1],m.addEventListener("click",function(t){e(t),h.showDirections(this.dataLatitude,this.dataLongitude,!0)}),m.appendChild(document.createTextNode(this.gettext("Directions"))),c.appendChild(m),p.appendChild(c));var k=new google.maps.InfoWindow({content:p});this.setMarkerInfowin(k),this.markerShowInfo&&google.maps.event.addListenerOnce(n,"tilesloaded",function(){k.open(n,d)}),google.maps.event.addListener(d,"click",function(){k.open(n,d)});var v=function(){h.updateGoogleLink()};google.maps.event.addListener(n,"idle",v),google.maps.event.addListener(n,"center_changed",v),google.maps.event.addListenerOnce(n,"tilesloaded",v)}(this.markerDirections||this.markerDirectionsShow)&&(this.startDirService(n),this.markerDirectionsShow&&this.showDirections(o[0],o[1],!1))},showAddress:function(e,t){var i=this,r=new google.maps.Geocoder;this.markerAddress=t,""===this.markerTitle&&(this.markerTitle=t),r.geocode({address:t,region:this.region},function(t,r){if(r===google.maps.GeocoderStatus.OK){var o=t[0].geometry.location,n=[o.lat(),o.lng()];i.showMarker(e,n,n)}else window.alert("Map address returns error: "+r)})},updateGoogleLink:function(){if("querySelectorAll"in document)try{for(var e=this.getMap().getDiv(),t=this.getMarkerLocation(),i=e.querySelectorAll("a[href*='maps.google.com/maps']:not([href*='mps_dialog']):not([href*='&q='])"),r=encodeURIComponent((this.markerAddress?this.markerAddress:this.markerTitle)+" @"+t.lat()+","+t.lng()),o=0,n=i.length;o<n;o++)i[o].href+="&mrt=loc&iwloc=A&q="+r}catch(e){}},redraw:function(){var e=this.getMap(),t=this.getKmlLayer();if(google.maps.event.trigger(e,"resize"),t)e.fitBounds(t.getDefaultViewport()),this.zoom&&e.setZoom(this.zoom);else{e.setCenter(this.getCenter()),e.setZoom(this.zoom);var i=this.getMarkerInfowin();i&&i.open(e,this.getMarkerPoint())}},startDirService:function(e){this.dirService||(this.dirService=new google.maps.DirectionsService),this.dirRenderer||(this.dirRenderer=new google.maps.DirectionsRenderer({map:e,draggable:this.dirDraggable,suppressMarkers:this.dirSuppressMarkers,panel:this.dirShowSteps?document.getElementById(this.markerDirectionsDiv):null}))},showDirections:function(t,i,r){var o=this;function n(e){var r={origin:e,destination:""===o.markerAddress?new google.maps.LatLng(t,i):o.markerAddress};switch(o.region&&(r.region=o.region),o.dirTravelMode){case"bicycling":r.travelMode=google.maps.TravelMode.BICYCLING;break;case"driving":r.travelMode=google.maps.TravelMode.DRIVING;break;case"transit":r.travelMode=google.maps.TravelMode.TRANSIT;break;case"walking":r.travelMode=google.maps.TravelMode.WALKING}switch(o.dirUnitSystem){case"imperial":r.unitSystem=google.maps.UnitSystem.IMPERIAL;break;case"metric":r.unitSystem=google.maps.UnitSystem.METRIC}o.dirService.route(r,a)}function a(e,t){var i=google.maps.DirectionsStatus;switch(t){case i.OK:o.dirRenderer.setDirections(e);break;case i.ZERO_RESULTS:window.alert("No route could be found between the origin and destination.");break;case i.OVER_QUERY_LIMIT:window.alert("The webpage has gone over the requests limit in too short a period of time.");break;case i.REQUEST_DENIED:window.alert("The webpage is not allowed to use the directions service.");break;case i.INVALID_REQUEST:window.alert("Invalid directions request.");break;case i.NOT_FOUND:window.alert("Origin or destination was not found.");break;default:window.alert("A directions request could not be processed due to a server error. The request may succeed if you try again.")}}this.markerDirectionsDiv&&this.dirShowSearch&&function(){var t,i,a=document.getElementById(o.markerDirectionsDiv),s=document.createElement("form");for(t=a.lastChild;t;t=a.lastChild)a.removeChild(t);(t=document.createElement("p")).appendChild(document.createTextNode(o.gettext("From")+": ")),(i=document.createElement("input")).type="text",i.name="from",i.value=o.markerDirectionsDefault,t.appendChild(i);var l=document.createElement("input");l.type="submit",l.value=o.gettext("Get directions"),t.appendChild(l),s.appendChild(t),a.appendChild(s),r&&i.focus(),s.addEventListener("submit",function(t){e(t);var i=this.elements.from.value;/\S/.test(i)&&n(i)})}(),this.markerDirectionsDefault&&n(this.markerDirectionsDefault)}}}();
1
  // Flexible Map
2
  // https://flexible-map.webaware.net.au/
3
 
4
+ "use strict";window.FlexibleMap=function(){var e,t,i,r,o,n,a=!1;this.getMap=function(){return e},this.getCenter=function(){return t},this.setCenter=function(i){t=i,e.setCenter(t)},this.setMarkerLocation=function(e){i=e},this.getMarkerLocation=function(){return i},this.setMarkerPoint=function(e){r=e},this.getMarkerPoint=function(){return r},this.setMarkerInfowin=function(e){o=e},this.getMarkerInfowin=function(){return o},this.getKmlLayer=function(){return n},this.redrawOnce=function(){a||(a=!0,this.redraw())},this.showMap=function(i,r){t=new google.maps.LatLng(r[0],r[1]);var o={small:google.maps.ZoomControlStyle.SMALL,large:google.maps.ZoomControlStyle.LARGE,default:google.maps.ZoomControlStyle.DEFAULT},n=o.small;this.zoomControlStyle in o&&(n=o[this.zoomControlStyle]);var a={mapTypeId:this.mapTypeId,mapTypeControl:this.mapTypeControl,scaleControl:this.scaleControl,panControl:this.panControl,streetViewControl:this.streetViewControl,zoomControl:this.zoomControl,zoomControlOptions:{style:n},fullscreenControl:this.fullscreen,center:t,zoom:this.zoom};return a=function(e,t){if(void 0!==t.gestureHandling)e.gestureHandling=t.gestureHandling;else if(void 0===t.draggable&&void 0===t.dblclickZoom&&void 0===t.scrollwheel)e.gestureHandling="cooperative";else{var i=void 0===t.draggable||t.draggable,r=void 0!==t.dblclickZoom&&!t.draggable,o=void 0!==t.scrollwheel&&t.scrollwheel;i||!r||o?i&&!r&&o?e.gestureHandling="greedy":(e.draggable=i,e.disableDoubleClickZoom=r,e.scrollwheel=o):e.gestureHandling="none"}return e}(a,this),this.mapTypeIds&&(a.mapTypeControlOptions={mapTypeIds:this.mapTypeIds.split(",")}),e=new google.maps.Map(document.getElementById(i),a),this.mapTypeId in this.mapTypes&&e.mapTypes.set(this.mapTypeId,this.mapTypes[this.mapTypeId]._styled_map),e},this.loadKmlMap=function(i){var r=this,o={map:e,url:i};return this.kmlCentre&&(o.preserveViewport=!0,o.center=new google.maps.LatLng(this.kmlCentre[0],this.kmlCentre[1])),n=new google.maps.KmlLayer(o),google.maps.event.addListenerOnce(n,"defaultviewport_changed",this.kmlCentre?function(){r.zoom||e.fitBounds(n.getDefaultViewport()),r.setCenter(new google.maps.LatLng(r.kmlCentre[0],r.kmlCentre[1]))}:function(){t=n.getDefaultViewport().getCenter()}),n},!this.localised&&"flxmap"in window&&this.localise(),this.mapTypeId=google.maps.MapTypeId.ROADMAP,this.mapTypeControl=!0,this.scaleControl=!1,this.panControl=!1,this.zoomControl=!0,this.zoomControlStyle="small",this.streetViewControl=!1,this.fullscreen=!0,this.gestureHandling=void 0,this.scrollwheel=void 0,this.draggable=void 0,this.dblclickZoom=void 0,this.zoom=16,this.markerTitle="",this.markerDescription="",this.markerHTML="",this.markerLink="",this.markerLinkTarget="",this.markerLinkText=!1,this.markerIcon="",this.markerShowInfo=!0,this.markerAnimation="drop",this.markerDirections=!1,this.markerDirectionsShow=!1,this.markerDirectionsDefault="",this.markerAddress="",this.targetFix=!0,this.dirService=!1,this.dirRenderer=!1,this.dirDraggable=!1,this.dirSuppressMarkers=!1,this.dirShowSteps=!0,this.dirShowSearch=!0,this.dirTravelMode="driving",this.dirUnitSystem=void 0,this.region="",this.locale="en",this.localeActive=!1,this.kmlCentre=!1,this.kmlcache="none"},FlexibleMap.prototype=function(){function e(e){e.stopPropagation(),e.preventDefault()}var t="undefined"==typeof MutationObserver?function(){}:function(e,t){var i=document.getElementById(t).parentNode;function r(e){var t=window.getComputedStyle(e);return"none"===t.display||"hidden"===t.visibility}r(i)&&new MutationObserver(function(t,o){r(i)||(e.redrawOnce(),o.disconnect())}).observe(i,{attributes:!0,attributeFilter:["style"]})};return{constructor:FlexibleMap,i18n:{},mapTypes:{},localised:!1,localise:function(){if("i18n"in flxmap&&(FlexibleMap.prototype.i18n=flxmap.i18n),"mapTypes"in flxmap){var e=flxmap.mapTypes;for(var t in e)e[t]._styled_map=new google.maps.StyledMapType(e[t].styles,e[t].options);FlexibleMap.prototype.mapTypes=e}FlexibleMap.prototype.localised=!0},setlocale:function(e){return this.locale=e,e in this.i18n?this.localeActive=e:e.substr(0,2)in this.i18n?this.localeActive=e:this.localeActive=!1,this.localeActive},gettext:function(e){var t=this.localeActive;return t&&e in this.i18n[t]?this.i18n[t][e]:e},showKML:function(e,i,r){this.zoom=r;var o=this,n=document.getElementById(e).getAttribute("data-flxmap"),a=this.showMap(e,[0,0]),s=this.loadKmlMap(function(e,t){var i,r=/^(\d+)\s*(minute|hour|day)s?$/.exec(t);if(r){var o=(new Date).getTime(),n=+r[1];switch(r[2]){case"minute":n<5&&(n=5),i=o/(6e4*n);break;case"hour":i=o/(36e5*n);break;case"day":i=o/(864e5*n);break;default:i=!1}i&&(i=Math.floor(i),e+=(e.indexOf("?")>-1?"&":"?")+"nocache="+i)}return e}(i,this.kmlcache));t(this,e),void 0!==r&&google.maps.event.addListenerOnce(a,"zoom_changed",function(){a.setZoom(r),o.zoom=r}),(this.markerDirections||this.markerDirectionsShow)&&this.startDirService(a),google.maps.event.addListener(s,"click",function(e){var t=e.featureData;if(!t._flxmapOnce){if(t._flxmapOnce=!0,o.targetFix&&t.description){var i=/ target="_blank"/gi;t.description=t.description.replace(i,""),t.infoWindowHtml=t.infoWindowHtml.replace(i,"")}if(o.markerDirections){var r=e.latLng,a=r.lat()+","+r.lng()+",'"+function(){function e(e){var t=e.charCodeAt(0),i=t.toString(16);return t<256?"\\x"+("00"+i).slice(-2):"\\u"+("0000"+i).slice(-4)}return function(t){return t.replace(/[\\/"'&<>\x00-\x1f\x7f-\xa0\u2000-\u200f\u2028-\u202f]/g,e)}}(t.name)+"',true",s='<br /><a href="#" onclick="'+n+".showDirections("+a+'); return false;">'+o.gettext("Directions")+"</a>";t.infoWindowHtml=t.infoWindowHtml.replace(/<\/div><\/div>$/i,s+"</div></div>")}}})},showMarker:function(i,r,o){var n=this.showMap(i,r),a=new google.maps.LatLng(o[0],o[1]),s={map:n,position:a,icon:this.markerIcon},l=google.maps.Animation;switch(this.markerAnimation){case"drop":s.animation=l.DROP;break;case"bounce":s.animation=l.BOUNCE}var d=new google.maps.Marker(s);if(this.setMarkerPoint(d),this.setMarkerLocation(a),t(this,i),this.markerTitle||(this.markerTitle=this.markerAddress),this.markerTitle||this.markerHTML||this.markerDescription||this.markerLink||this.markerDirections){var c,m,h=this,p=document.createElement("DIV");if(p.className="flxmap-infowin",(c=document.createElement("DIV")).className="flxmap-marker-title",this.markerTitle&&(c.appendChild(document.createTextNode(this.markerTitle)),d.setTitle(this.markerTitle)),p.appendChild(c),this.markerHTML&&((c=document.createElement("DIV")).innerHTML=this.markerHTML,p.appendChild(c)),this.markerDescription||this.markerLink){if((c=document.createElement("DIV")).className="flxmap-marker-link",this.markerDescription){for(var g=this.markerDescription.split("\n"),u=0,f=g.length;u<f;u++)u>0&&c.appendChild(document.createElement("BR")),c.appendChild(document.createTextNode(g[u]));this.markerLink&&c.appendChild(document.createElement("BR"))}this.markerLink&&((m=document.createElement("A")).href=this.markerLink,this.markerLinkTarget&&(m.target=this.markerLinkTarget),m.appendChild(document.createTextNode(this.markerLinkText||this.gettext("Click for details"))),c.appendChild(m)),p.appendChild(c)}this.markerDirections&&((c=document.createElement("DIV")).className="flxmap-directions-link",(m=document.createElement("A")).href="#",m.dataLatitude=o[0],m.dataLongitude=o[1],m.addEventListener("click",function(t){e(t),h.showDirections(this.dataLatitude,this.dataLongitude,!0)}),m.appendChild(document.createTextNode(this.gettext("Directions"))),c.appendChild(m),p.appendChild(c));var k=new google.maps.InfoWindow({content:p});this.setMarkerInfowin(k),this.markerShowInfo&&google.maps.event.addListenerOnce(n,"tilesloaded",function(){k.open(n,d)}),google.maps.event.addListener(d,"click",function(){k.open(n,d)});var v=function(){h.updateGoogleLink()};google.maps.event.addListener(n,"idle",v),google.maps.event.addListener(n,"center_changed",v),google.maps.event.addListenerOnce(n,"tilesloaded",v)}(this.markerDirections||this.markerDirectionsShow)&&(this.startDirService(n),this.markerDirectionsShow&&this.showDirections(o[0],o[1],!1))},showAddress:function(e,t){var i=this,r=new google.maps.Geocoder;this.markerAddress=t,""===this.markerTitle&&(this.markerTitle=t),r.geocode({address:t,region:this.region},function(t,r){if(r===google.maps.GeocoderStatus.OK){var o=t[0].geometry.location,n=[o.lat(),o.lng()];i.showMarker(e,n,n)}else window.alert("Map address returns error: "+r)})},updateGoogleLink:function(){if("querySelectorAll"in document)try{for(var e=this.getMap().getDiv(),t=this.getMarkerLocation(),i=e.querySelectorAll("a[href*='maps.google.com/maps']:not([href*='mps_dialog']):not([href*='&q='])"),r=encodeURIComponent((this.markerAddress?this.markerAddress:this.markerTitle)+" @"+t.lat()+","+t.lng()),o=0,n=i.length;o<n;o++)i[o].href+="&mrt=loc&iwloc=A&q="+r}catch(e){}},redraw:function(){var e=this.getMap(),t=this.getKmlLayer();if(google.maps.event.trigger(e,"resize"),t)e.fitBounds(t.getDefaultViewport()),this.zoom&&e.setZoom(this.zoom);else{e.setCenter(this.getCenter()),e.setZoom(this.zoom);var i=this.getMarkerInfowin();i&&i.open(e,this.getMarkerPoint())}},startDirService:function(e){this.dirService||(this.dirService=new google.maps.DirectionsService),this.dirRenderer||(this.dirRenderer=new google.maps.DirectionsRenderer({map:e,draggable:this.dirDraggable,suppressMarkers:this.dirSuppressMarkers,panel:this.dirShowSteps?document.getElementById(this.markerDirectionsDiv):null}))},showDirections:function(t,i,r){var o=this;function n(e){var r={origin:e,destination:""===o.markerAddress?new google.maps.LatLng(t,i):o.markerAddress};switch(o.region&&(r.region=o.region),o.dirTravelMode){case"bicycling":r.travelMode=google.maps.TravelMode.BICYCLING;break;case"driving":r.travelMode=google.maps.TravelMode.DRIVING;break;case"transit":r.travelMode=google.maps.TravelMode.TRANSIT;break;case"walking":r.travelMode=google.maps.TravelMode.WALKING}switch(o.dirUnitSystem){case"imperial":r.unitSystem=google.maps.UnitSystem.IMPERIAL;break;case"metric":r.unitSystem=google.maps.UnitSystem.METRIC}o.dirService.route(r,a)}function a(e,t){var i=google.maps.DirectionsStatus;switch(t){case i.OK:o.dirRenderer.setDirections(e);break;case i.ZERO_RESULTS:window.alert("No route could be found between the origin and destination.");break;case i.OVER_QUERY_LIMIT:window.alert("The webpage has gone over the requests limit in too short a period of time.");break;case i.REQUEST_DENIED:window.alert("The webpage is not allowed to use the directions service.");break;case i.INVALID_REQUEST:window.alert("Invalid directions request.");break;case i.NOT_FOUND:window.alert("Origin or destination was not found.");break;default:window.alert("A directions request could not be processed due to a server error. The request may succeed if you try again.")}}this.markerDirectionsDiv&&this.dirShowSearch&&function(){var t,i,a=document.getElementById(o.markerDirectionsDiv),s=document.createElement("form");for(t=a.lastChild;t;t=a.lastChild)a.removeChild(t);(t=document.createElement("p")).appendChild(document.createTextNode(o.gettext("From")+": ")),(i=document.createElement("input")).type="text",i.name="from",i.value=o.markerDirectionsDefault,t.appendChild(i);var l=document.createElement("input");l.type="submit",l.value=o.gettext("Get directions"),t.appendChild(l),s.appendChild(t),a.appendChild(s),r&&i.focus(),s.addEventListener("submit",function(t){e(t);var i=this.elements.from.value;/\S/.test(i)&&n(i)})}(),this.markerDirectionsDefault&&n(this.markerDirectionsDefault)}}}();
readme.txt CHANGED
@@ -6,8 +6,8 @@ Author URI: https://shop.webaware.com.au/
6
  Donate link: https://shop.webaware.com.au/donations/?donation_for=Flexible+Map
7
  Tags: google, map, maps, google maps, kml
8
  Requires at least: 4.0
9
- Tested up to: 5.0
10
- Stable tag: 1.17.0
11
  Requires PHP: 5.3
12
  License: GPLv2 or later
13
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -228,19 +228,17 @@ Either turn off CloudFlare Rocketscript :) or install the [Flxmap No Rocketscrip
228
 
229
  ## Upgrade Notice
230
 
231
- ### 1.17.0
232
 
233
- track the latest stable version of the Google Maps API; remove support for ancient browsers (Opera 12, IE < 11); fix KML maps with zoom when hidden in a tab
234
 
235
  ## Changelog
236
 
237
  The full changelog can be found [on GitHub](https://github.com/webaware/flexible-map/blob/master/changelog.md). Recent entries:
238
 
239
- ### 1.17.0
240
 
241
- Released 2018-11-19
242
 
243
- * fixed: map tiles don't redraw for KML maps with zoom when hidden in a tab / accordion
244
- * changed: use the [current quarterly (stable) version of the Google Maps API](https://developers.google.com/maps/documentation/javascript/versions)
245
- * changed: remove support for ancient browsers (Opera 12, IE < 11)
246
- * tested: WordPress 5.0 (no Gutenberg block yet; maybe next release!)
6
  Donate link: https://shop.webaware.com.au/donations/?donation_for=Flexible+Map
7
  Tags: google, map, maps, google maps, kml
8
  Requires at least: 4.0
9
+ Tested up to: 5.2
10
+ Stable tag: 1.17.1
11
  Requires PHP: 5.3
12
  License: GPLv2 or later
13
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
228
 
229
  ## Upgrade Notice
230
 
231
+ ### 1.17.1
232
 
233
+ KML map with center but no zoom no longer breaks the map; recognizes center coodinates with whitespace before and after the separating comma
234
 
235
  ## Changelog
236
 
237
  The full changelog can be found [on GitHub](https://github.com/webaware/flexible-map/blob/master/changelog.md). Recent entries:
238
 
239
+ ### 1.17.1
240
 
241
+ Released 2019-05-04
242
 
243
+ * fixed: KML map with center but no zoom breaks the map
244
+ * fixed: recognize center coordinates with whitespace before and after the separating comma