diff --git a/gmap_polyutil.inc b/gmap_polyutil.inc
index d33af92..78ac02a 100644
--- a/gmap_polyutil.inc
+++ b/gmap_polyutil.inc
@@ -16,6 +16,7 @@ DEFINE('GMAP_DP_EPSILON', 0.00001);
 DEFINE('GMAP_ZOOM_LEVELS', 18);
 DEFINE('GMAP_ZOOM_FACTOR', 2);
 
+use Drupal\gmap\GmapPolylineToolbox;
 
 /**
  * The following three functions will encode numbers so that they may be used
@@ -26,13 +27,12 @@ DEFINE('GMAP_ZOOM_FACTOR', 2);
  * differently--when generating Encoded Polylines, latitudes and longitudes are
  * encoded with gmap_polyutil_encode_signed(), and "levels" are encoded using
  * gmap_polyutil_encode_unsigned().
+ *
+ * @deprecated
  */
 function gmap_polyutil_encode_latlon($x) {
-  $x = round($x * 1e5) << 1;
-  if ($x < 0) {
-    $x = ~$x;
-  }
-  return _gmap_polyutil_encode($x);
+  include_once(drupal_get_path('module', 'gmap') . '/lib/Drupal/gmap/GmapPolylineToolbox.php');
+  return GmapPolylineToolbox::getInstance()->setLatLonNumber($x)->getEncodedLatLon();
 }
 
 function gmap_polyutil_encode_levels($x) {
