diff --git a/index.html b/index.html
index fa957b991..9d9a1ed60 100644
--- a/index.html
+++ b/index.html
@@ -46,6 +46,7 @@
+
diff --git a/js/id/id.js b/js/id/id.js
index 8ee5a0e4a..b6b6ed4ae 100644
--- a/js/id/id.js
+++ b/js/id/id.js
@@ -184,20 +184,9 @@ window.iD = function(container) {
return d[0] + ' icon';
});
- function geolocateSuccess(position) {
- map.center([position.coords.longitude, position.coords.latitude]);
- }
- function geolocateError() { }
if (navigator.geolocation) {
container.append('div')
- .attr('class', 'geolocate-control map-control')
- .append('button')
- .attr('class', 'narrow')
- .attr('title', 'Show My Location')
- .text('G')
- .on('click', function() {
- navigator.geolocation.getCurrentPosition(geolocateSuccess, geolocateError);
- });
+ .call(iD.geolocate(map));
}
var gc = container.append('div').attr('class', 'geocode-control map-control')
diff --git a/js/id/ui/geolocate.js b/js/id/ui/geolocate.js
new file mode 100644
index 000000000..1d4e1a491
--- /dev/null
+++ b/js/id/ui/geolocate.js
@@ -0,0 +1,22 @@
+iD.geolocate = function(map) {
+
+ function success(position) {
+ map.center([position.coords.longitude, position.coords.latitude]);
+ }
+
+ function error() { }
+
+ return function(selection) {
+ selection
+ .attr('class', 'geolocate-control map-control')
+ .append('button')
+ .attr('class', 'narrow')
+ .attr('title', 'Show My Location')
+ .text('G')
+ .on('click', function() {
+ navigator.geolocation.getCurrentPosition(
+ success, error);
+ });
+ };
+
+};