Customize Map Zoom Level

Hello Helical Team,

I am using Helical Insight 4.0. In the map, I want to automatically open the map with zoom at a specific location of latitude and longitude. I am trying to use the following script:
var map = L.map(‘map’).setView([51.505, -0.09], 13);

However, the above is not working when put in the JS Editor. Can you give a script to implement above?

Thank You,
Netta.

Hello Netta,

. In order to work with external JS scripts, you need to implement using any of the chart lifecycle methods like preExecution, postExecution, preFetch or postFetch scripts.

Below script is an example of how you can adjust the zoom factor and setView to a specific lat and longitude for the openstreemaps which are integrated.

hi_container.set("preExecution",function(c){
var viz_Options = c.get("viz_Options");
viz_Options.chartOptions["setViewLat"] = 26.746282;
viz_Options.chartOptions["setViewLong"] = 82.70905;
viz_Options.chartOptions["mapZoomLevel"] = 5;
c.set("viz_Options",viz_Options);
});

image

Thank You,
Helical Insight.

Hi,

In the created map based report if you put the below code in the JSEditor it will automatically zoom in to the very first record
Please note that in the below code highlighted in bold & red is the name of latitude and longitude columns which we have. For example if your latitude and longitude column name is dist_lat and dist_long then replace latitude and longitude with dist_lat and dist_long in the below code and then add it in JSEditor.
mapZoomLevel property also you can customize as per the amount of zoom you would like to have when it opens default.

hi_container.set("postFetch",function(c){
var viz_Options = c.get("viz_Options");
var responseData = c.get("responseData");
viz_Options.chartOptions["setViewLat"] = responseData.data[0].latitude;
viz_Options.chartOptions["setViewLong"] = responseData.data[0].longitude;
viz_Options.chartOptions["mapZoomLevel"] = 9;
c.set("viz_Options",viz_Options);
});