Get JSON script code with pushing to heatmap
Scope of Variables

Unless imei is used outside of the code in your post (which would be grounds for making it off-topic), then you should declare it as local to the function using var (or let if you want it to have block scope. The same is true for filtered and heatmap. That way those variables won't be global, which could cause confusion if you did use var to declare a variable inside a function but not before that.

For more information on that topic, see the section Keep your scopes close and your scope even closer on this page. 

Accessing DOM elements multiple times via $()

DOM lookups are slow. It is wise to cache them once in a variable and then refer to the variable when needed. This is also mentioned in the aforementioned article under the section Cache DOM Lookups

Those lookups could be added above the function (possibly assigned in a DOM ready function like jQuery's $(function(){}), though it is argued that isn't necessary with modern browsers):

var map = $('#map');
var selectedVehicles = $('#selectVehicles');
var startDate = $('#startDate');
var endDate = $('#endDate');


Then those variables can be used later on when the function is run- for example:


var url = $('#map').data('request-url2');



Can be updated to use map:

var url = map.data('request-url2');


And map could also be used when setting up the Google Map instance, since presumably that is the same element used for the map.

Using parseInt() without a radix

If you are going to use parseInt(), it is wise to specify the radix using the second parameter - unless you are using a unique number system like hexidecimal, octal, etc. then specify 10 for decimal numbers. 


  Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior. Different implementations produce different results when a radix is not specified, usually defaulting the value to 10.1


So I would update the line:


imei = parseInt($('#selectVehicles').val());



To pass the radix 10:

imei = parseInt($('#selectVehicles').val(), 10);


That way, if a value like 022 is entered, it isn't interpreted as the octal value (I.e. Decimal number 18).



1https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#Parameters