<?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 Mike Surowiec on Medium]]></title>
        <description><![CDATA[Stories by Mike Surowiec on Medium]]></description>
        <link>https://medium.com/@mikesurowiec?source=rss-ae591e13250------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*CU1AaV2cT6SduuuPQF0Ibg.jpeg</url>
            <title>Stories by Mike Surowiec on Medium</title>
            <link>https://medium.com/@mikesurowiec?source=rss-ae591e13250------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:01:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mikesurowiec/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[Clicking and Dragging SVG with React and D3.js]]></title>
            <link>https://medium.com/dev-shack/clicking-and-dragging-svg-with-react-and-d3-js-5639cd0c3c3b?source=rss-ae591e13250------2</link>
            <guid isPermaLink="false">https://medium.com/p/5639cd0c3c3b</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mike Surowiec]]></dc:creator>
            <pubDate>Sat, 07 Oct 2017 19:37:58 GMT</pubDate>
            <atom:updated>2017-10-07T22:40:24.399Z</atom:updated>
            <content:encoded><![CDATA[<p>A key feature of the interactive DC Metro map on <a href="https://dcmetropro.com/">https://dcmetropro.com</a> is clicking on station markers in the SVG map and dragging / zooming around. Here’s a quick rundown of what it took to make that happen!</p><blockquote>You might want to play with the map to get an idea of what it does before reading on: <a href="https://dcmetropro.com/">https://dcmetropro.com</a>.</blockquote><h3>Starting off slowly now</h3><h4>Step 1:</h4><p>Do you have an SVG file or content or something? For DC Metro Pro, I had to create the SVG of the DC Metro Map by hand (which I describe in <a href="https://medium.com/@mikesurowiec/making-an-interactive-dc-metro-map-c061e7a3bdf0">this other post</a>). Exporting from Sketch resulted in a big pile of svg content, which I put into a JS file like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/341d4eceebdf6c6f335f8d96124ce2ea/href">https://medium.com/media/341d4eceebdf6c6f335f8d96124ce2ea/href</a></iframe><p>When creating the file, I took special attention to name the layers and elements in a way that could be identified in code. Here’s a glimpse of the actual SVG content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LWhHIABrgDfe-Xklb25KzA.png" /></figure><p>The &lt;g id=&quot;Stations&quot;&gt; element wraps all of the individual station dots on the map, and the id of each dot corresponds to a metro stop (C05 is Rosslyn for all you WMATA fans out there).</p><p>This is a key component in turning the visual map into an interactive one, because now our visual pieces have some semantic meaning attached to them that we can leverage in the codez.</p><h3>A little bit faster now</h3><h4>Step 2:</h4><p>We have to get the SVG rendered into the DOM, and since we’re using React, we have to play by React’s rules.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1338f0f4852a8b9a1e98d57cdec4a0e/href">https://medium.com/media/f1338f0f4852a8b9a1e98d57cdec4a0e/href</a></iframe><p>So here is the React Metro Map component, which uses that big HTML/SVG string from before. We render it using React’s dangerouslySetInnerHTML property, which will take our string and drop it right into the DOM without having React parse or update it on re-renders. This allows us to use d3 to get a “handle” on the element. We also wrap it in a &lt;g&gt; tag (used to <em>group</em> elements) so we can handle some mouse trickery later on.</p><p>And finally, the snippet shows a little bit of the logic for sizing and resizing the svg element based on the window dimensions and the content size of the svg (the hardcoded viewport values are the Artboard dimensions from my Sketch file).</p><blockquote>Side Note: When you read through tutorials and overviews of code, things can seem really confusing; it’s partially because explaining a process that’s inherintely non-linear in a linear fashion, like a blog post, is hard. <strong>The code didn’t look like this when it was first written</strong>. I went through several iterations to get to this result. So if you caught yourself wondering, “how did he know to wrap that element?”, I want you to know that at first I didn’t! I ran into bugs with mouse events and text highlighting later on and this was how I fixed those problems. There’s a lot of trial and error that doesn’t get represented in posts like this. Continuing on...</blockquote><h3>Hey-Hey-A-Hey</h3><h4>Step 3:</h4><p>Finally the d3.js + React code you were promised in the title! What is that saying about preparation?</p><blockquote><strong>A good preparation takes longer than the delivery.</strong></blockquote><blockquote><strong>- </strong><em>E. Kim Nebeuts</em></blockquote><p>Who is E. Kim Nebeuts? 🤔. Well, that’s not the quote I was thinking of, but close enough.</p><p>A snippet about clicking elements in SVG:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7995d8ad816fcf19e9d2c1289201a435/href">https://medium.com/media/7995d8ad816fcf19e9d2c1289201a435/href</a></iframe><p>The comments in the snippet above walk through what each piece does.</p><p>Why do I append a circle element?</p><ul><li>As it turns out, the visual circle in the svg is very tiny, and a bigger hit area makes for a better UX. The sizing functions aren’t shown, but they position the circle centered over the g tag they were appended to, and the radius of the circle is increased for what I call “major” stations (they’re bigger dots on the map). These circles are what you see when you hover over a station on the map.</li></ul><h3>Jump Up and Shout Now!</h3><h4>Step 4:</h4><p>Time to drag the SVG. Alright, so clicking seems to work (proof is on the website!). Now how do we add dragging in a way that integrates well with the clicking?</p><p>The conceptual layout is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b713TpF6Bhw4h72Z1lYTRg.png" /><figcaption>The top layer is really just a conceptual layer, the dots are placed in the map (so they track the elements when the map is dragged). Shown this way to visualize how the pointer events pass through.</figcaption></figure><p>You can think of the mouse events as passing through these layers until they hit something. The circles themselves have pointer events (but not they layer the circles are on), so if the mouse is not over a circle the event passes through to the next layer that has pointer events, which is not the visual map, but our draggable background.</p><p>What this means is that clicking the circles get priority over dragging, but it also means you can’t start a drag on a circle. I’m sure there’s a better way to do this, but at this time I’d like to pull out my Good Enough™ stamp of approval.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LYJaQv0o10Sx86iFdC_seA.png" /><figcaption>Yeah it is.</figcaption></figure><p>Alright, enough funny business, let’s look at the code for dragging.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f630db4d3d6640b76ba493c0ea04fa5e/href">https://medium.com/media/f630db4d3d6640b76ba493c0ea04fa5e/href</a></iframe><p>We really lean on d3 here to do the heavy lifting. Trust me, I’ve written custom zoom+dragging logic before and it can get complicated 😉.</p><p>For the curious: What’s translateExtent do?</p><ul><li>Those are just bounding coordinates for how far you’re able to drag the map. Directly from the d3.js docs it “Sets the translate extent to the specified array of points [[x0, y0], [x1, y1]], where [x0, y0] is the top-left corner of the world and [x1, y1] is the bottom-right corner of the world.”</li></ul><h3>Conclusion</h3><p>Yes, the sub headers were riffing on The Isely Brothers, Shout. Hat tip if you noticed!</p><p>So that was a little peek at how clicking + dragging svg in a react component <em>can</em> work. I hope you were able to glean something useful in how to augment the SVG and bend it to your will with d3. If you have a question, please drop it in a comment below!</p><p>If you enjoyed this article, you might also enjoy <a href="https://twitter.com/mikesurowiec">my musings on Twitter</a>.</p><p>And finally, here’s one more link for the website that uses these techniques: <a href="https://www.dcmetropro.com/">https://www.dcmetropro.com</a>.</p><p>Have a great day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5639cd0c3c3b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dev-shack/clicking-and-dragging-svg-with-react-and-d3-js-5639cd0c3c3b">Clicking and Dragging SVG with React and D3.js</a> was originally published in <a href="https://medium.com/dev-shack">Dev Shack</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DC Metro Pro: Node.js and Socket.IO for realtime data]]></title>
            <link>https://medium.com/@mikesurowiec/dc-metro-pro-node-js-and-socket-io-for-realtime-data-94b846ffb481?source=rss-ae591e13250------2</link>
            <guid isPermaLink="false">https://medium.com/p/94b846ffb481</guid>
            <category><![CDATA[washington-dc]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[transportation]]></category>
            <dc:creator><![CDATA[Mike Surowiec]]></dc:creator>
            <pubDate>Mon, 24 Jul 2017 13:15:16 GMT</pubDate>
            <atom:updated>2017-07-24T13:15:16.601Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*f_J98C2LxG5sWWNZIt7iIg@2x.png" /></figure><h4>Super-charging realtime train arrival information</h4><h4>So What’s the Problem?</h4><p>Washington Metropolitan Area Transit Authority (WMATA) shows train arrival information in 20 second intervals. That means if you’re a Metro patron, you’re likely looking at information that’s at least 10 seconds old!</p><blockquote>❌ U n a c c e p t a b l e.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*4CinjR2DnXUHMbkF-gTEKQ.png" /><figcaption>If you’re not there in 2 minutes, you’ll be waiting 13 minutes!</figcaption></figure><p>I mean, this is 2017 right? Who has time for 20 second old data! Next thing you know they’ll be telling us it’s better to tunnel cars underground than to fly them! Balderdash!</p><p>Alright, so let’s take a walk through how the DC Metro Pro <a href="https://itunes.apple.com/us/app/dc-metro-pro/id1043136830?">app</a> and <a href="https://www.dcmetropro.com/">website</a> are setup to request the WMATA data as fast as possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*hGVg1oU2DT5G1y7dRt0cMg.gif" /><figcaption>Demo of the DC Metro Pro website. <a href="https://www.dcmetropro.com/">Click here to see it for yoursel</a>f.</figcaption></figure><p>The app and website are backed by a small Node.js server that pushes realtime train information to the users. Below is a rough outline of how the system works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*bbcEQ31JcnNPlVOTJzobsw@2x.png" /><figcaption>If you go to <a href="https://doors-closing-server.devshack.io/">https://doors-closing-server.devshack.io/</a> you should see an OK message! That means the server is running 😄. Also, Doors Closing was the old name of the app — an obscure homage to the automated train voice.</figcaption></figure><p>You can see in the diagram above that the Node.js server is essentially a caching layer between the clients and WMATA. (1) shows the HTTP request polling the WMATA API, (2) shows socket.io pushing the new data to the clients who want it.</p><h4>Why do it this way?</h4><p>The WMATA API is rate limited to 50,000 requests per day. With the one server making requests, we can use that 50k allotment to keep all of the DC Metro Pro users the most up-to-date. With a little maths:</p><p>86,400 seconds in a day / 50,000 requests = 1.728 seconds per request</p><p>In practice, I added a little buffer and make one request every ~2.5 seconds (see the Multiple Endpoints section below for why). As a result, users of the DC Metro Pro app and website have the latest information <strong>8x faster </strong>than on the WMATA website.</p><p>On top of that, using a WebSocket connection vs HTTP has it’s own speed and network overhead advantages. All around it’s a pretty decent system!</p><h4>But You Can’t Just Push New Data</h4><p>If the clients only received new data when the Node.js server got a response from the WMATA API, there would be a lag of 2–3 seconds when a new client came online between polling requests.</p><blockquote>❌ U n a c c e p t a b l e.</blockquote><p>To make the clients feel instantaneous, the Node.JS server accepts one-off requests for data (which it pulls very quickly from the in memory cache). This aspect is much more like a standard REST endpoint, where the client sends request and gets a response, vs the listening approach of “let me know when you have new stuff”. You need both to have a complete system.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a360bbc8f8448217f7afe46891f21253/href">https://medium.com/media/a360bbc8f8448217f7afe46891f21253/href</a></iframe><p>Above you can see when a client sends a request for the realtime data for a set of stations (usually something like[&#39;A32&#39;, &#39;B11&#39;]), the server grabs the data from the cache and sends it back via a separate emit for each station.</p><h4>Multiple Endpoints to Synchronize</h4><p>WMATA has more information than just the realtime train arrivals, so I set up a synchronization mechanism that requests the data from separate WMATA endpoints at different intervals. You can see below that the realtime train arrival data is the one updated most often, while the other two are on longer polling cycles.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/790c55790044d4b2fb442ebf6fee11ff/href">https://medium.com/media/790c55790044d4b2fb442ebf6fee11ff/href</a></iframe><p>Just checking my math here, at most the server will make 37,440 requests in a day.</p><p>(86,400 / 2.5) + (86,400 / 60) + (86,400 / 60) = 37,440 requests per day</p><p>So thats roughly 75% of the request allotment being utilized for the production server. The 25% buffer is for development and that warm feeling of being safely under the limit.</p><h4>setInterval vs setTimeout</h4><p>One thing you may notice is how the synchornization code doesn’t use setInterval, despite the function being referred to as loopWithInterval. This is because using setInterval could cause requests to pile up and overlap; imagine if one request hung, and a following one returned before it. That gets into bad territory fast! In my case, the easiest solution was Good Enough™. We simply wait for the response from WMATA and then send a new request after our pre-determined interval. This can result in “float” as the request windows are shifted forward by the latency of the previous request. We could account for this pretty easily but ¯\_(ツ)_/¯.</p><p>For a more technical look at this problem (but in reverse) see how Figma handles rate-limiting: <a href="https://blog.figma.com/an-alternative-approach-to-rate-limiting-f8a06cf7c94c">https://blog.figma.com/an-alternative-approach-to-rate-limiting-f8a06cf7c94c</a>.</p><h4>Graphs!</h4><p>Since starting this project WMATA has added some graphs and usage information, so I’ll share those below. This is usage over the last 90 days.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dyTbYEFbeDBOFVpRZbKBNg.png" /><figcaption>165GB of bandwidth 😎</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h9h_xePMg_m3o9HipeuMeQ.png" /><figcaption>Graphs are always fun!</figcaption></figure><p>My math from earlier seems to check out! We’re sitting around 31,000k calls on a given day. If you’re so inclined, you can quantify how the request latency affects the number of calls we make! Neat-o.</p><p>I hope you enjoyed a little peek at the backend that powers the <a href="https://itunes.apple.com/us/app/dc-metro-pro/id1043136830?">DC Metro Pro app</a> and <a href="https://www.dcmetropro.com/">website</a>. Thanks for reading!</p><blockquote>✅ A c c e p t a b l e</blockquote><p>— Mike Surowiec</p><ul><li><a href="https://twitter.com/mikesurowiec">Twitter</a></li><li><a href="https://github.com/mikesurowiec">Github</a></li><li><a href="https://www.devshack.io/">Dev Shack</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94b846ffb481" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1000 miles 2017]]></title>
            <link>https://medium.com/series/1000-miles-2017-168a9c1f5e8a?source=rss-ae591e13250------2</link>
            <guid isPermaLink="false">https://medium.com/p/168a9c1f5e8a</guid>
            <dc:creator><![CDATA[Mike Surowiec]]></dc:creator>
            <pubDate>Thu, 02 Mar 2017 22:38:21 GMT</pubDate>
            <atom:updated>2017-03-06T23:36:33.116Z</atom:updated>
            <content:encoded><![CDATA[<h3>My goal is to run 1000 miles in 2017.</h3><p>And take some photos while I do it.</p><p>Overlooking Rosslyn, VA</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wkiu26ziPlhIY0XYzdMBeQ@2x.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GLXusG-XdngALFQOS1KxIQ@2x.jpeg" /></figure><p>Benefits of running around D.C.</p><h3>My trip to Arizona made for a nice change of scenery.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Re2tEj0HdEAOkddYdJem8A@2x.jpeg" /></figure><p>Mile 134 of 1000 is hardly the end!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w_EdisHnny4ldWU6vroDrw@2x.jpeg" /></figure><p>The air is noticeably thinner out here compared to the east coast 🌬</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7KskMzEcg-tefQNKZmVwLw@2x.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T1SJ897yJjAtG14vAdOG_w@2x.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6rhwJaOKmsJUCfkAs2zTw@2x.jpeg" /></figure><p>If you ever get lost in the desert just follow the aerostat home 😂</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eg471vNxHNRcm2jLrCV6Ig@2x.jpeg" /><figcaption>Powering up for D.C. Rock &amp; Roll Half marathon (6 days away!)</figcaption></figure><p>13.1 miles is roughly 1500 calories</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=168a9c1f5e8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native Swift & Promises]]></title>
            <link>https://medium.com/dev-shack/react-native-swift-promises-81835eca79c0?source=rss-ae591e13250------2</link>
            <guid isPermaLink="false">https://medium.com/p/81835eca79c0</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mike Surowiec]]></dc:creator>
            <pubDate>Wed, 01 Mar 2017 01:04:58 GMT</pubDate>
            <atom:updated>2018-03-24T18:48:19.784Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Quick Reference Guide</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*O2CUTjGueE1m2_2rXNPCgQ.png" /></figure><p>For any given React Native project, I prefer to use Swift on the native side and promises on the Javascript side. Here’s the skinny on how to make that happen.</p><h3>1. Bridging Header File</h3><p>You need a .h file to expose Objective-C libraries to your Swift file. This file is called `ProjectName-Bridging-Header.h` and usually includes a couple of the react native libraries that you want to access.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78b5cb6b4190ffb4091e9ac4be0433cd/href">https://medium.com/media/78b5cb6b4190ffb4091e9ac4be0433cd/href</a></iframe><h3>2. React Native &lt;-&gt; Obj-C &lt;-&gt; Swift</h3><p>You’ll need another file (.m) that describes your Swift class in an Objective-C way so that React Native can understand it. The functions written here map to functions exposed from the Swift class that you’ll see in the next section. As an example, I’ll use parts of an AudioManager class that I’ve written for the <a href="https://autismmusicproject.com/">Autism Music Project App</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4639aa1e100b7db56f4424baf9c294e9/href">https://medium.com/media/4639aa1e100b7db56f4424baf9c294e9/href</a></iframe><h3>3. Your Swift Class</h3><p>Woo! Finally we get to write some Swift. This is where the bulk of the logic for the AudioManager class lives.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d71ea8b2607fa69be9168a53bda4605/href">https://medium.com/media/7d71ea8b2607fa69be9168a53bda4605/href</a></iframe><h3>4. Using it in Javascript</h3><p>Now that we’re back in Javascript (a.k.a wonderland 😉) we can use all our JS tricks like async &amp; await when talking over the native bridge.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0899946307c0859c9d446a05b9f63ad/href">https://medium.com/media/b0899946307c0859c9d446a05b9f63ad/href</a></iframe><p>I hope you found that quick run-through helpful, and if you have any questions or need clarification please ask!</p><p>Also make sure to check out the <a href="https://autismmusicproject.com/">Autism Music Project</a>, which is a collaboration to create specially designed music for children with Autism Spectrum Disorders.</p><p>Thanks!</p><p><a href="https://twitter.com/mikesurowiec">mikesurowiec</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81835eca79c0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dev-shack/react-native-swift-promises-81835eca79c0">React Native Swift &amp; Promises</a> was originally published in <a href="https://medium.com/dev-shack">Dev Shack</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making an Interactive DC Metro Map]]></title>
            <link>https://medium.com/dev-shack/making-an-interactive-dc-metro-map-c061e7a3bdf0?source=rss-ae591e13250------2</link>
            <guid isPermaLink="false">https://medium.com/p/c061e7a3bdf0</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[3d]]></category>
            <category><![CDATA[washington-dc]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[makers]]></category>
            <dc:creator><![CDATA[Mike Surowiec]]></dc:creator>
            <pubDate>Fri, 24 Feb 2017 17:35:31 GMT</pubDate>
            <atom:updated>2017-02-24T17:35:31.834Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GSSYYkRVBJ6K36ja9-8h7w.png" /><figcaption>The interactive DC Metro Map</figcaption></figure><p>After building and soft launching the <a href="https://itunes.apple.com/us/app/doors-closing-dc-metro/id1043136830?mt=8">Doors Closing — DC Metro App</a> I planned on making a light web version to provide some free value to people and possibly drive a few app purchases.</p><blockquote>TLDR; I made an interactive DC Metro Map → <a href="https://dcmetro.devshack.io/">https://dcmetro.devshack.io</a></blockquote><p>I knew I wanted the site to almost entirely be the standard DC Metro map that is seen throughout the stations. To me, it is well designed and represents the routes in a useful way.</p><p>Unfortunately a quick search for an SVG map (one which would scale and work at any resolution) of the DC Metro yielded less than satisfactory results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_nJ7c3YFKJ7byBw-A9yvyQ.png" /><figcaption>Left: Option 1 (<a href="https://commons.wikimedia.org/wiki/File:Washington_DC_Metro_Map_(To_Scale).svg">source</a>). Right: Option 2 (<a href="https://commons.wikimedia.org/wiki/File:DC_Metro_Map_2013.svg">source</a>).</figcaption></figure><p><strong>Option 1</strong>: Although geographically accurate, it’s not as helpful in navigating.</p><p><strong>Option 2</strong>: It’s not bad, but it’s also not <strong>the</strong> DC metro map.</p><p>After that I decided to email WMATA to ask if they would share the source asset. There’s no doubt the original map is in SVG format, but alas they “don’t publish” the SVG version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*8JwIdCOdCXl7xSuicdOMKg.png" /><figcaption>The response from WMATA</figcaption></figure><p>I won’t conjecture too much on it, but let’s just say I can understand why a design firm would keep the source svg of the map locked down. Hint: it prevents any $10/hr intern from making updates to it. 🤓</p><p>So with the easy options exhausted, I decided to make my own SVG map based exactly on the <a href="https://www.wmata.com/schedules/maps/">published PDF metro map</a>. I pulled the PDF into Sketch and had it “automatically” convert to SVG. The results were ok; it had outlined everything as paths as best it could, but some parts were broken and there were a bunch of manual tweaks necessary to make it useful. The most time consuming part was editing all of the labels to make them svg text elements instead of paths — this cut the file size down tremendously and fixed some weird scaling issues. I also needed to organize the paths and encode the station elements with their corresponding StationId’s so I could programmatically identify them. This is what would make the map interactive after-all!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3_v3G8TlJJTjIdn89r3waQ.png" /><figcaption>Sample of the generated SVG</figcaption></figure><p>Once I had a workable SVG map, creating the website took almost no time at all. I already had a server sending realtime train updates for the iOS app and the other major component — interacting programmatically with SVG — is fairly simple with the <a href="https://d3js.org/">d3.js library</a>. A little pan-zoom, some simple effects, a splash of design, and bam! A website was born. Check it out and let me know what you think! <a href="https://dcmetro.devshack.io/">https://dcmetro.devshack.io</a>. I’m always looking for suggestions to improve it.</p><blockquote>Shamless plug: consider purchasing the DC Metro app! It’s a great companion app for riding metro and has saved my butt more than once. When I lived near NoMa-Gallaudet, it was the difference between a leisurely walk to the station and an all out sprint to catch a train before getting stuck in a 20 minute train gap.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*vOiizb1UbS96cZk3voMA5w.png" /><figcaption><a href="https://itunes.apple.com/us/app/doors-closing-dc-metro/id1043136830?mt=8">Doors Closing — DC Metro App</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mSmY_9agCY4a9ysRgTf5ZQ.jpeg" /></figure><p>That’s all for today folks. Feel free to reach out to me on twitter <a href="https://twitter.com/mikesurowiec">@mikesurowiec</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c061e7a3bdf0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dev-shack/making-an-interactive-dc-metro-map-c061e7a3bdf0">Making an Interactive DC Metro Map</a> was originally published in <a href="https://medium.com/dev-shack">Dev Shack</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>