Develop a CartoJSS serializer
See original GitHub issueWriting CartoCSS in ES5 is a bit difficult since it has no backtick strings. So we want to allow CARTO.js users to write JSON CartoCSS or “CartoJSS”:
For example, this CartoJSS:
{
'#continent_points': {
'marker-fill-opacity': 0.9,
'marker-line-color': '#FFF',
'marker-placement': 'point',
'marker-allow-overlap': true,
'[continent="Africa"]': {
'marker-fill': '#A6CEE3'
},
'[continent="Antarctica"]': {
'marker-fill': '#1F78B4'
}
}
}
will be converted to this CartoCSS:
#continent_points {
marker-fill-opacity: 0.9;
marker-line-color: #FFF;
marker-placement: point;
marker-allow-overlap: true;
[continent="Africa"] {
marker-fill: #A6CEE3;
}
[continent="Antarctica"] {
marker-fill: #1F78B4;
}
}
Sources:
cc @makella
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
CartoJSS - Write CartoCSS using a Javascript object - GitHub
Write CartoCSS using a Javascript object. Contribute to CartoDB/CartoJSS development by creating an account on GitHub.
Read more >Tutorial 1: Serialization - Django REST framework
Creating a Serializer class. The first thing we need to get started on our Web API is to provide a way of serializing...
Read more >Creating and Using Serializers - Django REST Framework
To create a basic serializer one needs to import serializers class from rest_framework and define fields for a serializer just like creating ......
Read more >How to use Serializers in the Django Python web framework
Serialization is the process of transforming data into a format that can be stored or transmitted and then reconstructing it.
Read more >DRF Serializer How do I serialize my data and display
You could create a seperate serializer to use with the nested serializer. class SubjectNestedSerializer(serializers.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Jesus89
So I’ve gone through some CartoCSS documentation and pulled out some relevant pieces that I think will be helpful to you and that aren’t covered in the best practices doc.
Since the doc has pretty basic examples, I tried to provide some that are more complex for you to see. If you have any questions please let me know.
Also, this doesn’t necessarily cover everything, but should be a good start. Also, if this is not what you are looking for, let me know that too!
Instances
https://cartocss.readthedocs.io/en/latest/styling_concepts.html#attachments-and-instances
Example:
The one in the doc is good and yes, it can get more complex, but don’t see people doing this too often.
Selectors
By class:
you have two layers that you want to symbolize the same like
poi
andairports
classes:poi.pois
andairports.pois
with the syntax:Filter Selectors
By Zoom and/or Numeric Value
In addition to the docs, there are some alternatives you might see
AND/OR
AND/OR
By Regular Expression
Color Definitions and Functions
https://cartocss.readthedocs.io/en/latest/language_elements.html#color
Example
Float
https://cartocss.readthedocs.io/en/latest/language_elements.html#float
Example
String
https://cartocss.readthedocs.io/en/latest/language_elements.html#float
Example
Numbers
https://cartocss.readthedocs.io/en/latest/language_elements.html#numbers
Functions
https://cartocss.readthedocs.io/en/latest/language_elements.html#numbers
Example
Marker, polygon, line image URL
https://cartocss.readthedocs.io/en/latest/language_elements.html#uri
Closed by https://github.com/CartoDB/CartoJSS