Setting the Viewing Location and Allowable Zoom Range and Extent of the Map

When you "SetURL()" for a layer, the last parameter determines if you want the scene to zoom to the bounds of the layer (True) or not (False). If you specify False for all the layers, you can then zoom to a specified area on the map using the commands below.

Note that you can only zoom to an area after the StartMap() function call as the function will set the final width and height of the Canvas HTML object.

Zooming to an area

You can specify a location for the center of the map and a zoom level to start at. The zoom values for CanvasMap are 1 for a 1:1 ratio between map units (e.g. meters, degrees, feet) and pixels on the screen. As you zoom out, they decrease as integer values (.e.g -1, -2, -3). As you zoom in they increase as integer vales (e.g. 1, 2, 3, 4, 5).

In the example below, we are zooming into a coordinate that is specified in GoogleMap units. The easy way to determine such a location is to load your layer into a GIS application, put the mouse over the desired spot, and write down the coordinate's x and y values.

Note that this should be done after the "StartMap()" function call so the Canvas HTML element is sized to match the DIV that contains it.

TheCanvasMap.TheView.ZoomTo(-10); // zoomed out by a factor of 2^10	
TheCanvasMap.TheView.SetRefCenter(600000,4500000);

Limiting the area the user can view

You can change the maximum bounds of the map which will limit how far the user can pan the map. You'll almost always want to limit the "Zoom" levels with this as well.

You can easily find the bounds by loading your data into a GIS application and moving the cursor over the corners of the data. Then, enter the x and y coordinate values as shown below.

var TheBounds = 
{
  	XMin: -500000, // left side (usually wester most edge)
	XMax: 2000000, // right side (usually eastern most edge)
	YMin: 3300000, // bottom side (usually southern most edge)
	YMax: 5000000 // top side (usually northern most edge)
}
TheCanvasMap.TheView.SetMaxBounds(TheBounds);
TheCanvasMap.TheView.SetZoomRange(-11,10);