Oracle Maps example - Bounding theme

Instructions

Bounding theme can be used to tell the map client to automatically adjust the map center and zoom level so that the map covers the bounding box of all the features of a specified theme (the "bounding" theme). This occurs typically during the map intialization stage.

In addition to boudning them, client application can also directly invoke the method MVThemeBasedFOI.zoomToTheme() to achieve the same goal, even after map has been displayed. For example, if you zoom in a couple of times on the above map, you will no longer see all the customers (red dots) of the CUSTOMER theme. If you wish to snap the map back to an area that lets you view all the customers at the same time, you can click the above link to do so.

Source code

The following code shows how to set a theme-based FOI layer as the bounding theme.
  var mapview;
  var themebasedfoi ;
  
  function on_load_mapview() 
  {	
    var baseURL  = "http://"+document.location.host+"/mapviewer";
    var mapCenterLon = -122.45;
    var mapCenterLat =  37.7706;
    var mapZoom      =  5;       
    var mpoint = MVSdoGeometry.createPoint(mapCenterLon,mapCenterLat,8307);
    mapview = new MVMapView(document.getElementById("map"), baseURL);
    mapview.addMapTileLayer(new MVMapTileLayer("mvdemo.demo_map"));   
    mapview.setCenter(mpoint);   
    mapview.setZoomLevel(mapZoom);    
    
    themebasedfoi = new MVThemeBasedFOI('themebasedfoi','mvdemo.customers');
    
    themebasedfoi.setBoundingTheme(true);
    
    mapview.addThemeBasedFOI(themebasedfoi);
    mapview.addNavigationPanel('west');
    mapview.display();
  }
  
  function setVisible(item)
  {
    var themebasedfoi = mapview.getThemeBasedFOI(item.value);	  		
    themebasedfoi.setVisible(!themebasedfoi.isVisible());
  }
When you click on the HTML link to zoom to the theme, this is what's happening behind the scene:
<a href="javascript:themebasedfoi.zoomToTheme()">click here to view all FOIs of the CUSTOMERS theme</a>