0

I'd like to style contour lines so that they show differently at varying levels of zoom. When zoomed right out, only the 200m, 400m, 600m, etc. lines should show. When zoomed in a bit further, the 100m, 300m, etc. lines should appear. Text should appear too when zooming in.

I can achieve this fine using reasonably concise OR syntax in Builder, but when I try to cURL definitions containing OR conditions to create a named map, the map stops working.

For example, this one works both when cURLed and in Builder:

#layer[value='200'] {
    line-width: 0.7;
    line-color: #4b3ebc;
    line-opacity: 1;
}

But this one containing the OR condition ,[value='400'] only works in Builder: it does not work when cURLed:

#layer[value='200'],[value='400'] {
    line-width: 0.7;
    line-color: #4b3ebc;
    line-opacity: 1;
}

I can achieve the desired effect by cURLing this more verbose expression of the same thing, but would rather use more concise syntax because the full styling I need involves many more conditions:

#layer[value='200'] {
  line-width: 1.5;
  line-color: #4b3ebc;
  line-opacity: 1;
}

#layer[value='400'] {
  line-width: 1.5;
  line-color: #4b3ebc;
  line-opacity: 1;
}

For reference, here's the full styling I'm trying to achieve, expressed using concise syntax:

#layer[value='200'],[value='400'],[value='600'],[value='800'],[value='1000'],[value='1200'],[value='1400'],[value='1600'],[value='1800'],[value='2000'] {
  line-width: 1.5;
  line-color: #4b3ebc;
  line-opacity: 1;
}

#layer[zoom>10][value='200'],[zoom>10][value='400'],[zoom>10][value='600'],[zoom>10][value='800'],[zoom>10][value='1000'],[zoom>10][value='1200'],[zoom>10][value='1400'],[zoom>10][value='1600'],[zoom>10][value='1800'],[zoom>10][value='2000'] {
  text-face-name: 'DejaVu Sans Book';
  text-name: [value];
}

#layer[zoom>10][value='200'],[zoom>10][value='400'],[zoom>10][value='600'],[zoom>10][value='800'],[zoom>10][value='1000'],[zoom>10][value='1200'],[zoom>10][value='1400'],[zoom>10][value='1600'],[zoom>10][value='1800'],[zoom>10][value='2000'] {
  text-face-name: 'DejaVu Sans Book';
  text-name: [value];
}

#layer[zoom>11][value='100'],[zoom>11][value='300'],[zoom>11][value='500'],[zoom>11][value='700'],[zoom>11][value='900'],[zoom>11][value='1100'],[zoom>11][value='1300'],[zoom>11][value='1500'],[zoom>11][value='1700'],[zoom>11][value='1900'],[zoom>11][value='2100'] {
  line-width: 1.0;
  line-color: #4b3ebc;
  line-opacity: 1;
  text-face-name: 'DejaVu Sans Book';
  text-name: [value];
}

#layer[zoom>12][value='50'],[zoom>12][value='150'],[zoom>12][value='250'],[zoom>12][value='350'],[zoom>12][value='450'],[zoom>12][value='550'],[zoom>12][value='650'],[zoom>12][value='750'],[zoom>12][value='850'],[zoom>12][value='950'],[zoom>12][value='1050'],[zoom>12][value='1150'],[zoom>12][value='1250'],[zoom>12][value='1350'],[zoom>12][value='1450'],[zoom>12][value='1550'],[zoom>12][value='1650'],[zoom>12][value='1750'],[zoom>12][value='1850'],[zoom>12][value='1950'],[zoom>12][value='2050'],[zoom>12][value='2150'] {
  line-width: 0.7;
  line-color: #4b3ebc;
  line-opacity: 1;
  text-face-name: 'DejaVu Sans Book';
  text-name: [value];
}

I won't post the same CSS expressed the verbose way - if you consider the way those OR conditions decompose, clearly it's a lot more repetitive.

(I should note that in fact I use Postman, not cURL, but all the docs talk about cURL, so I thought I'd use the same language here.)

1

The correct way to do it would be:

    #layer[zoom > 10][value='200'] {  
line-width: 1.5;   
line-color: #4b3ebc;   
line-opacity: 1; 
}



 #layer[zoom > 10][value='300'] {   
line-width: 1.5;   
line-color: #4b3ebc;   
line-opacity: 1; 
}
 etc

I'm seeing that according the syntax the values are string types, I would transform them to a numeric type and apply a similar syntax to avoid writing so many conditions:

 #layer[zoom > 10][value > 200] {  
    line-width: 1.5;   
    line-color: #4b3ebc;   
    line-opacity: 1; 
    }
  • Thanks Oriol - I realised my question hadn't clearly shown that Builder accepts the more concise syntax (the second code sample) while cURL does not. I've edited the question now. Is there a reason for the difference? – OutstandingBill Oct 8 '17 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.