{"id":5787,"date":"2022-12-20T10:46:11","date_gmt":"2022-12-20T07:16:11","guid":{"rendered":"https:\/\/en.geobox.ir\/developers\/?post_type=docs&#038;p=5787"},"modified":"2023-01-21T15:47:36","modified_gmt":"2023-01-21T12:17:36","slug":"add-vector-layer","status":"publish","type":"docs","link":"https:\/\/en.geobox.ir\/developers\/docs\/add-sources\/add-vector-layer\/","title":{"rendered":"Add vector layer"},"content":{"rendered":"<p>To add a vector layer or vector layer view to the map, first copy the uuid of the vector layer from the geobox portal and<a href=\"https:\/\/en.geobox.ir\/developers\/docs\/vector\/working-with-vectorlayer\/#4-toc-title\"> get the vector layer from the server<\/a>: (examples are explained for vector layer, but the same is true for vector layer view.)<\/p>\n<h3>getVectorLayer (layer_uuid)<\/h3>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const vectorLayer = await Server.getVectorLayer ('4f9f3e4b-4dc1-469b-83ab-00ae00f02581');<\/pre>\n<p>Then add the vector layer to the map as follows.<\/p>\n<h3>addVectorLayer(vectorLayer, options)<\/h3>\n<p><strong>Parameters:<\/strong><\/p>\n<p>vectorLayer is the vector layer or vector layer view that is got from the server.<\/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: 23.2775%;\">Name<\/th>\n<th style=\"text-align: left; height: 26px; width: 102.776%;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 26px;\">\n<td style=\"height: 26px; width: 23.2775%; text-align: left;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.<span style=\"font-family: inherit; font-size: inherit;\">selection_color<\/span><\/div>\n<div>String?<\/div>\n<\/td>\n<td style=\"height: 26px; width: 102.776%; text-align: left;\">Sets selection color for this layer. rgb, rgba and hexadecimal values are accepted.<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 51px; width: 23.2775%; text-align: left;\">\n<div><span style=\"font-family: inherit; font-size: inherit;\">options.<\/span><span style=\"font-family: inherit; font-size: inherit;\">highlight_color<\/span><\/div>\n<div>String?<\/div>\n<\/td>\n<td style=\"height: 51px; width: 102.776%; text-align: left;\">Sets <span style=\"font-family: inherit; font-size: inherit;\">highlight <\/span>color for this layer. rgb, rgba and hexadecimal values are accepted.<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 51px; width: 23.2775%; text-align: left;\">\n<div><span style=\"font-family: inherit; font-size: inherit;\">options.<\/span><span style=\"font-family: inherit; font-size: inherit;\">paint<\/span><\/div>\n<div>object?<\/div>\n<\/td>\n<td style=\"height: 51px; width: 102.776%; text-align: left;\">Object of layer style based on <a href=\"https:\/\/maplibre.org\/maplibre-gl-js-docs\/style-spec\/\">maplibre standard<\/a>.<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 51px; width: 23.2775%; text-align: left;\">\n<div><span style=\"font-family: inherit; font-size: inherit;\">options.<\/span><span style=\"font-family: inherit; font-size: inherit;\">type<\/span><\/div>\n<div>String?<\/div>\n<\/td>\n<td style=\"height: 51px; width: 102.776%; text-align: left;\">If you want to add the layer with different geometry type, type of geometry in style can be set here. For example, if you want to add a polygon layer as a polyline layer, use &#8216;Line&#8217;.<\/p>\n<p>Choices are: &#8216;Fill&#8217; | &#8216;Line&#8217; | &#8216;Circle&#8217; | &#8216;Symbol&#8217; | &#8216;Fill Extrusion&#8217;<\/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\">String: Returns a message that shows adding layer 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 = await map.addVectorLayer(vectorLayer,{'paint':{'line-color':'#ff0066'},'type':'line','selection_color':'#0000ff','highlight_color':'#003300'});<\/pre>\n<p class='codepen'  data-height='500' data-theme-id='1' data-slug-hash='MWBWdaK' data-default-tab='result' data-animations='run' data-editable='' data-embed-version='2'>\nSee the Pen <a href=\"https:\/\/codepen.io\/geobox-gl-demo\/pen\/MWBWdaK\">Contact Form \u2013 Pen a Day 20<\/a> by Geobox (<a href=\"https:\/\/codepen.io\/geobox-gl-demo\">@geobox-gl-demo<\/a>) on <a href=\"http:\/\/codepen.io\">CodePen<\/a>.1<\/p>\n<script async src=\"https:\/\/cpwebassets.codepen.io\/assets\/embed\/ei.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>To add a vector layer or vector layer view to the map, first copy the uuid of the vector layer from the geobox portal and get the vector layer from the server: (examples are explained for vector layer, but the same is true for vector layer view.) getVectorLayer (layer_uuid) Example: const vectorLayer = await Server.getVectorLayer [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[56],"doc_tag":[],"class_list":["post-5787","docs","type-docs","status-publish","hentry","doc_category-add-sources"],"_links":{"self":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/5787","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=5787"}],"version-history":[{"count":12,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/5787\/revisions"}],"predecessor-version":[{"id":6648,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/5787\/revisions\/6648"}],"wp:attachment":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/media?parent=5787"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/doc_category?post=5787"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/doc_tag?post=5787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}