Mapbox Android: How to set padding in Location Layer plugin

1 min read

LocationLayer plugin allows changing most of style defining custom  styles in res but for padding we have to use LocationLayerOptions to set  padding.
Here’s an example to set padding on top, to shift camera a bit below.

LocationLayerOptions options = locationLayerPlugin
                    .getLocationLayerOptions() // Get current options
                    .toBuilder() // Convert to LocationLayerOptions.Builder
                    .padding(new int[]{0, 800, 0, 0}) // Change padding (Left, Top, Right, Bottom)
                    .build(); // Build back with new padding
locationLayerPlugin.applyStyle(options); //Set new options

It took me a while to figure this, hope this will be helpful for someone. Let me know if you know any better implementation in comments below.

Mapbox Android: Animate Icon Size

1 min read

We can animate almost any style property of Mapbox elements using ValueAnimator class in Android (minSdk 11).  Here’s an example using Mapbox recommended method customization using Source Layer+ Expression Styles:

Style Expression


Animate Property Value

ValueAnimator markerAnimator = new ValueAnimator();
markerAnimator.setObjectValues(1f, 1.5f, 1f);
markerAnimator.addUpdateListener(animation -> {
    animatePoint.addNumberProperty("icon-size", (float) animation.getAnimatedValue());
    //geoJsonSource is of class GeoJsonSource, featureCollection is of clas FeatureCollection and animatePoint is Feature residing in featureCollection

You can, obiviously, use any Expression in style layer with and customize animatation using many customization method of ValueAnimator class (such as duration, repeat, custom interpolator).

Let me know if you any question in comments below.

So, Make As Many Mistakes As You Can

1 min read

It is wrongly assumed that mistakes are not good.
Mistakes are good, NOT learning from your mistake is NOT good.
Learning from our mistakes is essential to positively move forward.

Here, I’m NOT referencing  to any particular “mistakes”.  Mistakes might be a mistake you made deciding your career, or a mistake  of leaving a semicolon at end of a syntax. It doesn’t matter.

I do not have much of life experience (Oh, I am young!), although I do have some experience in things I love to do.

Let’s take an example of how making mistake is part of my “exploring” process:  Whenever I start learning something new*, whether from book or  any other source, I feel that all this stuff is not going to add value  to myself all of sudden and I “want” to learn and deal with something  that is even more advanced. To do so I realize, it’s really important to  understand fundamentals thoroughly and then, use that as my Swiss Army  Knife to start the journey of exploration.

Exploration does not mean understanding what already has been  documented but instead looking at your individual perspective,  invoking** curiosity, making mistakes, asking question, getting answer  and of course feeling better. It is all part of learning the advanced  stuff.

Conclusion is, don’t let your mistakes bring you down, instead use  that as a tool. A tool that reminds you of things that go wrong and the  fact that it is time to make it right. Finally, you’ll have one less mistake to make. :)

Now, I would like to ask you what you have to say about your mistakes? And more importantly, how do you deal with them?

* It can be anything, learning a programming language or a game.
** I don’t think you need to invoke curiosity, it comes naturally as long as you’ve interest in it.