{"id":257,"date":"2017-04-27T10:00:29","date_gmt":"2017-04-27T17:00:29","guid":{"rendered":"http:\/\/peterbreen.info\/wp\/?p=257"},"modified":"2017-07-24T20:09:02","modified_gmt":"2017-07-25T03:09:02","slug":"react-maps","status":"publish","type":"post","link":"http:\/\/peterbreen.info\/wp\/react-maps\/","title":{"rendered":"React Maps"},"content":{"rendered":"<p>Everyone uses Google Maps, and lots of people use React. You&#8217;d think a Maps in React app would be easy, right? I did. And I was surprised that the answer seemed to be no. It&#8217;s not that there aren&#8217;t a lot of examples out there, it&#8217;s finding one that I could make work in my preferred environment and in ES2015. <!--more--><\/p>\n<p>Many examples I saw I had to pass on immediately; ones that used <code>React.createClass<\/code> and older Google Maps API versions were pretty common. I did this on principle, but the example went home when I realized that in between writing the code and writing this post, <a href=\"https:\/\/facebook.github.io\/react\/blog\/2017\/04\/07\/react-v15.5.0.html\">React  released v15.5.0<\/a> which is the first step towards deprecating <code>React.createClass<\/code> completely. Good thing I wasn&#8217;t using it!  My experience with <a href=\"http:\/\/peterbreen.info\/wp\/react-fishtank\/\">React Fishtank<\/a> served me in good stead here.<\/p>\n<p>To minimize the difficulties in adapting any example code I found, I looked specifically for something which worked to serve a map <em>first<\/em> and could be &#8211; hopefully &#8211; adapted to my CRA environment <em>second<\/em>. With those criteria in mind, I searched and found this helpful Codepen: <a href=\"http:\/\/codepen.io\/anon\/pen\/PNooKz\">http:\/\/codepen.io\/anon\/pen\/PNooKz<\/a><\/p>\n<p>Right up front I had high hopes for this one. Does it serve a map? Sure does! I can see it right there. Is it using the syntax I want? Sure is, I can see it right there. Is it something where I can read the code well enough to understand what each function is doing? Yes. So the only hurdle left is can I make it work in a CRA environment instead of Codepen? Sure can.<\/p>\n<p>The live site is available here: <a href=\"https:\/\/peterbreen.github.io\/gmapreact\/\">https:\/\/peterbreen.github.io\/gmapreact\/<\/a><br \/>\nThe code is available here: <a href=\"https:\/\/github.com\/PeterBreen\/gmapreact\">https:\/\/github.com\/PeterBreen\/gmapreact<\/a><\/p>\n<p>As a map it&#8217;s not very exciting, but as a platform for future development I hope somebody else finds it useful. I know I will, at least.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Everyone uses Google Maps, and lots of people use React. You&#8217;d think a Maps in React app would be easy, right? I did. And I was surprised that the answer seemed to be no. It&#8217;s not that there aren&#8217;t a lot of examples out there, it&#8217;s finding one that I could make work in my &hellip; <a href=\"http:\/\/peterbreen.info\/wp\/react-maps\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">React Maps<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,12],"tags":[],"class_list":["post-257","post","type-post","status-publish","format-standard","hentry","category-development","category-react"],"_links":{"self":[{"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/posts\/257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/comments?post=257"}],"version-history":[{"count":7,"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/posts\/257\/revisions"}],"predecessor-version":[{"id":287,"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/posts\/257\/revisions\/287"}],"wp:attachment":[{"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/media?parent=257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/categories?post=257"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/peterbreen.info\/wp\/wp-json\/wp\/v2\/tags?post=257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}