Flexible Map - Version 1.0.5

Version Description

[2012-03-17] = * fixed: CSS fixes for themes that muck up Google Maps images (e.g. twentyeleven) * added: infowindow styles now in enqueued stylesheet

Download this release

Release Info

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

Code changes from version 1.0.4a to 1.0.5

class.FlxMapPlugin.php CHANGED
@@ -30,6 +30,8 @@ class FlxMapPlugin {
30
  private function __construct() {
31
  // record plugin URL base
32
  $this->urlBase = WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__));
 
 
33
 
34
  if (is_admin()) {
35
  // kick off the admin handling
@@ -44,6 +46,7 @@ class FlxMapPlugin {
44
 
45
  // custom actions and filters for this plugin
46
  add_filter('flexmap_getmap', array($this, 'shortcodeMap'), 10, 1);
 
47
  }
48
  }
49
 
@@ -67,16 +70,23 @@ class FlxMapPlugin {
67
  $role->remove_cap('flxmap_options');
68
  }
69
 
 
 
 
 
 
 
 
 
70
  /**
71
  * output anything we need in the footer
72
  */
73
  public function actionFooter() {
74
  if ($this->loadScripts) {
75
  // load required scripts
76
- $url = parse_url("{$this->urlBase}/flexible-map.min.js", PHP_URL_PATH) . '?v=5';
77
-
78
  echo <<<HTML
79
- <script src="$url"></script>
80
  <script src="http://maps.google.com/maps/api/js?v=3.8&amp;sensor=false"></script>
81
 
82
  HTML;
@@ -266,7 +276,7 @@ HTML;
266
  * @return string
267
  */
268
  private static function unhtml($text) {
269
- return self::str2js(html_entity_decode($text));
270
  }
271
 
272
  /**
30
  private function __construct() {
31
  // record plugin URL base
32
  $this->urlBase = WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__));
33
+ if (!empty($_SERVER['HTTPS']))
34
+ $this->urlBase = preg_replace('@^http:@', 'https:', $this->urlBase);
35
 
36
  if (is_admin()) {
37
  // kick off the admin handling
46
 
47
  // custom actions and filters for this plugin
48
  add_filter('flexmap_getmap', array($this, 'shortcodeMap'), 10, 1);
49
+ add_action('wp_print_styles', array($this, 'actionEnqueueStyles'));
50
  }
51
  }
52
 
70
  $role->remove_cap('flxmap_options');
71
  }
72
 
73
+ /**
74
+ * enqueue any styles we require
75
+ */
76
+ public function actionEnqueueStyles() {
77
+ // theme writers: you can remove by calling wp_dequeue_script('flxmap');
78
+ wp_enqueue_style('flxmap', "{$this->urlBase}/styles.css", FALSE, '1');
79
+ }
80
+
81
  /**
82
  * output anything we need in the footer
83
  */
84
  public function actionFooter() {
85
  if ($this->loadScripts) {
86
  // load required scripts
87
+ $url = parse_url($this->urlBase, PHP_URL_PATH);
 
88
  echo <<<HTML
89
+ <script src="$url/flexible-map.min.js?v=6"></script>
90
  <script src="http://maps.google.com/maps/api/js?v=3.8&amp;sensor=false"></script>
91
 
92
  HTML;
276
  * @return string
277
  */
278
  private static function unhtml($text) {
279
+ return self::str2js(html_entity_decode($text, ENT_QUOTES, get_option('blog_charset')));
280
  }
281
 
282
  /**
flexible-map.js CHANGED
@@ -92,22 +92,21 @@ FlexibleMap.prototype = (function() {
92
  self = this,
93
  container = document.createElement("DIV");
94
 
95
- container.style.fontFamily = "Arial,Helvetica,sans-serif";
96
 
97
  // add tooltip title for marker
98
  point.setTitle(this.markerTitle);
99
 
100
  // heading for info window
101
  element = document.createElement("DIV");
102
- element.style.fontWeight = "bold";
103
- element.style.fontSize = "medium";
104
  element.appendChild(document.createTextNode(this.markerTitle));
105
  container.appendChild(element);
106
 
107
  // body of info window, with link
108
  if (this.markerDescription || this.markerLink) {
109
  element = document.createElement("DIV");
110
- element.style.fontSize = "small";
111
  if (this.markerDescription) {
112
  lines = this.markerDescription.split("\n");
113
  for (i = 0, len = lines.length; i < len; i++) {
@@ -130,7 +129,7 @@ FlexibleMap.prototype = (function() {
130
  // add a link for directions if wanted
131
  if (this.markerDirections) {
132
  element = document.createElement("DIV");
133
- element.style.fontSize = "small";
134
  a = document.createElement("A");
135
  a.href = "#";
136
  a.dataLatitude = marker[0];
92
  self = this,
93
  container = document.createElement("DIV");
94
 
95
+ container.className = "flxmap-infowin";
96
 
97
  // add tooltip title for marker
98
  point.setTitle(this.markerTitle);
99
 
100
  // heading for info window
101
  element = document.createElement("DIV");
102
+ element.className = "flxmap-marker-title";
 
103
  element.appendChild(document.createTextNode(this.markerTitle));
104
  container.appendChild(element);
105
 
106
  // body of info window, with link
107
  if (this.markerDescription || this.markerLink) {
108
  element = document.createElement("DIV");
109
+ element.className = "flxmap-marker-link";
110
  if (this.markerDescription) {
111
  lines = this.markerDescription.split("\n");
112
  for (i = 0, len = lines.length; i < len; i++) {
129
  // add a link for directions if wanted
130
  if (this.markerDirections) {
131
  element = document.createElement("DIV");
132
+ element.className = "flxmap-directions-link";
133
  a = document.createElement("A");
134
  a.href = "#";
135
  a.dataLatitude = marker[0];
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(){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.markerAddress="";this.navigationControlOptions={style:google.maps.NavigationControlStyle.SMALL};this.dirService=false;this.dirPanel=false;this.region=false}FlexibleMap.prototype=(function(){var b,a;if(document.addEventListener){b=function(d,c,e){d.addEventListener(c,e,false)};a=function(c){c.stopPropagation();c.preventDefault()}}else{if(document.attachEvent){b=function(c,d,e){c.attachEvent("on"+d,function(){e.call(c,window.event)})};a=function(c){c.cancelBubble=true;c.returnValue=0}}}return{constructor:FlexibleMap,showKML:function(c,g,d){var f=this.showMap(c,[0,0]),e=new google.maps.KmlLayer(g);e.setMap(f);if(typeof d!="undefined"){google.maps.event.addListenerOnce(f,"tilesloaded",function(){f.setZoom(d)})}google.maps.event.addListener(e,"click",function(h){h.featureData.description=h.featureData.description.replace(/ target="_blank"/ig,"")})},showMarker:function(f,e,k){var d=this.showMap(f,e),n=new google.maps.Marker({map:d,position:new google.maps.LatLng(k[0],k[1])});if(!this.markerTitle){this.markerTitle=this.markerAddress}if(this.markerTitle){var j,l,p,g,h,m,o=this,c=document.createElement("DIV");c.style.fontFamily="Arial,Helvetica,sans-serif";n.setTitle(this.markerTitle);h=document.createElement("DIV");h.style.fontWeight="bold";h.style.fontSize="medium";h.appendChild(document.createTextNode(this.markerTitle));c.appendChild(h);if(this.markerDescription||this.markerLink){h=document.createElement("DIV");h.style.fontSize="small";if(this.markerDescription){p=this.markerDescription.split("\n");for(j=0,l=p.length;j<l;j++){if(j>0){h.appendChild(document.createElement("BR"))}h.appendChild(document.createTextNode(p[j]))}if(this.markerLink){h.appendChild(document.createElement("BR"))}}if(this.markerLink){m=document.createElement("A");m.href=this.markerLink;m.appendChild(document.createTextNode("Click for details"));h.appendChild(m)}c.appendChild(h)}if(this.markerDirections){h=document.createElement("DIV");h.style.fontSize="small";m=document.createElement("A");m.href="#";m.dataLatitude=k[0];m.dataLongitude=k[1];m.dataTitle=this.markerTitle;b(m,"click",function(i){a(i);o.showDirections(this.dataLatitude,this.dataLongitude,this.dataTitle)});m.appendChild(document.createTextNode("Directions"));h.appendChild(m);c.appendChild(h);if(!this.dirService){this.dirService=new google.maps.DirectionsService()}if(!this.dirPanel){this.dirPanel=new google.maps.DirectionsRenderer({map:d,panel:document.getElementById(this.markerDirections)})}}g=new google.maps.InfoWindow({content:c});if(this.markerShowInfo){g.open(d,n)}google.maps.event.addListener(n,"click",function(){g.open(d,n)})}},showAddress:function(c,d){var e=this,f=new google.maps.Geocoder();this.markerAddress=d;if(this.markerTitle===""){this.markerTitle=d}f.geocode({address:d},function(i,h){if(h==google.maps.GeocoderStatus.OK){var g=i[0].geometry.location,j=[g.lat(),g.lng()];e.showMarker(c,j,j)}else{alert("Map address returns error: "+h)}})},showMap:function(c,d){return new google.maps.Map(document.getElementById(c),{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:new google.maps.LatLng(d[0],d[1]),zoom:this.zoom})},showDirections:function(g,c,i){var d=document.getElementById(this.markerDirections),f=document.createElement("form"),l=this,h=this.region||"",j,e,k;while(!!(e=d.lastChild)){d.removeChild(e)}e=document.createElement("p");e.appendChild(document.createTextNode("From: "));k=document.createElement("input");k.type="text";k.name="from";e.appendChild(k);j=document.createElement("input");j.type="submit";j.value="Get directions";e.appendChild(j);f.appendChild(e);d.appendChild(f);k.focus();if(typeof f.elements.from=="undefined"){f.elements.from=k}b(f,"submit",function(o){a(o);var p=this.elements.from.value;if(/\S/.test(p)){var m=(l.markerAddress==="")?new google.maps.LatLng(g,c):l.markerAddress,n={origin:p,region:h,destination:m,travelMode:google.maps.DirectionsTravelMode.DRIVING};l.dirService.route(n,function(s,q){var r=google.maps.DirectionsStatus;switch(q){case r.OK:l.dirPanel.setDirections(s);break;case r.ZERO_RESULTS:alert("No route could be found between the origin and destination.");break;case r.OVER_QUERY_LIMIT:alert("The webpage has gone over the requests limit in too short a period of time.");break;case r.REQUEST_DENIED:alert("The webpage is not allowed to use the directions service.");break;case r.INVALID_REQUEST:alert("Invalid directions request.");break;case r.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}})}})}}})();
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(){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.markerAddress="";this.navigationControlOptions={style:google.maps.NavigationControlStyle.SMALL};this.dirService=false;this.dirPanel=false;this.region=false}FlexibleMap.prototype=(function(){var b,a;if(document.addEventListener){b=function(d,c,e){d.addEventListener(c,e,false)};a=function(c){c.stopPropagation();c.preventDefault()}}else{if(document.attachEvent){b=function(c,d,e){c.attachEvent("on"+d,function(){e.call(c,window.event)})};a=function(c){c.cancelBubble=true;c.returnValue=0}}}return{constructor:FlexibleMap,showKML:function(c,g,d){var f=this.showMap(c,[0,0]),e=new google.maps.KmlLayer(g);e.setMap(f);if(typeof d!="undefined"){google.maps.event.addListenerOnce(f,"tilesloaded",function(){f.setZoom(d)})}google.maps.event.addListener(e,"click",function(h){h.featureData.description=h.featureData.description.replace(/ target="_blank"/ig,"")})},showMarker:function(f,e,k){var d=this.showMap(f,e),n=new google.maps.Marker({map:d,position:new google.maps.LatLng(k[0],k[1])});if(!this.markerTitle){this.markerTitle=this.markerAddress}if(this.markerTitle){var j,l,p,g,h,m,o=this,c=document.createElement("DIV");c.className="flxmap-infowin";n.setTitle(this.markerTitle);h=document.createElement("DIV");h.className="flxmap-marker-title";h.appendChild(document.createTextNode(this.markerTitle));c.appendChild(h);if(this.markerDescription||this.markerLink){h=document.createElement("DIV");h.className="flxmap-marker-link";if(this.markerDescription){p=this.markerDescription.split("\n");for(j=0,l=p.length;j<l;j++){if(j>0){h.appendChild(document.createElement("BR"))}h.appendChild(document.createTextNode(p[j]))}if(this.markerLink){h.appendChild(document.createElement("BR"))}}if(this.markerLink){m=document.createElement("A");m.href=this.markerLink;m.appendChild(document.createTextNode("Click for details"));h.appendChild(m)}c.appendChild(h)}if(this.markerDirections){h=document.createElement("DIV");h.className="flxmap-directions-link";m=document.createElement("A");m.href="#";m.dataLatitude=k[0];m.dataLongitude=k[1];m.dataTitle=this.markerTitle;b(m,"click",function(i){a(i);o.showDirections(this.dataLatitude,this.dataLongitude,this.dataTitle)});m.appendChild(document.createTextNode("Directions"));h.appendChild(m);c.appendChild(h);if(!this.dirService){this.dirService=new google.maps.DirectionsService()}if(!this.dirPanel){this.dirPanel=new google.maps.DirectionsRenderer({map:d,panel:document.getElementById(this.markerDirections)})}}g=new google.maps.InfoWindow({content:c});if(this.markerShowInfo){g.open(d,n)}google.maps.event.addListener(n,"click",function(){g.open(d,n)})}},showAddress:function(c,d){var e=this,f=new google.maps.Geocoder();this.markerAddress=d;if(this.markerTitle===""){this.markerTitle=d}f.geocode({address:d},function(i,h){if(h==google.maps.GeocoderStatus.OK){var g=i[0].geometry.location,j=[g.lat(),g.lng()];e.showMarker(c,j,j)}else{alert("Map address returns error: "+h)}})},showMap:function(c,d){return new google.maps.Map(document.getElementById(c),{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:new google.maps.LatLng(d[0],d[1]),zoom:this.zoom})},showDirections:function(g,c,i){var d=document.getElementById(this.markerDirections),f=document.createElement("form"),l=this,h=this.region||"",j,e,k;while(!!(e=d.lastChild)){d.removeChild(e)}e=document.createElement("p");e.appendChild(document.createTextNode("From: "));k=document.createElement("input");k.type="text";k.name="from";e.appendChild(k);j=document.createElement("input");j.type="submit";j.value="Get directions";e.appendChild(j);f.appendChild(e);d.appendChild(f);k.focus();if(typeof f.elements.from=="undefined"){f.elements.from=k}b(f,"submit",function(o){a(o);var p=this.elements.from.value;if(/\S/.test(p)){var m=(l.markerAddress==="")?new google.maps.LatLng(g,c):l.markerAddress,n={origin:p,region:h,destination:m,travelMode:google.maps.DirectionsTravelMode.DRIVING};l.dirService.route(n,function(s,q){var r=google.maps.DirectionsStatus;switch(q){case r.OK:l.dirPanel.setDirections(s);break;case r.ZERO_RESULTS:alert("No route could be found between the origin and destination.");break;case r.OVER_QUERY_LIMIT:alert("The webpage has gone over the requests limit in too short a period of time.");break;case r.REQUEST_DENIED:alert("The webpage is not allowed to use the directions service.");break;case r.INVALID_REQUEST:alert("Invalid directions request.");break;case r.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}})}})}}})();
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.0.4
7
  Author: WebAware
8
  Author URI: http://www.webaware.com.au/
9
  */
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.0.5
7
  Author: WebAware
8
  Author URI: http://www.webaware.com.au/
9
  */
instructions.html CHANGED
@@ -12,7 +12,8 @@
12
  </style>
13
 
14
  <p>To add a Flexible Map to a post or a page, add a shortcode [flexiblemap] and give it some useful parameters.</p>
15
- <p>Map can either be specified using centre coordinates, or by loading a KML file.</p>
 
16
 
17
  <h3>Parameters for all maps:</h3>
18
  <dl class="flxmap-instructions-parameters">
@@ -91,5 +92,8 @@
91
  'title' => 'Adelaide Hills',
92
  'description' => 'The Adelaide Hills are repleat with wineries.',
93
  'directions' => 'my-dir-div',
 
 
 
94
  ));</code></pre></dd>
95
  </dl>
12
  </style>
13
 
14
  <p>To add a Flexible Map to a post or a page, add a shortcode [flexiblemap] and give it some useful parameters.</p>
15
+ <p>Map can either be specified using centre coordinates, or by loading a KML file. A KML file has the advantage that you can have
16
+ many different markers all on the one map.</p>
17
 
18
  <h3>Parameters for all maps:</h3>
19
  <dl class="flxmap-instructions-parameters">
92
  'title' => 'Adelaide Hills',
93
  'description' => 'The Adelaide Hills are repleat with wineries.',
94
  'directions' => 'my-dir-div',
95
+ 'hidepanning' => 'false',
96
+ 'hidescale' => 'false',
97
+ 'maptype' => 'satellite',
98
  ));</code></pre></dd>
