{"id":6385,"date":"2023-01-10T14:33:07","date_gmt":"2023-01-10T11:03:07","guid":{"rendered":"https:\/\/en.geobox.ir\/developers\/?post_type=docs&#038;p=6385"},"modified":"2023-01-21T09:04:25","modified_gmt":"2023-01-21T05:34:25","slug":"map-object","status":"publish","type":"docs","link":"https:\/\/en.geobox.ir\/developers\/docs\/map-geobox-api-for-leaflet\/map-object\/","title":{"rendered":"Map object"},"content":{"rendered":"<h2>Properties:<\/h2>\n<h3>Lmap<\/h3>\n<p>Returns the leaflet map object. After you access the leaflet map object, all the methods and properties of the leaflet library can be applied to it.<\/p>\n<p id=\"zoomin-returns\" class=\"unprose txt-m mb3 anchor mt12\"><strong>Returns:<\/strong><\/p>\n<p class=\"unprose txt-m mb3 anchor mt12\"><a href=\"https:\/\/leafletjs.com\/\">Leaflet map<\/a>: Returns leaflet map object.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const leafletMap = map.Lmap;<\/pre>\n<h3>_boundsLayer<\/h3>\n<p>Returns the extent information drawn on the map.<\/p>\n<p id=\"zoomin-returns\" class=\"unprose txt-m mb3 anchor mt12\"><strong>Returns:<\/strong><\/p>\n<p class=\"unprose txt-m mb3 anchor mt12\">Object: Returns bounding box information.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const bBoxInfo= map._boundsLayer;<\/pre>\n<h2>Methods:<\/h2>\n<h3>addBaseLayer(baseMap, showAsDefault)<\/h3>\n<p>Adds base map to the map.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>baseMap is an object contains base map information. Choices are: GL.BaseLayers.OSM | GL.BaseLayers.Google | GL.BaseLayers.Mapbox (<a href=\"https:\/\/en.geobox.ir\/developers\/docs\/geobox-api-for-leaflet\/quick-installation-2\/\">GL is geobox-leaflet.js object<\/a>).<\/p>\n<p>showAsDefault is a boolean parameter. If true, this base map is used as the default base map.<\/p>\n<p id=\"zoomin-returns\" class=\"unprose txt-m mb3 anchor mt12\"><strong>Returns:<\/strong><\/p>\n<p class=\"unprose txt-m mb3 anchor mt12\">String: Returns a message that shows adding base map was successful or not. Null message means adding was successful.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const result = map.addBaseLayer(GL.BaseLayers.OSM, true);<\/pre>\n<h3>zoomToBounds(latLngBounds, padding)<\/h3>\n<p>Zooms to the specified bounding box.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>latLngBounds (Object): <a href=\"https:\/\/leafletjs.com\/reference.html#latlngbounds\">Leaflet latLngBounds<\/a> object.<\/p>\n<p>padding is a number to create space between the bounds and the map.<\/p>\n<p id=\"zoomin-returns\" class=\"unprose txt-m mb3 anchor mt12\"><strong>Returns:<\/strong><\/p>\n<p class=\"unprose txt-m mb3 anchor mt12\">String: Returns a message that shows zooming was successful or not. Null message means zooming was successful.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">vat\u00a0bounds\u00a0=\u00a0L.latLngBounds([35,51],[36,52]);\r\nconst result = map.zoomToBounds(bounds, 5);<\/pre>\n<h3>zoomToWorld()<\/h3>\n<p>Zooms to the whole world extent.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const result = map.zoomToWorld();<\/pre>\n<h3>showSpinner()<\/h3>\n<p>Activates the spinner on the map. You can use this method before starting the time-consuming processes.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">map.showSpinner();<\/pre>\n<h3>hideSpinner()<\/h3>\n<p>Deactivates the spinner.<\/p>\n<p>Example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">map.hideSpinner();<\/pre>\n<h3>openDialog(options)<\/h3>\n<p>Opens a new window to display information. This window can contain any information. This window can be moved.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>options (Object)<\/p>\n<table class=\"table table--fixed table--compact\" style=\"width: 100%;\">\n<thead>\n<tr class=\"bg-gray-faint\">\n<th style=\"text-align: left; width: 17.9841%;\">Name<\/th>\n<th style=\"text-align: left; width: 81.9434%;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left; width: 17.9841%;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.content<\/div>\n<div>Any<\/div>\n<\/td>\n<td style=\"text-align: left; width: 81.9434%;\">content can be a message string or can be any HTML element.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; width: 17.9841%;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.width<\/div>\n<div>Number?<\/div>\n<\/td>\n<td style=\"text-align: left; width: 81.9434%;\">width of the dialog window in pixel.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; width: 17.9841%;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.height<\/div>\n<div>Number?<\/div>\n<\/td>\n<td style=\"text-align: left; width: 81.9434%;\">height of the dialog window in pixel.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p id=\"zoomin-returns\" class=\"unprose txt-m mb3 anchor mt12\"><strong>Returns:<\/strong><\/p>\n<p>Object: Returns dialog object.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const dialog = map.openDialog({content: 'Welcome to Geobox', width: 300, height: 100});<\/pre>\n<h3>closeDialog()<\/h3>\n<p>Closes the existing dialog window.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">map.closeDialog();<\/pre>\n<h3>showMessage(message)<\/h3>\n<p>Opens a new window to display the desired message.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>message is a string that you want to show.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">map.showMessage('Welcome to Geobox');<\/pre>\n<h3>startDrawingBounds()<\/h3>\n<p>Puts the map into draw mode so you can draw a bounding box.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">map.startDrawingBounds();<\/pre>\n<p>After drawing the bounding box, you can access the coordinates of the drawn bounding box using <a href=\"https:\/\/en.geobox.ir\/developers\/docs\/map-geobox-api-for-leaflet\/map-object\/#2-toc-title\">_boundsLayer<\/a>.<\/p>\n<h3>cancelDrawingBounds()<\/h3>\n<p>Deactivates draw mode.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">map.cancelDrawingBounds();<\/pre>\n<h3>displayBounds(latLngBounds)<\/h3>\n<p>Displays the bounding box on the map.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>latLngBounds (Object): <a href=\"https:\/\/leafletjs.com\/reference.html#latlngbounds\">Leaflet latLngBounds<\/a> object.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">map.displayBounds({'_southWest':\u00a0{'lat':\u00a031,'lng':\u00a052},'_northEast':\u00a0{'lat':\u00a034,'lng':\u00a057}});<\/pre>\n<h3>clearBounds()<\/h3>\n<p>Deletes the existing drawn bounding box on the map.<\/p>\n<p>Example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">map.clearBounds();<\/pre>\n<h3>addButton(options)<\/h3>\n<p>Adds a new button on the map. When it is clicked, the function defined for it will be executed.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>options (Object)<\/p>\n<table class=\"table table--fixed table--compact\" style=\"width: 100%;\">\n<thead>\n<tr class=\"bg-gray-faint\">\n<th style=\"text-align: left; width: 17.9841%;\">Name<\/th>\n<th style=\"text-align: left; width: 81.9434%;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left; width: 17.9841%;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.name<\/div>\n<div>String<\/div>\n<\/td>\n<td style=\"text-align: left; width: 81.9434%;\">Name of button.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; width: 17.9841%;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.tooltip<\/div>\n<div>String<\/div>\n<\/td>\n<td style=\"text-align: left; width: 81.9434%;\">Tooltip of button.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; width: 17.9841%;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.color<\/div>\n<div>String<\/div>\n<\/td>\n<td style=\"text-align: left; width: 81.9434%;\">Color of icon. Choices are: rgb color |\u00a0 rgba color | hex color.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; width: 17.9841%;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.icon<\/div>\n<div>String<\/div>\n<\/td>\n<td style=\"text-align: left; width: 81.9434%;\">Name of icon in <a href=\"https:\/\/fonts.google.com\/icons\">google icons library<\/a>. (Google icons library should be added to the project)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; width: 17.9841%;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.click<\/div>\n<div>Function<\/div>\n<\/td>\n<td style=\"text-align: left; width: 81.9434%;\">Function that triggers when the button is clicked.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p id=\"zoomin-returns\" class=\"unprose txt-m mb3 anchor mt12\"><strong>Returns:<\/strong><\/p>\n<p>Object: Returns button object.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Tip: The fLayer is described in the <a href=\"https:\/\/en.geobox.ir\/developers\/docs\/features\/create-feature-layer-and-add-to-map\/\">featureLayer construction<\/a> section.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const zoomBtn = map.addButton({\r\n   name: 'zoom',\r\n   tooltip: 'zoom to feature with id 100',\r\n   color: 'red',\r\n   icon: 'zoom_in',\r\n   click: () =&gt; {\r\n      fLayer.zoomTo(100);\r\n   }\r\n})<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Properties: Lmap Returns the leaflet map object. After you access the leaflet map object, all the methods and properties of the leaflet library can be applied to it. Returns: Leaflet map: Returns leaflet map object. Example: const leafletMap = map.Lmap; _boundsLayer Returns the extent information drawn on the map. Returns: Object: Returns bounding box information. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[75],"doc_tag":[],"class_list":["post-6385","docs","type-docs","status-publish","hentry","doc_category-map-geobox-api-for-leaflet"],"_links":{"self":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/6385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/comments?post=6385"}],"version-history":[{"count":17,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/6385\/revisions"}],"predecessor-version":[{"id":6612,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/6385\/revisions\/6612"}],"wp:attachment":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/media?parent=6385"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/doc_category?post=6385"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/doc_tag?post=6385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}