{"id":6178,"date":"2023-01-02T14:51:34","date_gmt":"2023-01-02T11:21:34","guid":{"rendered":"https:\/\/en.geobox.ir\/developers\/?post_type=docs&#038;p=6178"},"modified":"2023-01-19T14:36:01","modified_gmt":"2023-01-19T11:06:01","slug":"working-with-map","status":"publish","type":"docs","link":"https:\/\/en.geobox.ir\/developers\/docs\/map-geobox-api-for-javascript\/working-with-map\/","title":{"rendered":"Map object"},"content":{"rendered":"<p>Tip: After you access the <a href=\"https:\/\/en.geobox.ir\/developers\/docs\/map-geobox-api-for-javascript\/map-2\/\">map<\/a> object, the following methods and properties are applicable on the map.<\/p>\n<h2>Properties:<\/h2>\n<h3>uuid<\/h3>\n<p>Returns the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Universally_unique_identifier\">universally unique identifier\u00a0(UUID)<\/a> of 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\"><a href=\"https:\/\/www.geobox.ir\/\">uuid<\/a>: Returns uuid string.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapUuid = map.uuid;<\/pre>\n<h3>name<\/h3>\n<p>Returns the name of 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 map name.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapName = map.name;<\/pre>\n<h3>display_name<\/h3>\n<p>Returns the display name of 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 map display name.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapDisplayName = map.display_name;<\/pre>\n<h3>description<\/h3>\n<p>Returns the description of 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 map description.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapDescription = map.description;<\/pre>\n<h3>created_at<\/h3>\n<p>Returns the time and date that the map was created.<\/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\">Date: Returns map created time.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapCreatedTime = map.created_at;<\/pre>\n<h3>last_modified_at<\/h3>\n<p>Returns the time and date that the map is updates.<\/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\">Date: Returns map updated time.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapModifiedTime = map.last_modified_at;<\/pre>\n<h3>is_shared<\/h3>\n<p>Indicates whether the map is shared or not.<\/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\">Bolean: If true, map is shared.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const isShared = map.is_shared;<\/pre>\n<h3>id<\/h3>\n<p>Returns the map id.<\/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\">Number: Returns map id.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapId = map.id;<\/pre>\n<h3>owner_id<\/h3>\n<p>Returns the user ID that the map belongs to.<\/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\">Number: Returns map owner id.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapOwnerId = map.owner_id;<\/pre>\n<h3>extent<\/h3>\n<p>Returns the coordinates of the map extent in the geographic coordinate system.<\/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\">Array: Returns an array includes [southwest lng, southwest lat,\u00a0 northeast lng, northeast lat].<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapExtent = map.extent;<\/pre>\n<h3>settings<\/h3>\n<p>Returns the map settings. These settings include editable layers, layer color settings, etc.<\/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 settings object.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapSettings = map.settings;<\/pre>\n<h2>Methods:<\/h2>\n<h3>getStyle()<\/h3>\n<p>Returns the map style. This function is an asynchronous function.<\/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:\/\/www.geobox.ir\/\">Style<\/a>: Returns style object.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapStyle = await map.getStyle();<\/pre>\n<h3>getThumbnailURL()<\/h3>\n<p>Returns the URL of the map thumbnail.<\/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 thumbnail PNG URL.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapThumbnailUrl = map.getThumbnailURL();<\/pre>\n<h3>updateSettings(options)<\/h3>\n<p>Updates the map settings.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>options (Object)<\/p>\n<table class=\"table table--fixed table--compact\" style=\"width: 82.5238%; height: 343px;\">\n<thead>\n<tr class=\"bg-gray-faint\" style=\"height: 26px;\">\n<th style=\"text-align: left; height: 26px; width: 22.926%;\">Name<\/th>\n<th style=\"text-align: left; height: 26px; width: 103.127%;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 26px;\">\n<td style=\"height: 26px; width: 22.926%; text-align: left;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.general_settings<\/div>\n<div>Object?<\/div>\n<\/td>\n<td style=\"height: 26px; width: 103.127%; text-align: left;\">An object that includes general settings. Keys and values are:<\/p>\n<p>&#8216;map_unit&#8217;: &#8216;latlng&#8217; | &#8216;utm&#8217;<\/p>\n<p>&#8216;base_map&#8217;: &#8216;OSM&#8217; | &#8216;google&#8217; | &#8216;blank&#8217;;<\/p>\n<p>&#8216;flash_color&#8217;: &#8216;rgb(255,0,0)&#8217; (rgb color or rgba color or hex color )<\/p>\n<p>&#8216;highlight_color&#8217;: &#8216;rgb(255,0,0)&#8217; (rgb color or rgba color or hex color )<\/p>\n<p>&#8216;selection_color&#8217;: &#8216;rgb(255,0,0)&#8217; (rgb color or rgba color or hex color )<\/p>\n<p>&#8216;selectable_layers&#8217;: &#8216;ALL&#8217; | null | Comma separated list of layers<\/p>\n<p>&#8216;show_maptip_on&#8217;: &#8216;ALL&#8217; | null | Comma separated list of layers<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 53px; width: 22.926%; text-align: left;\">\n<div><span style=\"font-family: inherit; font-size: inherit;\">options.<\/span><span style=\"font-family: inherit; font-size: inherit;\">edit_settings<\/span><\/div>\n<div>\n<div>Object?<\/div>\n<\/div>\n<\/td>\n<td style=\"height: 53px; width: 103.127%; text-align: left;\">An object that includes edit settings. Keys and values are:<\/p>\n<p>&#8216;target_layer&#8217;: name of a vector layer or vector layer view.<\/p>\n<p>&#8216;editable_layers&#8217;: &#8216;ALL&#8217; | null | Comma separated list of layers<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 53px; width: 22.926%; text-align: left;\">\n<div><span style=\"font-family: inherit; font-size: inherit;\">options.<\/span><span style=\"font-family: inherit; font-size: inherit;\">snap_settings<\/span><\/div>\n<div>\n<div>\n<div>Object?<\/div>\n<\/div>\n<\/div>\n<\/td>\n<td style=\"height: 53px; width: 103.127%; text-align: left;\">An object that includes snap settings. Keys and values are:<\/p>\n<p>snap_tolerance&#8217;: number of pixels for snap tolerance<\/p>\n<p>&#8216;snap_unit&#8217;: &#8216;pixels&#8217;<\/p>\n<p>&#8216;snap_mode&#8217;: &#8216;both&#8217; | &#8216;edge&#8217; | &#8216;vertex&#8217;<\/p>\n<p>&#8216;snap_cache&#8217;: number of total features for snap cache<\/p>\n<p>&#8216;snappable_layers&#8217;: &#8216;ALL&#8217; | null | Comma separated list of layers<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 53px; width: 22.926%; text-align: left;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.search_settings<\/div>\n<div>Object?<\/div>\n<\/td>\n<td style=\"height: 53px; width: 103.127%; text-align: left;\">An object that includes snap settings. Keys and values are:<\/p>\n<p>&#8216;search_mode&#8217;: &#8216;both&#8217; | &#8216;markers&#8217; | &#8216;layers&#8217;<\/p>\n<p>&#8216;search_layers&#8217;: &#8216;ALL&#8217; | null | Comma separated list of layers<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 53px; width: 22.926%; text-align: left;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.marker_settings<\/div>\n<div>Object?<\/div>\n<\/td>\n<td style=\"height: 53px; width: 103.127%; text-align: left;\">An object that includes marker settings. Keys and values are:<\/p>\n<p>&#8216;remvoe_unused_tags&#8217;: true | false<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 53px; width: 22.926%; text-align: left;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.controls<\/div>\n<div>Array?<\/div>\n<\/td>\n<td style=\"height: 53px; width: 103.127%; text-align: left;\">Comma separated list of controls that should be enabled in map.<\/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 class=\"unprose txt-m mb3 anchor mt12\">Object: Returns settings object.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapSettings = await map.updateSettings({\r\n   'general_settings': {\r\n      'map_unit': 'latlng',\r\n      'base_map': 'OSM',\r\n      'flash_color': 'rgb(255,0,0)',\r\n      'highlight_color': '#fbb440',\r\n      'selection_color': '#004cff',\r\n      'selectable_layers': 'ALL',\r\n      'show_maptip_on': null\r\n   },\r\n   'edit_settings': {\r\n      'target_layer': 'vector\/selected-roads',\r\n      'editable_layers': 'ALL'\r\n   },\r\n   'snap_settings': {\r\n      'snap_tolerance': 5,\r\n      'snap_unit': 'pixels',\r\n      'snap_mode': 'both',\r\n      'snap_cache': 500,\r\n      'snappable_layers': 'ALL'\r\n   },\r\n   'search_settings': {\r\n      'search_mode': 'both',\r\n      'search_layers': 'ALL'\r\n   },\r\n   'marker_settings': {\r\n      'remvoe_unused_tags': true\r\n   },\r\n   'controls': [\r\n      'overview',\r\n      'scalebar',\r\n      'searchbar',\r\n      'legend',\r\n      'basemaps',\r\n      'coordinates',\r\n      'measurement',\r\n      'print',\r\n      'gotoxy',\r\n      'location',\r\n      'edit'\r\n   ]\r\n});<\/pre>\n<h3>getMarkers()<\/h3>\n<p>Returns the markers and tags that is stored in the map. This function is an asynchronous function.<\/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 Markers object. This object contains a list of markers location\u00a0and tags object.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const mapMarkers = await map.getMarkers();<\/pre>\n<h3>setMarkers(options)<\/h3>\n<p>Saves the map markers and tags.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>options (Object)<\/p>\n<table class=\"table table--fixed table--compact\" style=\"width: 82.5238%; height: 103px;\">\n<thead>\n<tr class=\"bg-gray-faint\" style=\"height: 26px;\">\n<th style=\"text-align: left; height: 26px; width: 22.926%;\">Name<\/th>\n<th style=\"text-align: left; height: 26px; width: 103.127%;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 26px;\">\n<td style=\"height: 26px; width: 22.926%; text-align: left;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.tags<\/div>\n<div>Object?<\/div>\n<\/td>\n<td style=\"height: 26px; width: 103.127%; text-align: left;\">An object that includes tags and colors.<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 51px; width: 22.926%; text-align: left;\">\n<div><span style=\"font-family: inherit; font-size: inherit;\">options.locations<\/span><\/div>\n<div>\n<div>Array?<\/div>\n<\/div>\n<\/td>\n<td style=\"height: 51px; width: 103.127%; text-align: left;\">An array that includes markers objects<\/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 class=\"unprose txt-m mb3 anchor mt12\">Object: Returns Markers object. This object contains a list of markers location\u00a0and tags object.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const\u00a0mapMarkers = await map.setMarkers({\r\n   'tags': {\r\n      '#general': {\r\n         'color': '#ff0000',\r\n      }\r\n   },\r\n   'locations': [\r\n      {\r\n         'tag': '#general',\r\n         'name': 'test',\r\n         'geometry': [\r\n            51.13162784422988,\r\n            35.766603814763045\r\n          ],\r\n      'description': 'string'\r\n      }\r\n   ]\r\n});<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Tip: After you access the map object, the following methods and properties are applicable on the map. Properties: uuid Returns the universally unique identifier\u00a0(UUID) of the map. Returns: uuid: Returns uuid string. Example: const mapUuid = map.uuid; name Returns the name of the map. Returns: String: Returns map name. Example: const mapName = map.name; display_name [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[65],"doc_tag":[],"class_list":["post-6178","docs","type-docs","status-publish","hentry","doc_category-map-geobox-api-for-javascript"],"_links":{"self":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/6178","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=6178"}],"version-history":[{"count":24,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/6178\/revisions"}],"predecessor-version":[{"id":6586,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/6178\/revisions\/6586"}],"wp:attachment":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/media?parent=6178"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/doc_category?post=6178"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/doc_tag?post=6178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}