Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Sorting a list of locations by how for away they are: Part 1</h1>
<p>This is based directly upon an <a href="https://codepen.io/steinbring/pen/dyyOoXy">HTML5 Geolocation codepen</a> that I wrote two years ago.  Below, we are figuring out where the website user is and where five of the UW System Campus locations are.</p>

<div id="app">
	It looks like you are currently at:<br /><br />
	{{location.street}}<br />
	{{location.adminArea5}}, {{location.adminArea3}} {{location.postalCode}}<br /><br />
	
	Where the University of Wisconsin System campuses are at:<br /><br />
	<table>
		<tr>
			<th>Name</th>
			<th>Address</th>
		</tr>
		<tr v-for="campus in campuses">
			<td>{{campus.name}}</td>
			<td>{{campus.address}}</td>
		</tr>
	</table>
</div> 
              
            
!

CSS

              
                
              
            
!

JS

              
                new Vue({
  el: "#app",
  data() {
    return {
			location: null,
			campuses: [{name:'UW-Milwaukee',address: '2200 E Kenwood Blvd, Milwaukee, WI 53201',lat:43.075210,long:-87.881470},{name:'UW-Oshkosh',address: '800 Algoma Blvd. Oshkosh, WI 54901',lat:44.026360,long:-88.551500},{name:'UW-Green Bay',address: '2420 Nicolet Dr, Green Bay, WI 54311',lat:44.532299,long:-87.919853},{name:'UW-Parkside',address: '900 Wood Rd, Kenosha, WI 53144',lat:42.646120,long:-87.856200},{name:'UW-Whitewater',address: '800 W Main St, Whitewater, WI 53190',lat:42.834970,long:-88.742950}]
    };
  },
	methods: {
		geolocation: function() {
      if (navigator.geolocation) {
				navigator.geolocation.getCurrentPosition(this.showPosition);
			} else {
				console.log("Geolocation is not supported by this browser.");
			}
    },
		showPosition: function(position) {
			// Use Axios to make a MapQuest API Call
				axios
				.get("https://www.mapquestapi.com/geocoding/v1/reverse?key=TPWvRrsfpgGWBACqqXd94fbDcfVpy2WJ&location="+position.coords.latitude+"%2C"+position.coords.longitude+"&outFormat=json&thumbMaps=false")
					.then(response=> (this.location = response.data.results[0].locations[0]));
		}
	},
  mounted() {
    this.geolocation();
  }
});
              
            
!
999px

Console