Oracle Maps example - zoom to a specified rectangle

  1. Specify the rectangle here:
  2. Then click here to zoom the map to the above rectangle

Instructions>

This demo shows how to supply a rectangle whose coordinates represent a target area. The map can then be zoomed to cover an area that is as close to (but no smaller than) the target area as possible. Note that due to zoom-level definitions it may not be able to match the target rectangle exactly.

Source code

  var mapview = null;
  
  function showMap()
  {	
    var baseURL  = "http://"+document.location.host+"/mapviewer";
    var mapCenterLon = -122.45;
    var mapCenterLat =  37.6706;
    var mapZoom      =  4;  
    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);    
    mapview.display();  			
  }
  
  
  function zoomToRectangle()
  {
        var rect = "new MVSdoGeometry(2003, 8307, [1,1003,1],["+document.getElementById("rectangleArea").value+"])";
  	var sdoGeo=eval(rect);
        
  	mapview.zoomToRectangle(sdoGeo);
  }
  
And here is how the zoomToRectangle function is invoked:
  <a href="javascript:zoomToRectangle()">Then click here to zoom the map to the above rectangle</a>