• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • Synchronization
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Numeric Values
      • String Values
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
        • Map Statement
        • Map.show Function
        • Map.hide Function
        • Map.clear Function
        • Map.setTitle Function
        • Map.setBaseMap Function
        • Map.zoomTo Function
        • Map.showCurrentLocation Function
        • Map.saveSnapshot Function
        • Map.setOnClick Function
        • Map.getLastClickLatitude Function
        • Map.getLastClickLongitude Function
        • Map.addMarker Function
        • Map.removeMarker Function
        • Map.clearMarkers Function
        • Map.setMarkerImage Function
        • Map.setMarkerText Function
        • Map.setMarkerDescription Function
        • Map.setMarkerOnClick Function
        • Map.setMarkerOnClickInfoWindow Function
        • Map.setMarkerOnDrag Function
        • Map.setMarkerLocation Function
        • Map.getMarkerLatitude Function
        • Map.getMarkerLongitude Function
        • Map.addGeometry Function
        • Map.removeGeometry Function
        • Map.clearGeometry Function
        • Map.addTextButton Function
        • Map.addImageButton Function
        • Map.removeButton Function
        • Map.clearButtons Function
        • Mapping Engine
        • Base Map Specification
        • Offline Maps
      • Path
      • Pff Object
      • StringWriter Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Map.zoomTo Function

Format (Point)
b = map_name.zoomTo(latitude, longitudeʃ, zoom_levelʅ);
Format (Rectangle)
b = map_name.zoomTo(min_latitude, min_longitude,
                   
max_latitude, max_longitudeʃ, paddingʅ);
Format (Geometry)
b = map_name.zoomTo(geometry_nameʃ, paddingʅ);
Description
The Map.zoomTo function pans and zooms a Map to center the map on a given point, or to fit a rectangular region of the map to the screen. The Map.zoomTo function may be used before the map is displayed to set the initial view, or it may be used in a callback function to change the view while the map is showing.
The first format, Point, moves the map so that the point with coordinates (latitude, longitude) is at the center of the screen. If the optional zoom_level is specified, the map is also zoomed to the specified zoom level. The number zoom_level represents the level of detail to show. Zoom level 1 fits the entire world on the screen. Each consecutive zoom level is twice as detailed as the preceding level. Zoom level 15 shows streets, and zoom level 20 shows individual buildings. The minimum and maximum zoom levels supported will depend on the base map being used. If no zoom level is specified, the current zoom level is maintained.
The second format, Rectangle, pans and zooms the map to fit the rectangular region of the map with corners at (min_latitude, min_longitude) and (max_latitude, max_longitude). If optional padding is specified, the map will be zoomed less so that the rectangular region will fit onto the screen with extra padding on each side. This can be used so that the edges of the rectangle do not line up exactly with the edge of the screen. The padding is specified as a percentage of the width of the screen. For example, a padding of 5 would add padding equal to 5% of the device screen width.
The third format, Geometry, is a variant of the rectangular zoom in which the bounds are retrieved from the Geometry object named geometry_name.
If Map.zoomTo is not called before the map is shown, then the initial view is determined in the order listed:
  • If there are any markers, the view is set to fit all of the markers onto the screen.
  • Next, if an offline map file that specifies an extent is used as a base map, the view is set to the extent of the offline map file.
  • Last, the initial view is the entire world.
Return Value
The function returns a logical value of 1 (true) if the map is zoomed/panned and 0 (false) if there is an error (for example, if the rectangle is invalid).
Example 1 (Point)
// Declare a map
Map mymap;

// Set the initial view to center on the point 38.84839, -76.931098 at street level
mymap.zoomTo(38.84839, -76.931098, 15);

// Display the map
mymap.show();
Example 2 (Rectangle)
// Declare a map
Map mymap;

// Set the initial view to fit a rectangular region with 15% padding
mymap.zoomTo(38.841546, -76.937428, 38.853679, -76.911550, 15);

// Display the map
mymap.show();
Example 3 (Geometry)
// Declare a map
Map mymap;

// Populate a Geometry object from a GeoJSON file and add it to the map
Geometry ea_geometry;
ea_geometry.
load("ea-81-03-30.geojson");
mymap.
addGeometry(ea_geometry);

// Set the initial view to fit the GeoJSON with 5% padding
mymap.zoomTo(ea_geometry, 5);

// The above code is identical to:
mymap.zoomTo(ea_geometry.minLatitude(), ea_geometry.minLongitude(),
             ea_geometry.
maxLatitude(), ea_geometry.maxLongitude(), 5);

// Display the map
mymap.show();
See also: Map Object