99
  </dl>
readme.txt CHANGED
@@ -6,7 +6,7 @@ Author URI: http://www.webaware.com.au/
6
  Tags: google, maps, shortcode, kml
7
  Requires at least: 3.0.1
8
  Tested up to: 3.3.1
9
- Stable tag: 1.0.4a
10
 
11
  Embed Google Maps in pages and posts, either by centre coodinates or street address, or by URL to a Google Earth KML file.
12
 
@@ -98,6 +98,9 @@ There is a PHP function `flexmap_show_map()` for theme and plugin developers. Al
98
  'title' => 'Adelaide Hills',
99
  'description' => 'The Adelaide Hills are repleat with wineries.',
100
  'directions' => 'my-dir-div',
 
 
 
101
  ));`
102
 
103
  == Frequently Asked Questions ==
@@ -120,6 +123,10 @@ Google Maps API caches the KML file, so it often won't get your new changes. To
120
 
121
  == Changelog ==
122
 
 
 
 
 
123
  = 1.0.4 [2012-03-06] =
124
  * fixed: use LatLng methods to access latitude/longitude, instead of (ever changing) Google Maps API private members
125
  * added: tooltip on markers in non-KML maps
6
  Tags: google, maps, shortcode, kml
7
  Requires at least: 3.0.1
8
  Tested up to: 3.3.1
9
+ Stable tag: 1.0.5
10
 
11
  Embed Google Maps in pages and posts, either by centre coodinates or street address, or by URL to a Google Earth KML file.
12
 
98
  'title' => 'Adelaide Hills',
99
  'description' => 'The Adelaide Hills are repleat with wineries.',
100
  'directions' => 'my-dir-div',
101
+ 'hidepanning' => 'false',
102
+ 'hidescale' => 'false',
103
+ 'maptype' => 'satellite',
104
  ));`
105
 
106
  == Frequently Asked Questions ==
123
 
124
  == Changelog ==
125
 
126
+ = 1.0.5 [2012-03-17] =
127
+ * fixed: CSS fixes for themes that muck up Google Maps images (e.g. twentyeleven)
128
+ * added: infowindow styles now in enqueued stylesheet
129
+
130
  = 1.0.4 [2012-03-06] =
131
  * fixed: use LatLng methods to access latitude/longitude, instead of (ever changing) Google Maps API private members
132
  * added: tooltip on markers in non-KML maps
styles.css ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* stop some themes from messing up Google Maps' styling (e.g. twentyeleven) */
2
+
3
+ .flxmap-container img {
4
+ max-width: none;
5
+ }
6
+
7
+ /* some basic styling for info window */
8
+
9
+ .flxmap-infowin {
10
+ font-family: Arial,Helvetica,sans-serif;
11
+ }
12
+
13
+ .flxmap-marker-title {
14
+ font-weight: bold;
15
+ font-size: medium;
16
+ }
17
+
18
+ .flxmap-marker-link, .flxmap-directions-link {
19
+ font-weight: normal;
20
+ font-size: small;
21
+ }