{"id":2794,"date":"2023-12-22T18:59:51","date_gmt":"2023-12-22T18:59:51","guid":{"rendered":"https:\/\/developers.maplink.global\/first-steps\/"},"modified":"2024-10-11T18:57:43","modified_gmt":"2024-10-11T18:57:43","slug":"first-steps","status":"publish","type":"post","link":"https:\/\/developers.maplink.global\/en\/first-steps\/","title":{"rendered":"First steps"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Import the Javascript API<\/strong><\/h2>\n\n\n\n<p>The Maplink&#8217;s Javascript API is publicly available at the url <a href=\"https:\/\/maps.maplink.global\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/maps.maplink.global,<\/a> and can be included in any web page easily with a tag <code>script<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;script src=\"https:\/\/maps.maplink.global\">&lt;\/script><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Create map object<\/strong><\/h2>\n\n\n\n<p>With the API already imported, all you need to do to render a map is define a <code>div<\/code> element on your page, and create an instance of the <code>MaplinkMap<\/code> class associated with this element.<\/p>\n\n\n\n<p>The class constructor waits for two mandatory arguments: the Maplink api key (<strong>client_id<\/strong> used for API authentication), and the <code>id<\/code> of the <code>div<\/code> element where the map will be rendered.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div id=\"map\">&lt;\/div>\n&lt;script>\nconst apiKey = \"[CHAVE DE API]\";\nconst maplink = new MaplinkMap(apiKey, \"map\");\n&lt;\/script><\/pre>\n\n\n\n<p>A third settings argument can optionally be passed when building the map. This argument must be an object, where each property corresponds to a configuration definition.  <\/p>\n\n\n\n<p>The options available are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>renderType<\/code>  &#8211; Accepts string values <code>\"pbf\"<\/code> and <code>\"png\"<\/code>. Selects the format in which the map <em>tiles<\/em> will be sent by the server. By default, the format is <em>protobuf <\/em>(pbf), which uses the browser&#8217;s graphics acceleration feature via the WebGL API. In environments without <em>WebGL<\/em> support, the png option must be set, otherwise the map cannot be rendered.<\/li>\n\n\n\n<li><code>center<\/code> &#8211; Array with coordinates to define the center point in the initial rendering of the map.<\/li>\n\n\n\n<li><code>zoom<\/code> &#8211; Integer that defines the initial zoom level. This value is passed directly to the Leaflet instance associated with the map. More information can be found at the link: <a href=\"https:\/\/leafletjs.com\/examples\/zoom-levels\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Zoom levels &#8211; Leaflet<\/a>.<\/li>\n\n\n\n<li><code>theme<\/code>\u00a0\u2013 Theme in which the map will be displayed. The available options are:\u00a0<code>\"maplink-custom\"<\/code>(default)\u00a0and\u00a0<code>\"basic-preview\"<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>Below is an example of initializing the map with optional parameters:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">const options = {\n  renderType: \"pbf\",\n  center: [-23.545344, -46.657384],\n  zoom: 17,\n  theme: \"maplink-custom\"\n};\n\nconst map = new MaplinkMap(apiKey, \"map\", options);<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Import the Javascript API The Maplink&#8217;s Javascript API is publicly available at the url https:\/\/maps.maplink.global, and can be included in any web page easily with a tag script: Create map object With the API already imported, all you need to do to render a map is define a div element on your page, and create [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[169],"tags":[],"class_list":["post-2794","post","type-post","status-publish","format-standard","hentry","category-map-display-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/comments?post=2794"}],"version-history":[{"count":4,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2794\/revisions"}],"predecessor-version":[{"id":3066,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2794\/revisions\/3066"}],"wp:attachment":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/media?parent=2794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/categories?post=2794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/tags?post=2794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}