Jump to content

 
Photo

Tilemill/CartoCSS

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Hans van der Maarel

Hans van der Maarel

    CartoTalk Editor-in-Chief

  • Admin
  • PipPipPipPipPipPipPip
  • 3,898 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Cartography, GIS, history, popular science, music.
  • Netherlands

I'm in the process of setting up my first Tilemill/CartoCSS project but I'm running into some trouble (and I'm finding the documentation very frustrating...)

 

I'm using OpenStreetmap data to construct a simple base map, including streets and street names, and that's where the problem is. I can't seem to make the street names render always on top. Some appear underneath lines.

Attached File  text issue.JPG   53.74KB   2 downloads

 

And I can't figure out why. I read somewhere in the docs that stylesheets are rendered from left to right, so I figured I'd put the cartocss code that covered the labelling in a seperate stylesheet and put that to the right of the one handling the rest. All that resulted in was that the labels consistently rendered underneath the lines... Switched the stylesheets around and that didn't change a thing.

 

The relevant bit of code:

#highwayline
{
  line-smooth: 0.1;
  line-join: round;
  line-cap: round;
  [zoom >= 15][zoom < 17] {
  	[HIGHWAY="footway"]{line-color:#aca7a7; line-width:2}
  	[HIGHWAY="cycleway"]{line-color:#aca7a7; line-width:2}
  	[HIGHWAY="path"]{line-color:#aca7a7; line-width:2}
  	[HIGHWAY="track"]{line-color:#aca7a7; line-width:2}
  	[HIGHWAY="unclassified"]{line-color:#aca7a7; line-width:3}
  	[HIGHWAY="residential"]{line-color:#aca7a7; line-width:3}
  	[HIGHWAY="service"]{line-color:#aca7a7; line-width:3}
  	[HIGHWAY="living street"]{line-color:#aca7a7; line-width:3}
  	[HIGHWAY="living_street"]{line-color:#aca7a7; line-width:3}
  	[HIGHWAY="road"]{line-color:#aca7a7; line-width:3}
  	[HIGHWAY="pedestrian"]{line-color:#aca7a7; line-width:3}
  	[HIGHWAY="tertiary"]{line-color:#aca7a7; line-width:4}
  	[HIGHWAY="secondary"]{line-color:#aca7a7; line-width:4}
  	[HIGHWAY="construction"] {
    	line-color:#aca7a7;
    	line-width:3;
    	line-dasharray: 5,4;
    }
  	
    text-name: [NAME];
  	text-face-name: 'Frutiger 57 Condensed';
  	text-fill: #4b4f50;
  	text-size: 14;
  	text-placement: line;
  	text-halo-fill: fadeout(#e7f5f7, 50%);
  	text-halo-radius: 2.5;
   
  }  
  [zoom >= 17][zoom <= 20] {
  	[HIGHWAY="footway"]{line-color:#aca7a7; line-width:4}
  	[HIGHWAY="cycleway"]{line-color:#aca7a7; line-width:4}
  	[HIGHWAY="path"]{line-color:#aca7a7; line-width:4}
  	[HIGHWAY="track"]{line-color:#aca7a7; line-width:4}
  	[HIGHWAY="unclassified"]{line-color:#aca7a7; line-width:6}
  	[HIGHWAY="residential"]{line-color:#aca7a7; line-width:6}
  	[HIGHWAY="service"]{line-color:#aca7a7; line-width:6}
  	[HIGHWAY="living street"]{line-color:#aca7a7; line-width:6}
  	[HIGHWAY="living_street"]{line-color:#aca7a7; line-width:6}
  	[HIGHWAY="road"]{line-color:#aca7a7; line-width:6}
  	[HIGHWAY="pedestrian"]{line-color:#aca7a7; line-width:6}
  	[HIGHWAY="tertiary"]{line-color:#aca7a7; line-width:6}
  	[HIGHWAY="secondary"]{line-color:#aca7a7; line-width:6}
  	[HIGHWAY="construction"] {
    	line-color:#aca7a7;
    	line-width:6;
    	line-dasharray: 11,7;
    }
  	
    text-name: [NAME];
  	text-face-name: 'Frutiger 57 Condensed';
  	text-fill: #4b4f50;
  	text-size: 20;
  	text-placement: line;
  	text-halo-fill: fadeout(#e7f5f7, 50%);
  	text-halo-radius: 2.5;
    
  }  
}

Any pointers would be greatly appreciated.


Hans van der Maarel - Cartotalk Editor
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics

#2
l.jegou

l.jegou

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 114 posts
  • Gender:Male
  • Location:Toulouse
  • Interests:Webmapping, thematical mapping.
  • France

Hello, i think this support discussion is relevant :

 

http://support.mapbo...4-drawing-order

 

Good luck,

 

LJ



#3
Hans van der Maarel

Hans van der Maarel

    CartoTalk Editor-in-Chief

  • Admin
  • PipPipPipPipPipPipPip
  • 3,898 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Cartography, GIS, history, popular science, music.
  • Netherlands

Merci.

 

I'll try some of that out, it seems to conform to what's mentioned here. But yeah, 4 ways to influence rendering order... :wacko:


Hans van der Maarel - Cartotalk Editor
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics

#4
Hans van der Maarel

Hans van der Maarel

    CartoTalk Editor-in-Chief

  • Admin
  • PipPipPipPipPipPipPip
  • 3,898 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Cartography, GIS, history, popular science, music.
  • Netherlands

Of course the brute force method (importing the data layer a second time, placing that on top and using that one to style the labels and nothing else) works... But still this should be possible without having to import the data twice.


Hans van der Maarel - Cartotalk Editor
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics

#5
skorasaurus

skorasaurus

    Contributor

  • Validated Member
  • PipPip
  • 39 posts
  • Gender:Not Telling
  • Location:Cleveland, OH, United States
  • United States

Hans,

 

You don't mention what your data source is (I'm presuming it's a postgresql database, if it's SHP or something else, the following may not apply) but you'll want your own dedicated layer for labels in nearly all of your Tilemill projects.

 

 

I admit Tilemill can be confusing at first, especially for someone who comes from experience with ARC and other desktop GIS cartographic suites! I found it confusing at first as well even though it was my 2nd program that I ever used to style maps!



#6
Hans van der Maarel

Hans van der Maarel

    CartoTalk Editor-in-Chief

  • Admin
  • PipPipPipPipPipPipPip
  • 3,898 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Cartography, GIS, history, popular science, music.
  • Netherlands

Source data is shapefiles actually, and it seems that the dedicated layer trick works. Thanks for confirming my hunch.


Hans van der Maarel - Cartotalk Editor
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->