Flexible Map - Version 1.5.2

Version Description

[2012-10-12] = * fixed: KML maps broken; KMLLayer status_changed event unreliable, use defaultviewport_changed event instead (possible Google Maps API change)

Download this release

Release Info

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

Code changes from version 1.5.1 to 1.5.2

Files changed (4) hide show
  1. flexible-map.js +33 -25
  2. flexible-map.min.js +1 -1
  3. flexible-map.php +2 -2
  4. readme.txt +9 -6
flexible-map.js CHANGED
@@ -19,7 +19,7 @@ function FlexibleMap() {
19
  };
20
 
21
  /**
22
- * get the centrepoint of the map at time of creation
23
  * @return {google.maps.LatLng}
24
  */
25
  this.getCenter = function() {
@@ -91,7 +91,7 @@ function FlexibleMap() {
91
  kmlLayer.setMap(map);
92
 
93
  // listen for KML loaded
94
- google.maps.event.addListenerOnce(kmlLayer, "status_changed", function() {
95
  // update centre of map from bounds on KML layer
96
  centre = kmlLayer.getDefaultViewport().getCenter();
97
  });
@@ -168,26 +168,37 @@ FlexibleMap.prototype = (function() {
168
  }
169
 
170
  /**
171
- * escape some text for inserting into HTML as an attribute value delimited by quotes (")
 
172
  * @param {String} text
173
  * @return {String}
174
  */
175
- function escAttr(text) {
176
- // add text to a P element and extract HTML
177
- var element = document.createElement("p");
178
- element.appendChild(document.createTextNode(text));
179
 
180
- // convert non-JS safe characters to Unicode hex
181
- return element.innerHTML.replace(/[\\\/"'\x00-\x1f\x7f-\xa0\u2000-\u200f\u2028-\u202f]/g, toUnicodeHex);
182
- }
 
 
 
 
 
183
 
184
- /**
185
- * encode character as Unicode hex
186
- */
187
- function toUnicodeHex(ch) {
188
- var c = ch.charCodeAt(0);
189
- return "\\u" + ("0000" + c.toString(16)).slice(-4);
190
- }
 
 
 
 
 
 
 
 
191
 
192
  return {
193
  constructor: FlexibleMap,
@@ -254,7 +265,7 @@ FlexibleMap.prototype = (function() {
254
  showKML: function(divID, kmlFileURL, zoom) {
255
  var self = this,
256
  mapDiv = document.getElementById(divID),
257
- varName,
258
  map = this.showMap(divID, [0, 0]),
259
  kmlLayer = this.loadKmlMap(kmlFileURL);
260
 
@@ -268,11 +279,8 @@ FlexibleMap.prototype = (function() {
268
  }
269
 
270
  // add a directions service if needed
271
- if (this.markerDirections || this.markerDirectionsShow) {
272
  this.startDirService(map);
273
-
274
- // grab name of variable holding this object instance, need it for directions links
275
- varName = mapDiv.getAttribute("data-flxmap");
276
  }
277
 
278
  // customise the infowindow as required; can do this on click event on KML layer (thanks, Stack Overflow!)
@@ -296,7 +304,7 @@ FlexibleMap.prototype = (function() {
296
  // if we're showing directions, add directions link to marker description
297
  if (self.markerDirections) {
298
  var latLng = kmlEvent.latLng,
299
- params = latLng.lat() + ',' + latLng.lng() + ",'" + escAttr(featureData.name) + "'",
300
  a = '<br /><a href="#" data-flxmap-fix-opera="1" onclick="' + varName + '.showDirections(' + params + '); return false;">' + self.gettext("Directions") + '</a>';
301
 
302
  featureData.infoWindowHtml = featureData.infoWindowHtml.replace(/<\/div><\/div>$/i, a + "</div></div>");
@@ -442,13 +450,13 @@ FlexibleMap.prototype = (function() {
442
  kmlLayer = this.getKmlLayer();
443
 
444
  google.maps.event.trigger(map, "resize");
445
- map.setCenter(this.getCenter());
446
 
447
- // if map is KML, must refit to computed bounds, else use zoom setting
448
  if (kmlLayer) {
449
  map.fitBounds(kmlLayer.getDefaultViewport());
450
  }
451
  else {
 
452
  map.setZoom(this.zoom);
453
  }
454
  },
19
  };
20
 
21
  /**
22
+ * get the centrepoint of the map at creation, or via setCenter()
23
  * @return {google.maps.LatLng}
24
  */
25
  this.getCenter = function() {
91
  kmlLayer.setMap(map);
92
 
93
  // listen for KML loaded
94
+ google.maps.event.addListenerOnce(kmlLayer, "defaultviewport_changed", function() {
95
  // update centre of map from bounds on KML layer
96
  centre = kmlLayer.getDefaultViewport().getCenter();
97
  });
168
  }
169
 
170
  /**
171
+ * encode special JavaScript characters, so text is safe when building JavaScript/HTML dynamically
172
+ * NB: conservatively assumes that HTML special characters are unsafe, and encodes them too
173
  * @param {String} text
174
  * @return {String}
175
  */
176
+ var encodeJS = (function() {
 
 
 
177
 
178
+ /**
179
+ * encode character as Unicode hexadecimal escape sequence
180
+ * @param {String} ch character to encode
181
+ * @return {String}
182
+ */
183
+ function toUnicodeHex(ch) {
184
+ var c = ch.charCodeAt(0),
185
+ s = c.toString(16);
186
 
187
+ // see if we can use 2-digit hex code
188
+ if (c < 0x100) {
189
+ return "\\x" + ("00" + s).slice(-2);
190
+ }
191
+
192
+ // must use 4-digit hex code
193
+ return "\\u" + ("0000" + s).slice(-4);
194
+ }
195
+
196
+ return function(text) {
197
+ // search for JavaScript and HTML special characters, convert to Unicode hex
198
+ return text.replace(/[\\\/"'&<>\x00-\x1f\x7f-\xa0\u2000-\u200f\u2028-\u202f]/g, toUnicodeHex);
199
+ };
200
+
201
+ })();
202
 
203
  return {
204
  constructor: FlexibleMap,
265
  showKML: function(divID, kmlFileURL, zoom) {
266
  var self = this,
267
  mapDiv = document.getElementById(divID),
268
+ varName = mapDiv.getAttribute("data-flxmap"),
269
  map = this.showMap(divID, [0, 0]),
270
  kmlLayer = this.loadKmlMap(kmlFileURL);
271
 
279
  }
280
 
281
  // add a directions service if needed
282
+ if (this.markerDirections) {
283
  this.startDirService(map);
 
 
 
284
  }
285
 
286
  // customise the infowindow as required; can do this on click event on KML layer (thanks, Stack Overflow!)
304
  // if we're showing directions, add directions link to marker description
305
  if (self.markerDirections) {
306
  var latLng = kmlEvent.latLng,
307
+ params = latLng.lat() + ',' + latLng.lng() + ",'" + encodeJS(featureData.name) + "'",
308
  a = '<br /><a href="#" data-flxmap-fix-opera="1" onclick="' + varName + '.showDirections(' + params + '); return false;">' + self.gettext("Directions") + '</a>';
309
 
310
  featureData.infoWindowHtml = featureData.infoWindowHtml.replace(/<\/div><\/div>$/i, a + "</div></div>");
450
  kmlLayer = this.getKmlLayer();
451
 
452
  google.maps.event.trigger(map, "resize");
 
453
 
454
+ // if map is KML, must refit to computed bounds, else use centre and zoom setting
455
  if (kmlLayer) {
456
  map.fitBounds(kmlLayer.getDefaultViewport());
457
  }
458
  else {
459
+ map.setCenter(this.getCenter());
460
  map.setZoom(this.zoom);
461
  }
462
  },
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,"status_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 e,c,a;if(document.addEventListener){e=function(g,f,h){g.addEventListener(f,h,false)};c=function(f){f.stopPropagation();f.preventDefault()};a=function(g,f){var h=document.createEvent("HTMLEvents");h.initEvent(f,true,true);g.dispatchEvent(h)}}else{if(document.attachEvent){e=function(f,g,h){f.attachEvent("on"+g,function(){h.call(f,window.event)})};c=function(f){f.cancelBubble=true;f.returnValue=0};a=function(g,f){var h=document.createEventObject();h.eventType=f;g.fireEvent("on"+f,h)}}}function b(g){var f=document.createElement("p");f.appendChild(document.createTextNode(g));return f.innerHTML.replace(/[\\\/"'\x00-\x1f\x7f-\xa0\u2000-\u200f\u2028-\u202f]/g,d)}function d(f){var g=f.charCodeAt(0);return"\\u"+("0000"+g.toString(16)).slice(-4)}return{constructor:FlexibleMap,i18n:{en:{"Click for details":"Click for details",Directions:"Directions",From:"From","Get directions":"Get directions"}},setlocale:function(f){this.locale=f;if(f in this.i18n){this.localeActive=f}else{f=f.substr(0,2);if(f in this.i18n){this.localeActive=f}else{this.localeActive="en"}}return this.localeActive},gettext:function(g){var f=this.i18n[this.localeActive];if(g in f){return f[g]}return""},showKML:function(f,i,j){var h=this,g=document.getElementById(f),m,l=this.showMap(f,[0,0]),k=this.loadKmlMap(i);if(typeof j!="undefined"){google.maps.event.addListenerOnce(l,"tilesloaded",function(){l.setZoom(j);h.zoom=j})}if(this.markerDirections||this.markerDirectionsShow){this.startDirService(l);m=g.getAttribute("data-flxmap")}google.maps.event.addListener(k,"click",function(s){var q=s.featureData;if(!q._flxmapOnce){q._flxmapOnce=true;if(h.targetFix){var p=/ target="_blank"/ig;q.description=q.description.replace(p,"");q.infoWindowHtml=q.infoWindowHtml.replace(p,"")}if(h.markerDirections){var o=s.latLng,r=o.lat()+","+o.lng()+",'"+b(q.name)+"'",n='<br /><a href="#" data-flxmap-fix-opera="1" onclick="'+m+".showDirections("+r+'); return false;">'+h.gettext("Directions")+"</a>";q.infoWindowHtml=q.infoWindowHtml.replace(/<\/div><\/div>$/i,n+"</div></div>")}}});if(window.opera&&this.markerDirections){e(g,"click",function(n){if(n.target.getAttribute("data-flxmap-fix-opera")){c(n)}})}},showMarker:function(j,h,n){var g=this.showMap(j,h),q=new google.maps.Marker({map:g,position:new google.maps.LatLng(n[0],n[1])});if(!this.markerTitle){this.markerTitle=this.markerAddress}if(this.markerTitle){var m,o,s,k,l,p,r=this,f=document.createElement("DIV");f.className="flxmap-infowin";q.setTitle(this.markerTitle);l=document.createElement("DIV");l.className="flxmap-marker-title";l.appendChild(document.createTextNode(this.markerTitle));f.appendChild(l);if(this.markerDescription||this.markerLink){l=document.createElement("DIV");l.className="flxmap-marker-link";if(this.markerDescription){s=this.markerDescription.split("\n");for(m=0,o=s.length;m<o;m++){if(m>0){l.appendChild(document.createElement("BR"))}l.appendChild(document.createTextNode(s[m]))}if(this.markerLink){l.appendChild(document.createElement("BR"))}}if(this.markerLink){p=document.createElement("A");p.href=this.markerLink;p.appendChild(document.createTextNode(this.gettext("Click for details")));l.appendChild(p)}f.appendChild(l)}if(this.markerDirections){l=document.createElement("DIV");l.className="flxmap-directions-link";p=document.createElement("A");p.href="#";p.dataLatitude=n[0];p.dataLongitude=n[1];p.dataTitle=this.markerTitle;e(p,"click",function(i){c(i);r.showDirections(this.dataLatitude,this.dataLongitude,this.dataTitle)});p.appendChild(document.createTextNode(this.gettext("Directions")));l.appendChild(p);f.appendChild(l)}if(this.markerDirections||this.markerDirectionsShow){this.startDirService(g);if(this.markerDirectionsShow){this.showDirections(n[0],n[1],this.markerTitle)}}k=new google.maps.InfoWindow({content:f});if(this.markerShowInfo){k.open(g,q)}google.maps.event.addListener(q,"click",function(){k.open(g,q)})}},showAddress:function(f,g){var h=this,i=new google.maps.Geocoder();this.markerAddress=g;if(this.markerTitle===""){this.markerTitle=g}i.geocode({address:g,region:this.region},function(l,k){if(k==google.maps.GeocoderStatus.OK){var j=l[0].geometry.location,m=[j.lat(),j.lng()];h.showMarker(f,m,m)}else{alert("Map address returns error: "+k)}})},redraw:function(){var g=this.getMap(),f=this.getKmlLayer();google.maps.event.trigger(g,"resize");g.setCenter(this.getCenter());if(f){g.fitBounds(f.getDefaultViewport())}else{g.setZoom(this.zoom)}},startDirService:function(f){if(!this.dirService){this.dirService=new google.maps.DirectionsService()}if(!this.dirPanel){this.dirPanel=new google.maps.DirectionsRenderer({map:f,panel:document.getElementById(this.markerDirections)})}},showDirections:function(j,f,l){var g=document.getElementById(this.markerDirections),i=document.createElement("form"),o=this,k=this.region||"",m,h,n;while(!!(h=g.lastChild)){g.removeChild(h)}h=document.createElement("p");h.appendChild(document.createTextNode(this.gettext("From")+": "));n=document.createElement("input");n.type="text";n.name="from";n.value=this.markerDirectionsDefault;h.appendChild(n);m=document.createElement("input");m.type="submit";m.value=this.gettext("Get directions");h.appendChild(m);i.appendChild(h);g.appendChild(i);n.focus();if(typeof i.elements.from=="undefined"){i.elements.from=n}e(i,"submit",function(r){c(r);var s=this.elements.from.value;if(/\S/.test(s)){var p=(o.markerAddress==="")?new google.maps.LatLng(j,f):o.markerAddress,q={origin:s,region:k,destination:p,travelMode:google.maps.DirectionsTravelMode.DRIVING};o.dirService.route(q,function(v,t){var u=google.maps.DirectionsStatus;switch(t){case u.OK:o.dirPanel.setDirections(v);break;case u.ZERO_RESULTS:alert("No route could be found between the origin and destination.");break;case u.OVER_QUERY_LIMIT:alert("The webpage has gone over the requests limit in too short a period of time.");break;case u.REQUEST_DENIED:alert("The webpage is not allowed to use the directions service.");break;case u.INVALID_REQUEST:alert("Invalid directions request.");break;case u.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(n.value){a(i,"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.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")}}}})();
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.1
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.1');
32
 
33
  // shortcode tags
34
  define('FLXMAP_PLUGIN_TAG_MAP', 'flexiblemap');
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.2
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.5.2');
32
 
33
  // shortcode tags
34
  define('FLXMAP_PLUGIN_TAG_MAP', 'flexiblemap');
readme.txt CHANGED
@@ -5,9 +5,9 @@ Plugin URI: http://snippets.webaware.com.au/wordpress-plugins/wp-flexible-map/
5
  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.0.1
9
  Tested up to: 3.4.2
10
- Stable tag: 1.5.1
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -68,7 +68,7 @@ To add a Flexible Map to a post or a page, add a shortcode [flexiblemap] and giv
68
  * **scrollwheel**: enable zoom with mouse scroll wheel, from [true, false], e.g. *scrollwheel="true"*; default=false
69
  * **draggable**: enable dragging to pan, from [true, false], e.g. *draggable="true"*; default=true
70
  * **dblclickzoom**: enable double-clicking to zoom, from [true, false], e.g. *dblclickzoom="true"*; default=true
71
- * **directions**: show directions link in text bubble; by default, directions will be displayed underneath map, but you can specify the element ID for directions here
72
  * **region**: specify region to help localise address searches for street address map and directions, taken from the list of [ccTLD](http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains) (without the .), e.g. *region="au"*
73
  * **locale**: use a specific locale (language) for messages like the text of the Directions link, e.g. *locale="nl-BE"*
74
 
@@ -83,8 +83,8 @@ Either the center or the address paramater is required. If you provide both, the
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
87
- * **directionsfrom**: initial from: location for directions
88
 
89
  *Samples*:
90
  `[flexiblemap center="-34.916721,138.828878" width="500" height="400" zoom="9" title="Adelaide Hills" description="The Adelaide Hills are repleat with wineries."]
@@ -194,13 +194,16 @@ And here's some sample jQuery code:
194
 
195
  == Changelog ==
196
 
 
 
 
197
  = 1.5.1 [2012-09-30] =
198
  * changed: tighten up FlexibleMap API to keep private members private (in case they change later)
199
 
200
  = 1.5.0 [2012-09-29] =
201
  * added: new shortcode attribute "id" which will be used for the container div, instead of the random unique div id
202
  * added: FlexibleMap object is accessible via global variable with name derived from container div id (e.g. if you need to access the Google Maps map object in your own scripts)
203
- * added: redraw() and redrawOnce() methods, for when the map needs to be redrawn correctly (e.g. when hidden then revealed)
204
  * added: KML maps support directions (sponsored by [Roger Los](http://www.rogerlos.com/) -- thanks!)
205
 
206
  = 1.4.1 [2012-09-11] =
5
  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.2
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
68
  * **scrollwheel**: enable zoom with mouse scroll wheel, from [true, false], e.g. *scrollwheel="true"*; default=false
69
  * **draggable**: enable dragging to pan, from [true, false], e.g. *draggable="true"*; default=true
70
  * **dblclickzoom**: enable double-clicking to zoom, from [true, false], e.g. *dblclickzoom="true"*; default=true
71
+ * **directions**: show directions link in text bubble; by default, directions will be displayed underneath map, but you can specify the element ID for directions here, e.g. *directions="true", directions="my-dir-id"*; default=false
72
  * **region**: specify region to help localise address searches for street address map and directions, taken from the list of [ccTLD](http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains) (without the .), e.g. *region="au"*
73
  * **locale**: use a specific locale (language) for messages like the text of the Directions link, e.g. *locale="nl-BE"*
74
 
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
 
89
  *Samples*:
90
  `[flexiblemap center="-34.916721,138.828878" width="500" height="400" zoom="9" title="Adelaide Hills" description="The Adelaide Hills are repleat with wineries."]
194
 
195
  == Changelog ==
196
 
197
+ = 1.5.2 [2012-10-12] =
198
+ * fixed: KML maps broken; KMLLayer status_changed event unreliable, use defaultviewport_changed event instead (possible Google Maps API change)
199
+
200
  = 1.5.1 [2012-09-30] =
201
  * changed: tighten up FlexibleMap API to keep private members private (in case they change later)
202
 
203
  = 1.5.0 [2012-09-29] =
204
  * added: new shortcode attribute "id" which will be used for the container div, instead of the random unique div id
205
  * added: FlexibleMap object is accessible via global variable with name derived from container div id (e.g. if you need to access the Google Maps map object in your own scripts)
206
+ * added: redraw() and redrawOnce() methods, for when the map needs to be redrawn correctly (e.g. when initially hidden then revealed)
207
  * added: KML maps support directions (sponsored by [Roger Los](http://www.rogerlos.com/) -- thanks!)
208
 
209
  = 1.4.1 [2012-09-11] =