Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!-- Permission to use FFC logo was assumed, I'm sorry -->
<img id="fcc-logo" src="https://raw.githubusercontent.com/FreeCodeCamp/assets/master/assets/logos/freeCodeCamp.png" />
<h1>Campsites Across the Globe</h1>

<!-- Map Visualization -->
<div id="campsite-map">
  <svg width="960" height="611"></svg>
</div>


<!-- Because I keep accidentally deleting these URLs from JS file -->
<!-- https://gist.githubusercontent.com/alicejiang1/2491a45b2b00451484be65a14f810a7b/raw/005da59e145e9e2323b26f10839c0fc082d3120f/world.json -->
<!-- https://gist.githubusercontent.com/alicejiang1/7bcb1078704c53fa4cbc7598785c0466/raw/0a52dc63510e6a6fcf0f6d66f6332b159531ec13/campsites.json -->
            
          
!
            
              body {
  background: #006400;
  text-align: center;
  font-family: "Lato", sans-serif;
  color: #FFFFFF;
}
#fcc-logo, h1 {
  margin: 0px;
  filter: drop-shadow(2px 2px 5px #333333);
}
#fcc-logo{
  max-height: 60px;
}
#campsite-map {
  border-radius:25px;
  background: #FFFFFF;
  margin: 15px auto;
  max-width: 960px;
  max-height: 480px;
  padding: 25px;
  -webkit-box-shadow: 5px 5px 10px #333333;
     -mox-box-shadow: 5px 5px 10px #333333;
          box-shadow: 5px 5px 10px #333333;
}
#campsite-map svg {
  width:100% ;
  border: 2px solid #006400;
  border-radius: 10px;

  max-width: 960px;
  max-height: 480px;
}
.land {
  fill: #BBBBBB;
}

.boundary {
  fill: none;
  stroke: #FFFFFF;
  stroke-width: 0.5px;
}
.campsites {
  fill: #006400;
  opacity: .3;
  z-index: 100;
}
.campsite-info {
  position: absolute;
  text-align: center;
  font-size: 12px;
  color: #EEEEEE;
  background: #006400;
  border: 1px solid #EEEEEE;
  border-radius: 2.5px;
  padding: 3px;
  opacity: 0.95;
  z-index: 1000;
  -webkit-box-shadow: 2px 2px 5px #333333;
     -mox-box-shadow: 2px 2px 5px #333333;
          box-shadow: 2px 2px 5px #333333;
}
            
          
!
            
              var svg     =   d3.select("svg"),
    width   = +svg.attr("width"),
    height  = +svg.attr("height");

var projection = d3.geoCylindricalStereographic()
                   .scale(153)
                   .translate([width/2, height/2])
                   .precision(0.1);

var path = d3.geoPath()
             .projection(projection);

// Define the div for the tooltip
var tip = d3.select("#campsite-map")
            .append("div")
            .attr("class", "campsite-info")
            .style("display", "none");

// Zoom and pan functionality
var zoom = d3.zoom()
             .scaleExtent([1, 10])
             .translateExtent([[0,0],[width, height]])
             .on("zoom", zoomed);

function zoomed(){
  rt.attr("transform", d3.event.transform)
}

var rt = svg.append("g")
            .call(zoom);

rt.append("rect")
  .attr("width", width)
  .attr("height", height)
  .style("fill", "none")
  .style("pointer-events", "all");

// Create the world
d3.json("https://gist.githubusercontent.com/becausealice2/2491a45b2b00451484be65a14f810a7b/raw/70209036e73080a11205664dedf75ce75c27763a/world-50m.json", function(err, world) {
  if (err) { console.log(err); }

  rt.insert("path")
     .datum(topojson.feature(world, world.objects.land))
     .attr("class", " countries land")
     .attr("d", path);

  rt.insert("path")
     .datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; }))
     .attr("class", " countries boundary")
     .attr("d", path);

  // Multiply and replenish the earth
  d3.json("https://gist.githubusercontent.com/becausealice2/7bcb1078704c53fa4cbc7598785c0466/raw/b93a12aeee7be5f461c0dd4bd344473e7714c601/campsites.json", function(err, campsites) {
    if (err) { console.log(err); }

    rt.selectAll("circle")
        .data(campsites[0]["wikij"])
        .enter()

        // Facebook group links
        .append("a")
        .attr("xlink:href", function(d) { return d.facebook; })
        .attr("target", "_blank")

        // Campsite markers
        .append("circle")
        .attr("cx", function(d) {
          d = d.coords;
          if (d !== undefined) { return projection([d.lng, d.lat])[0]; }
        })
        .attr("cy", function(d) {
          d = d.coords;
          if (d !== undefined) { return projection([d.lng, d.lat])[1]; }
        })
        .attr("r", 2)
        .attr("class", "campsites")

        // Tooltip event handlers
        .on("mouseover", function(d) {
          tip.transition()
             .duration(100)
             .style("display", "block")
          tip.html(d.city+", "+(d.region?d.region+", ":"")+d.country)
             .style("left", (d3.event.pageX+5)+"px")
             .style("top", (d3.event.pageY-20)+"px");
        })
        .on("mouseout", function() {
          tip.transition()
             .duration(300)
             .style("display", "none")
        });

  });

});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console