object:setCenter()

Type Function
Object Map
Library native.*
Return value none
Revision Release 2022.3683
Keywords setCenter
See also object:setRegion()

Overview

Moves the displayed map region to a new location, using the new center point but maintaining the zoom level. The final parameter is an optional boolean (default false) that determines whether the transition is animated or happens instantly.

Syntax

object:setCenter( latitude, longitude [, isAnimated] )
latitude (required)

Number. The latitude of the map's center point.

longitude (required)

Number. The longitude of the map's center point.

isAnimated (optional)

Boolean. Specifies whether the transition is animated (true) or happens instantly (false, the default).

Example

local myMap = native.newMapView( 0, 0, display.contentWidth, display.contentHeight )
myMap:setCenter( 37.331692, -122.030456 )