Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Color fixes (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
Langston Smith authored Jun 25, 2018
1 parent 24043bf commit 3691ec9
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

import java.io.InputStream;

import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.geometryType;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.linear;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
Expand Down Expand Up @@ -91,10 +91,10 @@ private void setUpDepthFillLayers() {
depthPolygonFillLayer.withProperties(
fillColor(interpolate(linear(),
get("depth"),
stop(5, color(Color.parseColor("#109ED2"))),
stop(10, color(Color.parseColor("#257491"))),
stop(15, color(Color.parseColor("#45667C"))),
stop(30, color(Color.parseColor("#1F3443"))))),
stop(5, rgb(16, 158, 210)),
stop(10, rgb(37, 116, 145)),
stop(15, rgb(69, 102, 124)),
stop(30, rgb(31, 52, 67)))),
fillOpacity(.7f));
// Only display Polygon Features in this layer
depthPolygonFillLayer.setFilter(eq(geometryType(), literal("Polygon")));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mapbox.mapboxandroiddemo.examples.dds;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

Expand All @@ -14,9 +13,9 @@
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.sources.VectorSource;

import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
import static com.mapbox.mapboxsdk.style.expressions.Expression.step;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
Expand Down Expand Up @@ -61,16 +60,15 @@ public void onMapReady(final MapboxMap mapboxMap) {
statePopulationLayer.withSourceLayer("state_county_population_2014_cen");
statePopulationLayer.setFilter(Expression.eq(get("isState"), literal(true)));
statePopulationLayer.withProperties(
fillColor(step((get("population")), color(Color.BLACK),
stop(0, color(Color.parseColor("#F2F12D"))),
stop(750000, color(Color.parseColor("#EED322"))),
stop(1000000, color(Color.parseColor("#DA9C20"))),
stop(2500000, color(Color.parseColor("#CA8323"))),
stop(5000000, color(Color.parseColor("#B86B25"))),
stop(7500000, color(Color.parseColor("#A25626"))),
stop(10000000, color(Color.parseColor("#8B4225"))),
stop(25000000, color(Color.parseColor("#723122")))
)),
fillColor(step((get("population")), rgb(0,0,0),
stop(0, rgb(242,241,45)),
stop(750000, rgb(238,211,34)),
stop(1000000, rgb(218,156,32)),
stop(2500000, rgb(202,131,35)),
stop(5000000, rgb(184,107,37)),
stop(7500000, rgb(162,86,38)),
stop(10000000, rgb(139,66,37)),
stop(25000000, rgb(114,49,34)))),
fillOpacity(0.75f)
);

Expand All @@ -80,17 +78,16 @@ public void onMapReady(final MapboxMap mapboxMap) {
countyPopulationLayer.withSourceLayer("state_county_population_2014_cen");
countyPopulationLayer.setFilter(Expression.eq(get("isCounty"), literal(true)));
countyPopulationLayer.withProperties(
fillColor(step(get("population"), color(Color.TRANSPARENT),
stop(0, color(Color.parseColor("#F2F12D"))),
stop(100, color(Color.parseColor("#EED322"))),
stop(1000, color(Color.parseColor("#E6B71E"))),
stop(5000, color(Color.parseColor("#DA9C20"))),
stop(10000, color(Color.parseColor("#CA8323"))),
stop(50000, color(Color.parseColor("#B86B25"))),
stop(100000, color(Color.parseColor("#A25626"))),
stop(500000, color(Color.parseColor("#8B4225"))),
stop(1000000, color(Color.parseColor("#723122")))
)),
fillColor(step(get("population"), rgb(0,0,0),
stop(0, rgb(242,241,45)),
stop(100, rgb(238,211,34)),
stop(1000, rgb(230,183,30)),
stop(5000, rgb(218,156,32)),
stop(10000, rgb(202,131,35)),
stop(50000, rgb(184,107,37)),
stop(100000, rgb(162,86,38)),
stop(500000, rgb(139,66,37)),
stop(1000000, rgb(114,49,34)))),
fillOpacity(0.75f),
visibility(NONE)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mapbox.mapboxandroiddemo.examples.dds;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

Expand All @@ -12,11 +11,11 @@
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.sources.VectorSource;

import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.match;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
Expand Down Expand Up @@ -63,12 +62,12 @@ public void onMapReady(MapboxMap mapboxMap) {
stop(22, 180f)
)),
circleColor(
match(get("ethnicity"), color(Color.parseColor("#000000")),
stop("white", color(Color.parseColor("#fbb03b"))),
stop("Black", color(Color.parseColor("#223b53"))),
stop("Hispanic", color(Color.parseColor("#e55e5e"))),
stop("Asian", color(Color.parseColor("#3bb2d0"))),
stop("Other", color(Color.parseColor("#cccccc"))))));
match(get("ethnicity"), rgb(0, 0, 0),
stop("white", rgb(251, 176, 59)),
stop("Black", rgb(34, 59, 83)),
stop("Hispanic", rgb(229, 94, 94)),
stop("Asian", rgb(59, 178, 208)),
stop("Other", rgb(204, 204, 204)))));

