Last active
May 10, 2021 12:48
-
-
Save timersys/fd89fe2fa40dce472db0b5223aae5bbc to your computer and use it in GitHub Desktop.
Access Javascript geo info in GeotargetingWP
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
$(document).on('geotwp_ajax_success', function(e, data) { | |
if( typeof data.geo != 'undefined') { | |
// create a custom cookie with zip value and 999 days duration | |
GeotCreateCookie('geot_switcher', data.geo.city.data.zip, 999); | |
// Add a marker in a custom google map | |
if( data.geo.geolocation.data.latitude && data.geo.geolocation.data.longitude && jQuery('#geot-map').length != 0 ) { | |
var stanton = {lat: parseFloat(data.geo.geolocation.data.latitude), lng: parseFloat(data.geo.geolocation.data.longitude)}; | |
add_marker(stanton); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment