Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Created November 8, 2013 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wboykinm/7374192 to your computer and use it in GitHub Desktop.
Save wboykinm/7374192 to your computer and use it in GitHub Desktop.
IP location w/ mapbox.js
// Set default location in case the IP doesn't have one
var y = 40.8;
var x = -96.67;
// Grab IP location from freegeoip API
$.getJSON('http://freegeoip.net/json/', function(json) {
if (json) {
y = json.latitude;
x = json.longitude;
}
// Build the map
var map = L.mapbox.map('map', 'landplanner.g7443phg', {
scrollWheelZoom:false
}).setView([y, x], 9);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment