new SqlView(options)
Class for managing SQL views on layers
Parameters:
Name | Type | Description |
---|---|---|
options |
nyc.carto.SqlView.Options | Constructor options |
- Source:
Fires:
Extends
Methods
off(eventName, evtHdlr, hdlrScopeopt)
Remove a previously connected event handler
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
string | The name of the event to which the handler will be connected | |
evtHdlr |
function | The event handler function | |
hdlrScope |
Object |
<optional> |
The scope in which to invoke the event handler |
- Inherited From:
- Source:
on(eventName, evtHdlr, hdlrScopeopt)
Connect a function to an event
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
string | The name of the event to which the handler will be connected | |
evtHdlr |
function | The event handler function | |
hdlrScope |
Object |
<optional> |
The scope in which to invoke the event handler |
- Inherited From:
- Source:
one(eventName, evtHdlr, hdlrScopeopt)
Connect a function to an event for a single invocation
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
string | The name of the event to which the handler will be connected | |
evtHdlr |
function | The event handler function | |
hdlrScope |
Object |
<optional> |
The scope in which to invoke the event handler |
- Inherited From:
- Source:
replace(str, values) → {string}
Replace tokens in a string with values from a provided object
Parameters:
Name | Type | Description |
---|---|---|
str |
string | String with tokens to be replaced |
values |
Object.<string, string> | Values token for replacement |
- Inherited From:
- Source:
Returns:
String with replacement value substitution
- Type
- string
sql(template, values, filtersopt) → {string}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
template |
string | The SQL template with optional replacement tokens | |
values |
Object.<string, Object.<string, string>> | The replacement values | |
filters |
Object.<string, string> |
<optional> |
The filters to append to the WHERE clause (i.e. ) |
- Inherited From:
- Source:
Returns:
The SQL statement
- Type
- string
Example
var template = "SELECT * FROM bike WHERE ${where}";
var values = {
color: {value: "red"},
gear: {low: 10, high: 18}
};
var filters = {
color: "color = '${value}'",
gear: "gear BETWEEN ${low} AND ${high}"
};
var sqlTmpl = nyc.carto.SqlTemplate();
sqlTmpl.sql(template, values, filters);
//Returns "SELECT * FROM bike WHERE color = 'red' AND gear BETWEEN 10 AND 18"
trigger(eventName, dataopt)
Trigger a named event with event data
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
string | The name of the event to trigger | |
data |
Object |
<optional> |
The event data |
- Inherited From:
- Source:
update(filterValues, descriptionValues)
Update the view by modifying the data for the layer
Parameters:
Name | Type | Description |
---|---|---|
filterValues |
Object.<string, Object.<string, string>> | The values object used along with the view's filters and sqlTemlate to modify the query for this view |
descriptionValues |
Object.<string, string> | The values objects for replacing tokens in the descriptionTemplate |
- Source:
Type Definitions
Options
Object type to hold constructor options for nyc.carto.View
Type:
- Object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | A name for the view | |
layer |
cartodb.CartoDBLayer.SubLayer | The layer managed by the view | |
sqlTemplate |
string | The template with optional replacement tokens for generating queries on the layer | |
filters |
Object.<string, string> | The filters used with the sqlTemplate for generating queries on the layer | |
descriptionTemplate |
string |
<optional> |
The template with optional replacement tokens for the chart description |
symbolizer |
nyc.carto.Symbolizer |
<optional> |
The symbolizer used to change the layer's CartoCSS as its underlying data changes |
legend |
nyc.Legend |
<optional> |
The legend for this view |
- Source: