Coordinates Object

Coordinates are the smallest unit to represent geographical information such as the location of a camera or an overlay. Most APIs associated with maps deal with coordinates or areas as a parameter or return value.

Coordinates

The NAVER Maps SDK adopts the Geographic coordinate system that enables every location on the earth to be specified by a set of latitude and longitude as a default coordinate system, and provides associated features. The SDK also allows several other coordinate systems that can be converted into the default coordinate system.

LatLng

LatLng is a class that represents a set of latitude and longitude. The latitude property refers to a latitude, and the longitude property refers to a longitude. All properties of the LatLng class are final, so each of them can be specified by a constructor, and properties of the object once created cannot be modified.

The following code example creates a LatLng object and displays a latitude and longitude as a toast message.

LatLng coord = new LatLng(37.5670135, 126.9783740);

Toast.makeText(context,
    "latitude: " + coord.latitude + ", longitude: " + coord.longitude,
    Toast.LENGTH_SHORT).show();

Java

LatLng coord = new LatLng(37.5670135, 126.9783740);

Toast.makeText(context,
    "latitude: " + coord.latitude + ", longitude: " + coord.longitude,
    Toast.LENGTH_SHORT).show();

Kotlin

val coord = LatLng(37.5670135, 126.9783740)

Toast.makeText(context,
        "latitude: ${coord.latitude}, longitude: ${coord.longitude}",
        Toast.LENGTH_SHORT).show()

Other coordinate systems

The NAVER Maps SDK supports several coordinate systems other than the LatLng. The following coordinate systems are available:

You can converts other coordinates into the LatLng coordinates by using the toLatLng() method of each class, or vice versa by using the valueOf() static method.

The following code example converts Utmk into LatLng.

Utmk utmk = new Utmk(953935.5, 1952044.1);
LatLng latLng = utmk.toLatLng();

Java

Utmk utmk = new Utmk(953935.5, 1952044.1);
LatLng latLng = utmk.toLatLng();

Kotlin

val utmk = Utmk(953935.5, 1952044.1)
val latLng = utmk.toLatLng()

The following code example converts LatLng into Utmk.

LatLng latLng = new LatLng(37.5666103, 126.9783882);
Utmk utmk = Utmk.valueOf(latLng);

Java

LatLng latLng = new LatLng(37.5666103, 126.9783882);
Utmk utmk = Utmk.valueOf(latLng);

Kotlin

val latLng = LatLng(37.5666103, 126.9783882)
val utmk = Utmk.valueOf(latLng)

MBR

With two coordinates representing south-western and north-eastern vertices respectively, you can create a rectangular shaped area. This is known as the Minimum bounding rectangle (MBR). MBRs are the simplest way to define an area, so they are frequently used by the APIs handling areas.

LatLngBounds

LatLngBounds is a class that represents an MBR that is composed of latitude and longitude coordinates. The southWest property represents south-western coordinates, and the northEast property represents north-eastern coordinates. All properties of the LatLngBounds class are final, so each of them can be specified by a constructor, and properties of the object once created cannot be modified.

The following code example creates a LatLngBounds object.

LatLng southWest = new LatLng(31.43, 122.37);
LatLng northEast = new LatLng(44.35, 132);
LatLngBounds bounds = new LatLngBounds(southWest, northEast);

Java

LatLng southWest = new LatLng(31.43, 122.37);
LatLng northEast = new LatLng(44.35, 132);
LatLngBounds bounds = new LatLngBounds(southWest, northEast);

Kotlin

val southWest = LatLng(31.43, 122.37)
val northEast = LatLng(44.35, 132.0)
val bounds = LatLngBounds(southWest, northEast)

Builder

Using LatLngBounds.Builder, you can create an MBR including a series of coordinates. Create a builder object, call the include() method to specify coordinates to include in the area, and then call the build() method, and a LatLngBounds object for the area including all the coordinates specified with the include() method is created.

The following code example creates a LatLngBounds object using the LatLngBounds.Builder.

LatLngBounds bounds = new LatLngBounds.Builder()
    .include(new LatLng(37.5640984, 126.9712268))
    .include(new LatLng(37.5651279, 126.9767904))
    .include(new LatLng(37.5625365, 126.9832241))
    .include(new LatLng(37.5585305, 126.9809297))
    .include(new LatLng(37.5590777, 126.974617))
    .build();

Java

LatLngBounds bounds = new LatLngBounds.Builder()
    .include(new LatLng(37.5640984, 126.9712268))
    .include(new LatLng(37.5651279, 126.9767904))
    .include(new LatLng(37.5625365, 126.9832241))
    .include(new LatLng(37.5585305, 126.9809297))
    .include(new LatLng(37.5590777, 126.974617))
    .build();

Kotlin

val bounds = LatLngBounds.Builder()
        .include(LatLng(37.5640984, 126.9712268))
        .include(LatLng(37.5651279, 126.9767904))
        .include(LatLng(37.5625365, 126.9832241))
        .include(LatLng(37.5585305, 126.9809297))
        .include(LatLng(37.5590777, 126.974617))
        .build()

results matching ""

    No results matching ""