Flexible Map - Version 1.5.1

Version Description

[2012-09-30] = * changed: tighten up FlexibleMap API to keep private members private (in case they change later)

Download this release

Release Info

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

Code changes from version 1.5.0 to 1.5.1

Files changed (4) hide show
  1. flexible-map.js +61 -66
  2. flexible-map.min.js +1 -1
  3. flexible-map.php +2 -2
  4. readme.txt +4 -1
flexible-map.js CHANGED
@@ -18,14 +18,6 @@ function FlexibleMap() {
18
  return map;
19
  };
20
 
21
- /**
22
- * set the Google Maps API Map object
23
- * @param {google.maps.Map} map
24
- */
25
- this.setMap = function(newMap) {
26
- map = newMap;
27
- };
28
-
29
  /**
30
  * get the centrepoint of the map at time of creation
31
  * @return {google.maps.LatLng}
@@ -35,11 +27,12 @@ function FlexibleMap() {
35
  };
36
 
37
  /**
38
- * set the centrepoint of the map at time of creation
39
  * @param {google.maps.LatLng} latLng
40
  */
41
  this.setCenter = function(latLng) {
42
  centre = latLng;
 
43
  };
44
 
45
  /**
@@ -50,14 +43,6 @@ function FlexibleMap() {
50
  return kmlLayer;
51
  };
52
 
53
- /**
54
- * record the map's KML layer
55
- * @param {google.maps.KmlLayer} layer
56
- */
57
- this.setKmlLayer = function(layer) {
58
- kmlLayer = layer;
59
- };
60
-
61
  /**
62
  * if map starts life hidden and needs to be redrawn when revealed, this function will perform that redraw *once*
63
  */
@@ -68,6 +53,52 @@ function FlexibleMap() {
68
  }
69
  };
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  // set map defaults
72
  this.mapTypeId = google.maps.MapTypeId.ROADMAP;
73
  this.mapTypeControl = true; // no control for changing map type
