Last active
February 7, 2018 17:35
-
-
Save kyle-mccarthy/9b65aa68c5d0acc84e3ab8bb79b9cf02 to your computer and use it in GitHub Desktop.
Modify Google Maps with Callrail numbers
This file contains hidden or 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
var callrailGoogleMaps = { | |
getNumbers: function() { | |
var self = this; | |
window.CallTrk.getSwapNumbers(null, function(nums) { | |
self.swapNumbers(nums); | |
}); | |
}, | |
getMapPoints: function() { | |
if (mapping !== undefined) { | |
return mapping.mapPoint.alllocmap.points; | |
} | |
return []; | |
}, | |
swapNumbers: function(nums) { | |
this.getMapPoints().forEach(function(p) { | |
var n = Number(p.appointments.replace(/-/g, '')); | |
if (nums[n] !== undefined) { | |
var fmtd = (nums[n] + "").replace(/(\d{3})(\d{3})(\d{4})/, '$1-$2-$3'); | |
p.appointments = fmtd; | |
} | |
}); | |
this.reloadMap(); | |
}, | |
reloadMap: function() { | |
mapping.load() | |
}, | |
init: function() { | |
var self = this; | |
if (window.mapping === undefined || window.CallTrk === undefined) { | |
setTimeout(function() { | |
self.init(); | |
}, 500) | |
} else { | |
this.getNumbers(); | |
} | |
} | |
}; | |
callrailGoogleMaps.init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment