cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
Introduction
The following article will explain how to center and zoom scatter map.
Purpose/Benefits
This script allows you to center and zoom a map according to a given latitude and longitude.
Example
In the Example below we want to center the map to China and set the zoom to 8.
Steps

STEP 1 - FIND LATITUDE AND LONGITUDE

You can find the latitude and longitude using google maps

STEP 2 - ADD WIDGET SCRIPT

/********************************************************/ 
/********Set and Center a Map**********/ 
/********************************************************/ 
__first_load__ = true;

widget.on("beforeviewloaded", function (widget, args){

var map = args.options.map;

window.map = map;

});

widget.on("domready", function (widget, args){

if (__first_load__){ 
setTimeout(function () { window.map.setView([39, 116], 8);}, 500); 
} 
__first_load__ = false;

});
For multi-map support, please use the following syntax instead:
widget['__first_load__'] = true;
widget.on("beforeviewloaded", function (w, args){
var map = args.options.map;
window['map_'+w.oid] = map;
});

widget.on("domready", function (w, args){
 if (widget['__first_load__'] ){ 
 setTimeout(function () { window['map_'+w.oid].setView([39, 116], 8);}, 1000); 
 } 
 widget['__first_load__'] = false;
} );
Rate this article:
Version history
Last update:
‎03-02-2023 09:17 AM
Updated by:
Contributors