Location:

Quick Start

After completing the preparation work, you can develop the map application. This chapter will take you through the basics of using maps, such as creating maps, point markers, pop-ups, event functions, and more.


Create a map

Creating a map requires only one line of code. The map in the constructor parameter is the id of the map container added during the preparation phase, and the developer can set the center point for the map. Attributes such as level, display mode, custom style, etc.:

                    nimap.accessToken="your AK";
                    var map = new nimap.Map({
                            container: 'map',
                            style: '${mapStyle}',
                            Zoom: 11, // ​​Initialize the map level
                            Center: [116.397428, 39.90923] //Initialize the map center point
                    });
                

Point Markers

The JS SDK provides the ability to draw overlays on a map. For example, add a default style Marker method:

                        var marker = new nimap.Marker().setLngLat([116.39, 39.9]);
                        marker.addTo(map);//Add to map
                    

The method of removal is as follows:

                        marker.remove();
                    
TOP