# Dec 11th, 2019 \[EN\]\[Kibana\] Maps getting even better with 7.5: A practical example

**URL:** <https://discuss.elastic.co/t/dec-11th-2019-en-kibana-maps-getting-even-better-with-7-5-a-practical-example/211289>\
**Category:** Advent Calendar\
**Created:** [December 11, 2019, 8:00am UTC](https://discuss.elastic.co/t/dec-11th-2019-en-kibana-maps-getting-even-better-with-7-5-a-practical-example/211289 "2019-12-11T08:00:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![radoondas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radoondas/32/47522_2.png) [@radoondas](https://discuss.elastic.co/u/radoondas)\
**Post date:** [December 11, 2019, 8:00am UTC](https://discuss.elastic.co/t/dec-11th-2019-en-kibana-maps-getting-even-better-with-7-5-a-practical-example/211289/1 "2019-12-11T08:00:03Z")

</div>

# Maps getting even better with 7.5: A practical example

Kibana [Maps](https://www.elastic.co/guide/en/kibana/current/maps.html) were already introduced in version 6.7. Since then each release brought fixes and also many new features and improvements to existing ones.

It was already possible to add color to a location and also custom color map based on chosen document value. This approach is simple and effective for many use cases. Later on we added possibility to use Icons instead of a circle and also coloring based on their value.

With the [release](https://www.elastic.co/blog/kibana-7-5-0-released) of version 7.5 there is a new possibility for how to style your location points you are placing on the layer. As we add many new features to every Kibana release, this little improvement was not even mentioned in the blog post.

## So what does that mean?

A simple but very practical example is public transportation location. With this dataset, you can plot position of public transportation vehicles on the map in real time (or every X seconds/minutes) using Kibana Maps. But not only showing their position, but also style them based on timestamp or 'how old' the location is.

Following image represents how such map can look like. Number of locations are filtered out for simplicity. Dark points are latest and fading over time.

 ![fading-locations](https://us1.discourse-cdn.com/elastic/original/3X/1/4/1439068adba5558ceea7ff1c57b49d950e1aab70.jpeg)

## Before version 7.5

Styling based on [Date](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html) datatype was not possible.

The only option was to use numerical value instead. Even Date datatype is stored in Elasticsearch as date converted to UTC (if the time-zone is specified) and stored as a long number representing milliseconds-since-the-epoch. Kibana Maps was not able to work with the information.

There is a simple workaround which can be used. What if you subtract location’s Timestamp from **now** and store the value in separate field?

That is possible with Kibana [scripted fields](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html).

- In Kibana navigate to _Management -\> Index Patterns_
- Choose your _Index pattern_ where your documents are stored
- Switch to _Scripted fields_ panel
- Click on _Add scripted field_
- Add _name_, choose _Number_ type and enter script you want:

```auto
    ZonedDateTime zdt = doc['date_time2'].value;
    double now = Math.abs(System.currentTimeMillis());
    return (now - zdt.toInstant().toEpochMillis());

```

- Hit _Save field_ to add new numerical field calculated on the fly

 ![scriptedfield](https://us1.discourse-cdn.com/elastic/original/3X/0/5/05c98b87489b74c410f2cdb4432a413da94545ab.png)

**Please make sure that your timestamp is always available or do check if the value exists in your document.**

You can now go to your Kibana Maps layer details where you add locations on the map and change your styling based on new scripted field `age_of_position` as in the following example.

 ![age-of-position](https://us1.discourse-cdn.com/elastic/original/3X/3/8/387aa63cdffe8b503cc5f92d731553a6a653e5ad.png)

Do not forget to Save your changes and check how style of your locations changes over time.

## After version 7.5

With latest release there is nothing easier to do. Instead of creating a new Scripted field, you need to go straight to your layer Styling options and choose Date datatype as it will show up in the list of fields.  
_Note that Date fields were not listed in previous versions for styling when you accessed the list of fields._

Using Date datatype will now do exactly the same job as if using numerical difference between 2 timestamps.

 ![timestamp-styling](https://us1.discourse-cdn.com/elastic/original/3X/1/4/14677d082b3f5b7ca26a13b45545ae348f2a2a24.png)

We always try to improve and add new features and if you have new ideas what we should implement, let us know in [Kibana GitHub](https://github.com/elastic/kibana) repository.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 4, 2022, 7:36am UTC](https://discuss.elastic.co/t/dec-11th-2019-en-kibana-maps-getting-even-better-with-7-5-a-practical-example/211289/2 "2022-11-04T07:36:50Z")

</div>


