1 Reply Latest reply on Nov 15, 2012 1:48 PM by Jake Baillie

    Hacking Urban Mapping's TMS File.

    Shawn Wallwork

      Yesterday I posted a Viz Talk with a TMS file that makes it easy to see highways & streets through the filled map layer. I worked with Jake at Urban Mapping to figure out the syntax necessary to change the way base maps are displayed. The following is some of what I think learned working through this process. I'm pinging Jake so he can set me straight if I get anything wrong.


      So first I think it will be helpful if you understand the file structure (FYI: a TMS file is a text file):


      Don't freak, it's really not as bad as it looks. The highlighted stuff should be familiar. You don't need to know what most of this stuff means (I don't) but you can still make some fairly dramatic changes to your background maps. In the Viz Talk file I changed this line:



      <map-layer-style name="pp2_line" request-string="mode=named|from=tableau2_2_roads"/>


      <map-layer-style name="pp2_line" request-string="mode=named|from=tableau2_2_roads|invert=1"/>


      And that's what made the roads dark, instead of grey. I did this in all three of the map option sections (Normal, Grey, Dark). I also changed this line in each of the three sections:


              <map-style display-name="Filled Map Normal" display-name-de="Normal" display-name-es="Normal" display-name-fr="Normal" display-name-ja="標準"


      I don't know any Japanese, so I left that part alone.


      A Few Things To Know.

      • Changes don't take effect until you close and re-open the file.
      • If you get red X's it probably means you introduced a syntax error.
      • It might also mean Tableau couldn't find your TMS file
      • Your TMS file has to be in your version of this directory: D:\Shawn\My Tableau Repository\Mapsources
      • The original online.tms file is in your version of this directory: C:\Program Files (x86)\Tableau\Tableau 7.0\Mapsources
      • Don't hack the orginal, just copy it to the Repository\Mapsources diretory
      • Whatever is in that directory will show up on your Map\Background Maps pull-down menu
      • In each section the lines are in order of the menus in the Map Options menu



      • When you insert commands into lines use the piping | character to separate them
      • You can insert more than one command in a line
      • It doesn't seem to matter where in the string you insert it, but it needs to be after the request-string=" and before the next /
      • Some lines combine elements, for instance:

      <map-layer-style name="um_light_countries" request string="mode=named|opacity=.5|from=tableau1_2_admin0_borders{L}/mode=named|opacity=.5|from=tableau1_2_admin0_labels{L}"/>


      • The stuff in blue effect the light country borders, and the stuff in red effect the country labels.
      • Not all commands work on all the different elements


      A Few Commands.

      • |Invert=1|
      • |Opacity= x| (any value 0 to 1, and maybe higher)
      • |Brightness=x| (a negative # produces black roads)
      • |Grayscale=1| (changes base map to gray)


      You can find others at the hackyourmap website.


      One Last Item.

      In the beginning I had some pretty good luck setting the roads to this |Brightness=-1| It made them completely black. But it also made the highway signs black, which didn't look that great. Jake did a little research and found out that the roads and signs are on different layer, but are combined in that single pp2 line. Here's the syntax for pulling them apart:


      <map-layer-style name="pp2_line" request-string="mode=proxy|from=tableau1_2_roads/mode=proxy|from=tableau1_2_road_labels"/>


      Use it to replace the original pp2 line. The next step is to display the two elements on the map (or not).


      <map-layer-style name="pp2_line" request-string="mode=proxy|from=tableau1_2_roads/"/>     //displays the roads without signs


      <map-layer-style name="pp2_line" request-string="mode=proxy|from=tableau1_2_roads/mode=proxy|

      from=tableau1_2_road_labels"/>     //displays both


      <map-layer-style name="pp2_line" request-string="mode=proxy|invert=1|from=tableau1_2_roads/mode=proxy|

      from=tableau1_2_road_labels"/>     //displays dark roads, and the light-gray highway signs.


      That's it. If you play around with this file and find anything cool, let us know.



        • 1. Re: Hacking Urban Mapping's TMS File.
          Jake Baillie

          Thanks for this Shawn. A few things to note:


          The format of the queries that Shawn describes above (request-strings that start with "mode=<something>") are "types" of queries available in Mapfluence.


          You can implement visual queries for display in Tableau. Tableau does not offer access to Mapfluence's spatial (non-map) type queries, and you will need a separate Mapfluence key to use them (you can contact us to request a key).


          All of the visual type queries are well documented in the Mapfluence Developer Documentation.


          If you're playing around with queries, it's best to actually use the JavaScript map client to get them right, so you don't have to keep changing TMS files (and restarting Tableau). If you'd like, you can also register for a key for use in the JavaScript map client - doing so will enable us to help you more quickly if you run into issues (as we can identify you in logs). This is especially important if you're getting the (dreaded!) Red Xs - using a web browser and the JavaScript client, Mapfluence will return syntax error information in the HTTP headers and you can use Chrome or Firefox developer tools to retrieve those errors and see what you've done wrong.


          If you want Tableau to "automatically" detect new Mapsources file, put them in the C:\Program Files (x86)\Tableau\Tableau 7.0\Mapsources, and restart Tableau.


          I have to run to a meeting, but there's another topic I want to discuss when I get back - pre-rendered elements vs. elements rendered on the fly.