logo
Tutorials Examples naver map js api v3 네이버 지도 API Abbreviations

Abbreviations

Namespaces

The NAVER Maps API v3 uses the naver.maps namespace, and also provides the N namespace, an abbreviation for user convenience.

The N namespace is valid only if the global variable is not used when the NAVER Maps API v3 is loaded.

// Full expression
var map = new naver.maps.Map('map', {
    center: new naver.maps.LatLng(37.3595704, 127.105399),
    zoom: 10
});

// Abbreviated expression
var map2 = new N.Map('map', {
    center: new N.LatLng(37.3595704, 127.105399),
    zoom: 10
});

naver.maps === N; // true

You can also use a custom namespace as shown in the following code example.

var MyNS = naver.maps;

var map = new MyNS.Map('map', {
    center: new MyNS.LatLng(37.3595704, 127.105399),
    zoom: 10
});

Basic class factory methods

The NAVER Maps API v3 enables you to create an instance of a frequently used base class by a factory method.

Base classes supporting factory methods are listed below:

An instance created by a factory method behaves the same way as using the new keyword.

Using factory methods with abbreviated namespaces makes your code simpler.

var cityHall = naver.maps.LatLng(37.5666805, 126.9784147);
var cityHall2 = N.LatLng(37.5666805, 126.9784147);

cityHall.equals(cityHall2); // true

var point = naver.maps.Point(10, 20);
var point2 = N.Point(10, 20);

var dokdo = naver.maps.LatLngBounds(
    naver.maps.LatLng(37.2380651, 131.8562652),
    naver.maps.LatLng(37.2444436, 131.8786475));
var dokdo2 = N.LatLngBounds(
    N.LatLng(37.2380651, 131.8562652),
    N.LatLng(37.2444436, 131.8786475));

var size = naver.maps.Size(300, 400);
var size2 = N.Size(300, 400);

Literal expressions of base classes

The NAVER Maps API v3 allows you to use literal expressions, instead of instance objects of the frequently used base classes listed below.

Two types of literal expressions are available: object literals and array literals.

Object literals

An Object literal is a general object that represents all properties of an object.
The SizeObject literal must contain width and height properties.
The PointObject or LatLngObject literal must contain x and y, or lat and lng properties respectively; the PointBoundsObject or LatLngBoundsObject literal must contain minX, minY, maxX, and maxY, or south, west, north, and east properties respectively.

SizeObject literal

You can use the SizeObject literal, rather than the naver.maps.Size class.
The SizeObject literal is a general object that contains width and height properties.

var size = new naver.maps.Size(1024, 768),
    sizeObject = {
        width: 1024,
        height: 768
    };

map.setSize(sizeObject);

PointObject literal

You can use the PointObject literal, rather than the naver.maps.Point class.
The PointObject literal is a general object that contains x and y properties.

var point = new naver.maps.Point(64, 128),
    pointObject = {
        x: 64,
        y: 128
    };

map.setCenterPoint(pointObject);

LatLngObject literal

You can use the LatLngObject literal, rather than the naver.maps.LatLng class.
The LatLngObject literal is a general object that contains lat and lng properties.

var latlng = new naver.maps.LatLng(37.5666103, 126.9783882),
    latlngObject = {
        lat: 37.5666103,
        lng: 126.9783882
    };

map.setCenter(latlngObject);

The PointObject literal can also be used where the LatLngObject literal can be used.

PointBoundsObject literal

You can use the PointBoundsObject literal, rather than the naver.maps.PointBounds class.
The PointBoundsObject literal is a general object that contains minX, minY, maxX, and maxY properties.

var pointBounds = new naver.maps.PointBounds(
                new naver.maps.Point(125, 36),
                new naver.maps.Point(128, 38)),
    pointBoundsObject = {
        minX: 125,
        minY: 36,
        maxX: 128,
        maxY: 37
    };

map.fitBounds(pointBoundsObject);

LatLngBoundsObject literal

You can use the LatLngBoundsObject literal, rather than the naver.maps.LatLngBounds class.
The LatLngBoundsObject literal is a general object that contains south, west, north, and east properties.

var latlngBounds = new naver.maps.LatLngBounds(
                new naver.maps.LatLng(36, 125),
                new naver.maps.LatLng(38, 128)),
    latlngBoundsObject = {
        south: 36,
        west: 125,
        north: 38,
        east: 128
    };

map.fitBounds(latlngBoundsObject);

The PointBoundsOBject literal can also be used where the LatLngBoundsObject literal can be used.

Array literals

The Array literal represents an array, elements of which are listed in GeoJSON order.
Elements of the SizeArray literal are listed in the order of width and height.
Elements of the PointArray literal are listed in the order of x and y, or lng and lat, while four elements of the PointBoundsArray literal are listed in the order of minX, minY, maxX, and maxY, or west, south, east, and north.

SizeArray literal

You can use the SizeArray literal, rather than the naver.maps.Size class.
The SizeArray literal is an array object, which is in the order of [width, height].

var size = new naver.maps.Size(1024, 768),
    sizeArray = [1024, 768];

map.setSize(sizeArray);

PointArray literal

You can use the PointArray literal, rather than the naver.maps.Point class.
The PointArray literal is an array object, which is in the order of [x, y] or [lng, lat].

var latlng = new naver.maps.LatLng(37.5666103, 126.9783882),
    pointArray = [126.9783882, 37.5666103];

map.setCenter(pointArray);

PointBoundsArray literal

You can use the PointBoundsArray literal, rather than the naver.maps.PointBounds class.
The PointBoundsArray literal is an array object, which is in the order of [minX, minY, maxX, maxY] or [west, south, east, north].

var latlngBounds = new naver.maps.LatLngBounds(
                new naver.maps.LatLng(36, 125),
                new naver.maps.LatLng(38, 128)),
    pointBoundsArray = [125, 36, 128, 38];

map.fitBounds(pointBoundsArray);