@@ -217,30 +248,24 @@ FlexibleMap.prototype = (function() {
217
  /**
218
  * show a map based on a KML file
219
  * @param {String} divID the ID of the div that will contain the map
220
- * @param {String} kmlFile path to the KML file to load
221
  * @param {Number} zoom [optional] zoom level
222
  */
223
- showKML: function(divID, kmlFile, zoom) {
224
  var self = this,
225
  mapDiv = document.getElementById(divID),
226
  varName,
227
  map = this.showMap(divID, [0, 0]),
228
- kmlLayer = new google.maps.KmlLayer(kmlFile);
229
-
230
- this.setKmlLayer(kmlLayer);
231
- kmlLayer.setMap(map);
232
-
233
- // listen for KML loaded
234
- google.maps.event.addListenerOnce(map, "tilesloaded", function() {
235
- // grab true centre of map
236
- self.setCenter(map.getCenter());
237
 
238
- // set zoom if specified
239
- if (typeof zoom != "undefined") {
 
 
240
  map.setZoom(zoom);
241
  self.zoom = zoom;
242
- }
243
- });
244
 
245
  // add a directions service if needed
246
  if (this.markerDirections || this.markerDirectionsShow) {
@@ -272,7 +297,7 @@ FlexibleMap.prototype = (function() {
272
  if (self.markerDirections) {
273
  var latLng = kmlEvent.latLng,
274
  params = latLng.lat() + ',' + latLng.lng() + ",'" + escAttr(featureData.name) + "'",
275
- a = '<br /><a href="#" data-flxmap-isdir="1" onclick="' + varName + '.showDirections(' + params + '); return false;">' + self.gettext("Directions") + '</a>';
276
 
277
  featureData.infoWindowHtml = featureData.infoWindowHtml.replace(/<\/div><\/div>$/i, a + "</div></div>");
278
  }
@@ -282,7 +307,7 @@ FlexibleMap.prototype = (function() {
282
  // hack for directions links on Opera, which fails to ignore events when onclick returns false
283
  if (window.opera && this.markerDirections) {
284
  addEventListener(mapDiv, "click", function(event) {
285
- if (event.target.getAttribute("data-flxmap-isdir")) {
286
  stopEvent(event);
287
  }
288
  });
@@ -409,46 +434,15 @@ FlexibleMap.prototype = (function() {
409
  });
410
  },
411
 
412
- /**
413
- * show a map at specified centre latitude / longitude
414
- * @param {String} divID the ID of the div that will contain the map
415
- * @param {Array} centre an array of two integers: [ latitude, longitude ]
416
- * @return {google.maps.Map} the Google Maps map created
417
- */
418
- showMap: function(divID, centre) {
419
- var latLng = new google.maps.LatLng(centre[0], centre[1]),
420
- map = new google.maps.Map(document.getElementById(divID), {
421
- mapTypeId: this.mapTypeId,
422
- mapTypeControl: this.mapTypeControl,
423
- scaleControl: this.scaleControl,
424
- panControl: this.panControl,
425
- zoomControl: this.zoomControl,
426
- draggable: this.draggable,
427
- disableDoubleClickZoom: !this.dblclickZoom,
428
- scrollwheel: this.scrollwheel,
429
- streetViewControl: this.streetViewControl,
430
- navigationControlOptions: this.navigationControlOptions,
431
- center: latLng,
432
- zoom: this.zoom
433
- });
434
-
435
- // record map and centre in instance, so we can refer to them later
436
- this.setMap(map);
437
- this.setCenter(latLng);
438
-
439
- return map;
440
- },
441
-
442
  /**
443
  * tell Google Maps to redraw the map, and centre it back where it started with default zoom
444
  */
445
  redraw: function() {
446
  var map = this.getMap(),
447
- centre = this.getCenter(),
448
  kmlLayer = this.getKmlLayer();
449
 
450
  google.maps.event.trigger(map, "resize");
451
- map.setCenter(centre);
452
 
453
  // if map is KML, must refit to computed bounds, else use zoom setting
454
  if (kmlLayer) {
@@ -466,6 +460,7 @@ FlexibleMap.prototype = (function() {
466
  // make sure we have a directions service
467
  if (!this.dirService)
468
  this.dirService = new google.maps.DirectionsService();
 
469
  if (!this.dirPanel) {
470
  this.dirPanel = new google.maps.DirectionsRenderer({
471
  map: map,
18
  return map;
19
  };
20
 
 
 
 
 
 
 
 
 
21
  /**
22
  * get the centrepoint of the map at time of creation
23
  * @return {google.maps.LatLng}
27
  };
28
 
29
  /**
30
+ * set the centrepoint of the map
31
  * @param {google.maps.LatLng} latLng
32
  */
33
  this.setCenter = function(latLng) {
34
  centre = latLng;
35
+ map.setCenter(centre);
36
  };
37
 
38
  /**
43
  return kmlLayer;
44
  };
45
 
 
 
 
 
 
 
 
 
46
  /**
47
  * if map starts life hidden and needs to be redrawn when revealed, this function will perform that redraw *once*
48
  */
53
  }
54
  };
55
 
56
+ /**
57
+ * show a map at specified centre latitude / longitude
58
+ * @param {String} divID the ID of the div that will contain the map
59
+ * @param {Array} latLng the map centre, an array of two integers: [ latitude, longitude ]
60
+ * @return {google.maps.Map} the Google Maps map created
61
+ */
62
+ this.showMap = function(divID, latLng) {
63
+ centre = new google.maps.LatLng(latLng[0], latLng[1]);
64
+
65
+ map = new google.maps.Map(document.getElementById(divID), {
66
+ mapTypeId: this.mapTypeId,
67
+ mapTypeControl: this.mapTypeControl,
68
+ scaleControl: this.scaleControl,
69
+ panControl: this.panControl,
70
+ zoomControl: this.zoomControl,
71
+ draggable: this.draggable,
72
+ disableDoubleClickZoom: !this.dblclickZoom,
73
+ scrollwheel: this.scrollwheel,
74
+ streetViewControl: this.streetViewControl,
75
+ navigationControlOptions: this.navigationControlOptions,
76
+ center: centre,
77
+ zoom: this.zoom
78
+ });
79
+
80
+ return map;
81
+ };
82
+
83
+ /**
84
+ * load a map from a KML file and add as a layer on the Google Maps map
85
+ * @param {String} kmlFileURL
86
+ * @return {google.maps.KmlLayer}
87
+ */
88
+ this.loadKmlMap = function(kmlFileURL) {
89
+ // load KML file as a layer and add to map
90
+ kmlLayer = new google.maps.KmlLayer(kmlFileURL);
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
+ });
98
+
99
+ return kmlLayer;
100
+ };
101
+
102
  // set map defaults
103
  this.mapTypeId = google.maps.MapTypeId.ROADMAP;
104
  this.mapTypeControl = true; // no control for changing map type
248
  /**
249
  * show a map based on a KML file
250
  * @param {String} divID the ID of the div that will contain the map
251
+ * @param {String} kmlFileURL path to the KML file to load
252
  * @param {Number} zoom [optional] zoom level
253
  */
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
 
261
+ // set zoom if specified
262
+ if (typeof zoom != "undefined") {
263
+ // listen for KML layer load finished
264
+ google.maps.event.addListenerOnce(map, "tilesloaded", function() {
265
  map.setZoom(zoom);
266
  self.zoom = zoom;
267
+ });
268
+ }
269
 
270
  // add a directions service if needed
271
  if (this.markerDirections || this.markerDirectionsShow) {
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>");
303
  }
307
  // hack for directions links on Opera, which fails to ignore events when onclick returns false
308
  if (window.opera && this.markerDirections) {
309
  addEventListener(mapDiv, "click", function(event) {
310
+ if (event.target.getAttribute("data-flxmap-fix-opera")) {
311
  stopEvent(event);
312
  }
313
  });
434
  });
435
  },
436
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
  /**
438
  * tell Google Maps to redraw the map, and centre it back where it started with default zoom
439
  */
440
  redraw: function() {
441
  var map = this.getMap(),
 
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) {
460
  // make sure we have a directions service
461
  if (!this.dirService)
462
  this.dirService = new google.maps.DirectionsService();
463
+
464
  if (!this.dirPanel) {
465
  this.dirPanel = new google.maps.DirectionsRenderer({
466
  map: map,
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.setMap=function(e){d=e};this.getCenter=function(){return b};this.setCenter=function(e){b=e};this.getKmlLayer=function(){return c};this.setKmlLayer=function(e){c=e};this.redrawOnce=function(){if(!a){a=true;this.redraw()}};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,l,i){var h=this,g=document.getElementById(f),m,k=this.showMap(f,[0,0]),j=new google.maps.KmlLayer(l);this.setKmlLayer(j);j.setMap(k);google.maps.event.addListenerOnce(k,"tilesloaded",function(){h.setCenter(k.getCenter());if(typeof i!="undefined"){k.setZoom(i);h.zoom=i}});if(this.markerDirections||this.markerDirectionsShow){this.startDirService(k);m=g.getAttribute("data-flxmap")}google.maps.event.addListener(j,"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-isdir="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-isdir")){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)}})},showMap:function(f,h){var g=new google.maps.LatLng(h[0],h[1]),i=new google.maps.Map(document.getElementById(f),{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:g,zoom:this.zoom});this.setMap(i);this.setCenter(g);return i},redraw:function(){var h=this.getMap(),f=this.getCenter(),g=this.getKmlLayer();google.maps.event.trigger(h,"resize");h.setCenter(f);if(g){h.fitBounds(g.getDefaultViewport())}else{h.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,"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")}}}})();
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.0
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.0');
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.1
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.1');
32
 
33
  // shortcode tags
34
  define('FLXMAP_PLUGIN_TAG_MAP', 'flexiblemap');
readme.txt CHANGED
@@ -7,7 +7,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
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.0
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -194,6 +194,9 @@ And here's some sample jQuery code:
194
 
195
  == Changelog ==
196
 
 
 
 
197
  = 1.5.0 [2012-09-29] =
198
  * added: new shortcode attribute "id" which will be used for the container div, instead of the random unique div id
199
  * 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)
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
 
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)