<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by TMaps on Medium]]></title>
        <description><![CDATA[Stories by TMaps on Medium]]></description>
        <link>https://medium.com/@tmapstn?source=rss-6e9b37be5c26------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oPzBQlcITKHTBQuT</url>
            <title>Stories by TMaps on Medium</title>
            <link>https://medium.com/@tmapstn?source=rss-6e9b37be5c26------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:32:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tmapstn/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[MapLibre GL Vector Tiles with TMaps: Dark Mode and 3D]]></title>
            <link>https://medium.com/@tmapstn/maplibre-gl-vector-tiles-with-tmaps-dark-mode-and-3d-972f08030f7e?source=rss-6e9b37be5c26------2</link>
            <guid isPermaLink="false">https://medium.com/p/972f08030f7e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[tunisia]]></category>
            <dc:creator><![CDATA[TMaps]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 13:28:36 GMT</pubDate>
            <atom:updated>2026-10-23T15:31:03.667Z</atom:updated>
            <content:encoded><![CDATA[<p>Raster tiles are pictures of the map. They’re simple and they work everywhere, but what you get is what you get. Vector tiles send the map data itself (roads, buildings, labels) and let the browser draw it. That means the map stays sharp on any screen, zooming is smooth, you can rotate and tilt it, and you can restyle it instantly.</p><p>In this post we’ll use <a href="https://www.tmaps.tn/en/cartes">TMaps</a> vector tiles with <a href="https://maplibre.org/">MapLibre GL JS</a>, the open-source WebGL map library, and build a little style switcher with four styles.</p><p>Live demo: <a href="https://examples.tmaps.tn/03-vector-maplibre-styles/">examples.tmaps.tn/03-vector-maplibre-styles</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cdqsl8aDn88BUcMa.jpg" /></figure><h3>How TMaps vector tiles work</h3><p>You don’t request the tiles yourself. Each style is a JSON document that follows the Mapbox Style Specification:</p><pre>https://tiles.tmaps.tn/v-tile/{style}.json?api_key=YOUR_API_KEY</pre><p>That JSON lists the tile sources, the fonts (glyphs), the icons (sprites) and how every layer should be drawn. MapLibre reads it and fetches the rest on its own. There are four styles to choose from:</p><ul><li>streets: everyday reference map, easy to read streets and points of interest</li><li>dark: dashboards and night mode</li><li>terrain: relief, rivers and topography</li><li>sunny: tourism and retail, warmer colours</li></ul><h3>1. A first vector map</h3><p>You’ll need a TMaps API key from the <a href="https://app.tmaps.tn/">TMaps console</a>, with your domain (and localhost) in its Authorized Domains.</p><pre>&lt;!doctype html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot;&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;<br>  &lt;title&gt;Vector map of Tunisia&lt;/title&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/maplibre-gl@5.6.0/dist/maplibre-gl.css&quot;&gt;<br>  &lt;script src=&quot;https://cdn.jsdelivr.net/npm/maplibre-gl@5.6.0/dist/maplibre-gl.js&quot;&gt;&lt;/script&gt;<br>  &lt;style&gt;<br>    html, body, #map { height: 100%; margin: 0; }<br>  &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;div id=&quot;map&quot;&gt;&lt;/div&gt;<br>  &lt;script&gt;<br>    const API_KEY = &#39;YOUR_API_KEY&#39;;</pre><pre>    const map = new maplibregl.Map({<br>      container: &#39;map&#39;,<br>      style: `https://tiles.tmaps.tn/v-tile/streets.json?api_key=${API_KEY}`,<br>      center: [10.1815, 36.8002], // Tunis, as [lng, lat]<br>      zoom: 12,<br>      maxZoom: 18,<br>    });</pre><pre>    map.addControl(new maplibregl.NavigationControl(), &#39;top-right&#39;);<br>  &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>One thing to watch: MapLibre takes [longitude, latitude], the opposite of Leaflet&#39;s [lat, lng]. Mixing them up is the most common reason a map opens in the middle of the ocean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3JSLYuVd0WQZvG28.jpg" /></figure><h3>2. Switch styles without reloading the map</h3><p>map.setStyle(url) swaps the style but keeps the map, its position and its controls. A basic switcher is only a few lines:</p><pre>const styleUrl = (name) =&gt; `https://tiles.tmaps.tn/v-tile/${name}.json?api_key=${API_KEY}`;</pre><pre>for (const name of [&#39;streets&#39;, &#39;dark&#39;, &#39;terrain&#39;, &#39;sunny&#39;]) {<br>  const button = document.createElement(&#39;button&#39;);<br>  button.textContent = name;<br>  button.addEventListener(&#39;click&#39;, () =&gt; map.setStyle(styleUrl(name)));<br>  document.body.append(button);<br>}</pre><p>Here’s the same view of Tunis in the other three styles. First dark, which works well on dashboards:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rg95nTtr-9pj1VQz.jpg" /></figure><p>Then terrain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tsE8Wi9REVsWnNEl.jpg" /></figure><p>And sunny:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i_KEVSPd9uY7xftJ.jpg" /></figure><h4>Follow the user’s dark mode</h4><p>Since switching is instant, you can simply follow the operating system’s theme:</p><pre>const dark = window.matchMedia(&#39;(prefers-color-scheme: dark)&#39;);<br>const applyTheme = () =&gt; map.setStyle(styleUrl(dark.matches ? &#39;dark&#39; : &#39;streets&#39;));</pre><pre>dark.addEventListener(&#39;change&#39;, applyTheme);<br>applyTheme();</pre><h3>3. Tilt and rotate</h3><p>The map is drawn with WebGL, so you can tilt and rotate it, which raster tiles simply can’t do:</p><pre>map.jumpTo({<br>  center: [10.179, 36.799], // Medina of Tunis<br>  zoom: 15.5,<br>  pitch: 60,     // tilt, in degrees<br>  bearing: -25,  // rotation, in degrees<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZPqLx3RYRyNPrcD7.jpg" /></figure><p>Users can do the same thing themselves with a right-click drag on desktop, or two fingers on a phone.</p><h3>4. Customize a style</h3><p>The style JSON is yours to tweak. Download it, change the layers (colours, fonts, which labels show up at which zoom), and host your own copy. Just keep two things in mind:</p><ul><li>the tile URLs in sources must still point to tiles.tmaps.tn with your api_key, because that&#39;s how your usage is authenticated;</li><li>you’re free to change layers, and also glyphs and sprite if you host your own fonts and icons.</li></ul><h3>Raster or vector?</h3><ul><li><strong>Libraries</strong>: raster works with Leaflet, OpenLayers or any XYZ client; vector needs MapLibre GL JS or MapLibre Native.</li><li><strong>High-density screens</strong>: raster is blurry (no @2x yet); vector is always sharp.</li><li><strong>Changing the style</strong>: raster needs new tiles; vector changes instantly, in the browser.</li><li><strong>Rotate and tilt</strong>: only vector.</li><li><strong>Older devices</strong>: raster is very light; vector needs WebGL.</li></ul><p>For a simple map embedded in a page, raster tiles with Leaflet are hard to beat. When the map is the heart of your product, go vector.</p><h3>Going further</h3><ul><li>About TMaps: <a href="https://www.tmaps.tn/en">Tunisia maps, geocoding and routing API</a></li><li>Live demos: <a href="https://examples.tmaps.tn/">examples.tmaps.tn</a></li><li>Source code, MIT licensed: <a href="https://github.com/tmaps-tn/tmaps-snippets">github.com/tmaps-tn/tmaps-snippets</a></li><li>Postman collection: <a href="https://www.postman.com/tmaps-tn/tmaps-api">postman.com/tmaps-tn/tmaps-api</a></li><li>Vector tiles documentation: <a href="https://www.tmaps.tn/documentation/api/vector-tiles">tmaps.tn/documentation</a></li></ul><p>Questions or feedback? Leave a comment or write to support@tmaps.tn.</p><p><em>Originally published on </em><a href="https://dev.to/tmaps/vector-maps-of-tunisia-with-maplibre-gl-4-styles-dark-mode-and-3d-tilt-59l1"><em>DEV</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=972f08030f7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>