mapboxMap.addLayer(circleLayer);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mapbox.mapboxandroiddemo.examples.dds;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
Expand All @@ -17,9 +16,9 @@

import java.io.InputStream;

import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.match;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;

/**
Expand Down Expand Up @@ -57,9 +56,9 @@ public void onMapReady(final MapboxMap mapboxMap) {

LineLayer linesLayer = new LineLayer("finalLines", "lines").withProperties(
PropertyFactory.lineColor(
match(get("color"), color(Color.parseColor("#000000")),
stop("red", color(Color.parseColor("#F7455D"))),
stop("blue", color(Color.parseColor("#33C9EB"))))),
match(get("color"), rgb(0, 0, 0),
stop("red", rgb(247, 69, 93)),
stop("blue", rgb(51, 201, 235)))),
PropertyFactory.visibility(Property.VISIBLE),
PropertyFactory.lineWidth(3f)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mapbox.mapboxandroiddemo.examples.extrusions;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
Expand All @@ -20,13 +19,13 @@
import com.mapbox.mapboxsdk.style.sources.VectorSource;

import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.gt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBase;
Expand Down Expand Up @@ -73,9 +72,9 @@ private void addFillsLayer() {
fillsLayer.setFilter(all(lt(get("pkm2"), literal(300000))));
fillsLayer.withProperties(
fillColor(interpolate(exponential(1f), get("pkm2"),
stop(0, color(Color.parseColor("#160e23"))),
stop(14500, color(Color.parseColor("#00617f"))),
stop(145000, color(Color.parseColor("#55e9ff"))))));
stop(0, rgb(22, 14, 35)),
stop(14500, rgb(0, 97, 127)),
stop(145000, rgb(85, 223, 255)))));
mapboxMap.addLayerBelow(fillsLayer, "water");
}

Expand All @@ -85,9 +84,9 @@ private void addExtrusionsLayer() {
fillExtrusionLayer.setFilter(all(gt(get("p"), 1), lt(get("pkm2"), 300000)));
fillExtrusionLayer.withProperties(
fillExtrusionColor(interpolate(exponential(1f), get("pkm2"),
stop(0, color(Color.parseColor("#160e23"))),
stop(14500, color(Color.parseColor("#00617f"))),
stop(145000, color(Color.parseColor("#55e9ff"))))),
stop(0, rgb(22, 14, 35)),
stop(14500, rgb(0, 97, 127)),
stop(145000, rgb(85, 233, 255)))),
fillExtrusionBase(0f),
fillExtrusionHeight(interpolate(exponential(1f), get("pkm2"),
stop(0, 0f),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mapbox.mapboxandroiddemo.examples.styles;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

Expand All @@ -14,6 +13,7 @@
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillLayer;

import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
Expand Down Expand Up @@ -51,10 +51,10 @@ public void onMapReady(final MapboxMap mapboxMap) {
//Set a zoom function to update the color of the water
layer.setProperties(
fillColor(Expression.interpolate(Expression.exponential(1f), zoom(),
stop(1f, Expression.color(Color.GREEN)),
stop(8.5f, Expression.color(Color.BLUE)),
stop(10f, Expression.color(Color.RED)),
stop(18f, Expression.color(Color.YELLOW)))));
stop(1f, rgb(0,209,22)),
stop(8.5f, rgb(10,88,255)),
stop(10f, rgb(255,10,10)),
stop(18f, rgb(251,255,0)))));

mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40.73581, -73.99155), 12), 12000);

Expand Down

0 comments on commit 3691ec9

Please sign in to comment.