Created
February 19, 2013 18:27
-
-
Save jessecravens/4988493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
var map; | |
var info = $('#infobox'); | |
var doc = $(document); | |
var tinyIcon = L.Icon.extend({ | |
options: { | |
shadowUrl: '../vendor/leaflet/assets/marker-shadow.png', | |
iconSize: [25, 39], | |
iconAnchor: [12, 36], | |
shadowSize: [41, 41], | |
shadowAnchor: [12, 38], | |
popupAnchor: [0, -30] | |
} | |
}); | |
var redIcon = new tinyIcon({ iconUrl: '../vendor/leaflet/assets/marker-red.png' }); | |
var sentData = {} | |
var connects = {}; | |
console.log(connects) | |
var markers = {}; | |
var active = false; | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(positionSuccess, positionError, { enableHighAccuracy: true }); | |
} else { | |
$('.map').text('Your browser is out of fashion, there\'s no geolocation!'); | |
} | |
function positionSuccess(position) { | |
console.log('positionSuccess'); | |
var lat = position.coords.latitude; | |
var lng = position.coords.longitude; | |
var acr = position.coords.accuracy; | |
// mark user's position | |
userMarker = L.marker([lat, lng], { | |
icon: redIcon | |
}); | |
// uncomment for static debug | |
//userMarker = L.marker([30.2630, 262.254], { icon: redIcon }); | |
// load leaflet map | |
map = L.map('map', { | |
center: [30.2630, 262.254], | |
zoom: 15, | |
zoomControl: false, | |
attributionControl: false | |
}); | |
// leaflet API key tiler | |
L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', { maxZoom: 18, detectRetina: true }).addTo(map); | |
userMarker.addTo(map); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment