Skip to content

Instantly share code, notes, and snippets.

@timersys
Last active May 10, 2021 12:48
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 timersys/fd89fe2fa40dce472db0b5223aae5bbc to your computer and use it in GitHub Desktop.
Save timersys/fd89fe2fa40dce472db0b5223aae5bbc to your computer and use it in GitHub Desktop.
Access Javascript geo info in GeotargetingWP
$(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