<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Projects on stepansite</title><link>https://stepansite.com/en/tags/projects/</link><description>Recent content in Projects on stepansite</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 07 Sep 2020 20:00:00 +0000</lastBuildDate><atom:link href="https://stepansite.com/en/tags/projects/index.xml" rel="self" type="application/rss+xml"/><item><title>Added the map</title><link>https://stepansite.com/en/2021/places-map/</link><pubDate>Mon, 07 Sep 2020 20:00:00 +0000</pubDate><guid>https://stepansite.com/en/2021/places-map/</guid><description>&lt;p&gt;I tend to forget everything, so I wanted to make a map with the markers of the visited places for a while.&#10;One day I saw someone&amp;rsquo;s &lt;a href="https://gist.github.com/janikvonrotz/37dc61480790b07ab91d88d624caef2b" target="_blank" rel="noreferrer"&gt;gist&lt;/a&gt; and decided to create one for myself.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;markers are clickable&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&#10;&#10;&#10;&lt;script src='https://api.mapbox.com/mapbox-gl-js/v2.4.1/mapbox-gl.js'&gt;&lt;/script&gt;&#10;&lt;link href='https://api.mapbox.com/mapbox-gl-js/v2.4.1/mapbox-gl.css' rel='stylesheet' /&gt;&#10;&lt;div id='map' style='width: 100%; height: 500px;'&gt;&lt;/div&gt;&#10;&lt;script defer&gt;&#10;mapboxgl.accessToken = "pk.eyJ1Ijoic3RlcGhhbjIxIiwiYSI6ImNsMm5lOHViMTE2YmQzb3BraGtrd2hzdXIifQ.UVLMX1yr359G9FroBX5cdQ";&#10;&#10; &#10;const map = new mapboxgl.Map({&#10; container: "map",&#10; style: "mapbox://styles/mapbox/light-v10?optimize=true",&#10; zoom: 3,&#10; center: [14.0213,47.9296]&#10;});&#10;&#10;&#10;&#10;&#10;fetch("\/2020\/places-map\/places.json")&#10;.then( response =&gt; response.json() )&#10;.then( data =&gt; {&#10; map.loadImage("https://a.tiles.mapbox.com/v4/marker/pin-m+7e7e7e.png?access_token=" + mapboxgl.accessToken, function(error, image) {&#10; if (error) throw error;&#10; map.addImage("custom-marker", image);&#10; &#10; map.addLayer({&#10; id: "markers",&#10; type: "symbol",&#10; &#10; source: {&#10; type: "geojson",&#10; data: data&#10; },&#10; "minzoom": 0.5,&#10; "maxzoom": 15,&#10; layout: {&#10; "icon-image": "custom-marker",&#10; "icon-allow-overlap": true&#10; }&#10; });&#10; });&#10;});&#10;&#10;map.on('click', function(e) {&#10; var features = map.queryRenderedFeatures(e.point, {&#10; layers: ['markers'] &#10; });&#10;&#10; if (!features.length) {&#10; return;&#10; }&#10;&#10; var feature = features[0];&#10;&#10; var popup = new mapboxgl.Popup({ offset: [0, -15] })&#10; .setLngLat(feature.geometry.coordinates)&#10; .setHTML('&lt;h4&gt;' + feature.properties.title + '&lt;/h4&gt;&lt;i&gt;' + feature.properties.date + '&lt;/i&gt;')&#10; .addTo(map);&#10;});&#10;&#10;map.addControl(new mapboxgl.FullscreenControl());&#10;&lt;/script&gt;&#10;&#10;&lt;h2 id="how-to"&gt;How-to&lt;/h2&gt;&#10;&lt;p&gt;Markers data is stored in &lt;a href="https://docs.mapbox.com/help/glossary/geojson/" target="_blank" rel="noreferrer"&gt;GeoJSON&lt;/a&gt; that you can generate using one of online services: &lt;a href="https://geojson.io/" target="_blank" rel="noreferrer"&gt;geojson.io&lt;/a&gt;, &lt;a href="https://geojson.net/" target="_blank" rel="noreferrer"&gt;geojson.net&lt;/a&gt;.&#10;All you have to do is put the marker on the map and click it to add more parameters.&lt;/p&gt;</description></item></channel></rss>