Oracle Maps example - highlight JDBC theme features using a polygon

Follow the steps below.
  1. Click here to enter polygon creation mode, then click on the map to define polygon vertices
  2. When done, click here to close the polygon and highlight customers within it
  3. Click here to remove the highlighted features and the polygon
  4. Please go back to step 1 if you would like to start over.

Instructions

This demo adds a dynamic query-based FOI layer to the map. The FOI layer displays states. You can then draw a polygon on the map using the red line tool, and the client will highlight all the states that interact with the polygon.
The highlighted states are displayed as another dynamic query-based FOI layer. This FOI layer is the same as the original FOI layer except two differences. First, it applies a sdo_filter clause to the original query. The coordinates of redline polygon is used as the filtering geometry. Second, it uses a different color style to "highlight" the states interacting with the polygon. the polygon
Note that for pre-defined theme based FOI, you can use the built-in methods MVThemeBasedFOI.setHighlightOnly() and MVThemeBasedFOI.setFilteringGeom() to highlight features. This is shown in tutorial no. 43. These methods have no effect on JDBC theme-based FOI layers.

Source code

The key JavaScript code for the above map is listed below. The first function, redlineDone(), is invoked as soon as you finish drawing the polygon on the map. The second function highlightTheme() is used to display the highlighted states using a JDBC theme-based FOI layer. The third function is used to clear the highlighted states.
  function redlineDone()
  {
    redline.generateArea();
    var geom = redline.getPolygon();  //this will be our filtering geom
    //alert("ordinates:"  + geom.getOrdinates().toString());
    highlightTheme(geom);    
  }
  
   //this function hilights only the states that interact with the
  //provided filtering geometry.
  function highlightTheme(geom)
  {
    var ordsArray = geom.getOrdinates();
    
    var baseQuery2 = "select geom, state from states "+
                    "where sdo_filter(geom, sdo_geometry(2003, 8307, null,"+
                    "sdo_elem_info_array(1,1003,1), "+
                    "sdo_ordinate_array("+ordsArray.toString()+"))) = 'TRUE'";
                  
    var jdbcTheme2 = "" +
                "" + baseQuery2 +
                ""+
                "" ;               
    highlightStates = new MVThemeBasedFOI('highlightedst',jdbcTheme2);
    
    highlightStates.setRenderingStyle("C.RED"); //set red color as the highlight style

    mapview.addThemeBasedFOI(highlightStates);
  }
  
  function clearHighlights()
  {
    mapview.removeThemeBasedFOI(highlightStates);
    redline.clear();
  }