diff --git a/plugins/layer_types/openlayers_layer_type_tms.inc b/plugins/layer_types/openlayers_layer_type_tms.inc
index c046247..bc89dc1 100644
--- a/plugins/layer_types/openlayers_layer_type_tms.inc
+++ b/plugins/layer_types/openlayers_layer_type_tms.inc
@@ -67,6 +67,13 @@ class openlayers_layer_type_tms extends openlayers_layer_type {
           $this->data['layername'] : '',
         '#description' => t('This is the base URL of the TMS service.  For example, if this was your tile scheme URL: http://example.com/tms/1.0.0/layer_name/{z}/{y}/{x}.png, then <em>layer_name</em> would be the Layer Name.'),
       ),
+      'serviceVersion' => array(
+        '#type' => 'textfield',
+        '#default_value' => isset($this->data['serviceVersion']) ?
+          $this->data['serviceVersion'] : '1.0.0',
+        '#title' => t('Service version'),
+        '#description' => t('This is the version of the TMS service URL. For example, if this was your tile scheme URL: http://example.com/tms/version/layer_name/{z}/{y}/{x}.png. The <em>version</em> defaults to 1.0.0.'),
+      ),
       'baselayer' => array(
         '#type' => 'checkbox',
         '#default_value' => $this->data['baselayer'],
diff --git a/plugins/layer_types/openlayers_layer_type_tms.js b/plugins/layer_types/openlayers_layer_type_tms.js
index ba13a1b..e4b5c4d 100644
--- a/plugins/layer_types/openlayers_layer_type_tms.js
+++ b/plugins/layer_types/openlayers_layer_type_tms.js
@@ -14,6 +14,37 @@ Drupal.openlayers.layer.tms = function(title, map, options) {
       options.maxExtent = new OpenLayers.Bounds.fromArray(options.maxExtent);
     }
     options.projection = 'EPSG:' + options.projection;
+
+    // Add url creation callback function.
+    options.getURL = function (bounds) {
+      bounds = this.adjustBounds(bounds);
+      // Calculate x, y and z.
+      var res = this.map.getResolution();
+      var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
+      var y;
+
+      if (options.serviceVersion === '1.0.0') {
+        y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
+      }
+      else {
+        y = Math.round ((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
+      }
+
+      var z = this.serverResolutions != null ?
+            OpenLayers.Util.indexOf(this.serverResolutions, res) :
+            this.getServerZoom() + this.zoomOffset;
+
+      // Build TMS URL parts.
+      var serviceVersion = options.serviceVersion ? options.serviceVersion : '1.0.0'
+      var layername = '/' + options.layername;
+      var path = '/' + z + "/" + x + "/" + y + "." + this.type;
+      var url = this.url;
+      if (url instanceof Array) {
+          url = this.selectUrl(path, url);
+      }
+      return url + serviceVersion + layername + path;
+    }
+
     var layer = new OpenLayers.Layer.TMS(title, options.base_url, options);
     layer.styleMap = styleMap;
     return layer;
