It's the 15th anniversary of Google Maps Platform - Check out the latest news and announcements

Google.Maps.MapLoadRegion

Encapsulates a region of the map to load.

Summary

The method MapsService.MakeMapLoadRegion creates an instance of the MapLoadRegion class to load tiles for the MapsService.

The following code example loads the region of the map that is visible in the main camera's viewport.

MapsService.MakeMapLoadRegion().AddViewport(Camera.main).Load(options);
  

Public functions

AddBounds(Bounds bounds)
Adds rectangular bounds to the map region.
AddCircle(Vector3 center, float radius)
Adds a circular area to the map region.
AddViewport(Camera camera, float maxDistance)
AddViewport(Camera camera, Transform transform, float maxDistance)
Clear()
void
Clears the contents of this region.
Expand(float distance)
Grows the region in every direction by at least the given distance.
Load(GameObjectOptions options)
Loads the portion of the map defined by this region at the zoom level specified by the MapsService.
SetGroundHeight(float height)
Sets the height of the ground plane.
SetLoadingPoint(Vector3? point)
Sets the point in world space where tiles should load first.
UnloadOutside()
Unloads the map outside this region.
UnloadOutside(int zoom)
Unloads the map outside this region, at the specified zoom level.

Public functions

AddBounds

MapLoadRegion AddBounds(
  Bounds bounds
)

Adds rectangular bounds to the map region.

Details
Parameters
bounds
The bounds that define the region.

AddCircle

MapLoadRegion AddCircle(
  Vector3 center,
  float radius
)

Adds a circular area to the map region.

Details
Parameters
center
The center of the circle.
radius
The radius of the circle.

AddViewport

MapLoadRegion AddViewport(
  Camera camera,
  float maxDistance
)

Adds an area to the map region based on the camera's view frustum.

Overrides SetLoadingPoint.

The loaded area of the map is limited by the camera's far clip plane. If this loads too much, especially at shallow camera angles, then it can be limited further by maxDistance. It also loads the Camera to access the camera data in the scene. camera is used to sort the tiles based on their distance from the camera before loading so that tiles that are closest to the camera load first. Note: Calling this method multiple times with different cameras simply sorts the tiles by distance from the last camera.

Details
Parameters
camera
The camera used to limit the area of the map loaded. It is also used to determine which tiles to load first.
maxDistance
The maximum distance from the camera position to load.

AddViewport

MapLoadRegion AddViewport(
  Camera camera,
  Transform transform,
  float maxDistance
)

Adds an area to the map region based on the camera's view frustum and given transform.

Overrides SetLoadingPoint.

The loaded area of the map is limited by the camera's far clip plane. If this loads too much, especially at shallow camera angles, then it can be limited further by maxDistance. It also loads the Camera to access the camera data in the scene. camera is used to sort the tiles based on their distance from the camera before loading so that tiles that are closest to the camera load first. Note: Calling this method multiple times with different cameras simply sorts the tiles by distance from the last camera.

Details
Parameters
camera
The camera used to limit the area of the map loaded. It is also used to determine which tiles to load first.
transform
The Transform used to transform the area of the map region to be loaded. This is usually the Transform of the corresponding MapsService component to ensure that the right amount of geometry is loaded to fill the viewport whenever it is rotated or scaled.
maxDistance
The maximum distance from the camera position to load.

Clear

void Clear()

Clears the contents of this region.

Expand

MapLoadRegion Expand(
  float distance
)

Grows the region in every direction by at least the given distance.

Details
Parameters
distance
The distance to expand by.

Load

MapLoadRegion Load(
  GameObjectOptions options
)

Loads the portion of the map defined by this region at the zoom level specified by the MapsService.

Details
Parameters
options
Game object options. Ignored if a StyleAttachment component is attached to the same GameObject as the relevant MapsService.

SetGroundHeight

MapLoadRegion SetGroundHeight(
  float height
)

Sets the height of the ground plane.

This changes how the region is projected onto the area of the map to load - for example, it changes the plane that the camera frustum is projected onto for AddViewport(Camera, float). It does not change the position of loaded map features.

Details
Parameters
height
Y position of the ground plane.

SetLoadingPoint

MapLoadRegion SetLoadingPoint(
  Vector3? point
)

Sets the point in world space where tiles should load first.

The SDK loads tiles in an order that corresponds to their distance from this point.

The tiles that are closest to this point are loaded first, and then more distant tiles are loaded.

Details
Parameters
point
The point in world space where tiles should load first. You can set this to null, which results in the default unordered tile loading behaviour.

UnloadOutside

MapLoadRegion UnloadOutside()

Unloads the map outside this region.

UnloadOutside

MapLoadRegion UnloadOutside(
  int zoom
)

Unloads the map outside this region, at the specified zoom level.

Details
Parameters
zoom
The zoom level. Zoom levels ranges from 0-21. Only tiles at this zoom level are unloaded.