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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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>Detecting the physical location by IP Address <b>OR</b> HTML5 geolocation</h1>
<p>This example uses Vue, Axios, and my new cloudflare workers API to get your location.  To get your physical location using your device's GPS or its IP address, click one of the two buttons, below.</p>

<div id="app">
	<p><button v-on:click="geolocation()">Use GPS to update position</button></p>

	<p><button v-on:click="showPositionByIP()">Use IP to update position</button></p>

	It looks like you are currently at:<br /><br />
 	{{details.mqStreet}}<br />
	{{details.mqCity}}, {{details.mqState}} {{details.mqZip}}<br />
</div> 
              
            
!

CSS

              
                
              
            
!

JS

              
                new Vue({
  el: "#app",
  data() {
    return {
			details: {
				latitude: null,
				longitude: null,
				cfCountry: null,
				cfCity: null,
				cfLatitude: null,
				cfLongitude: null,
				cfPostalcode: null,
				cfRegion: null,
				cfRegioncode: null,
				cfTimezone: null,
				mqStreet: null,
				mqCity: null,
				mqState: null,
				mqZip: null
			}
    };
  },
	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 the API Call
				axios
				.get("https://geolocation-json.joe.workers.dev/?latitude="+position.coords.latitude+"&longitude="+position.coords.longitude)
					.then(response=> (this.details = response.data));
		},
		showPositionByIP: function() {
			// Use Axios to make the API Call
			axios
				.get("https://geolocation-json.joe.workers.dev/")
					.then(response=> (this.details = response.data));
		}
	}
});
              
            
!
999px

Console