• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

100
Views
Trying to Bind Tooltip to Result of Turf Distance Method

I'm trying to simply put the results of the distance variable in the tooltip but keep getting undefined. I don't understand what's happening. I know it's something simple. Thanks!

                
                // convert Leaflet layer to geojson with Leaflet toGeoJSON() method
                var centCounty = countyPolygon.toGeoJSON();

                // get centroid of county polygon
                var centroid = turf.centerOfMass(centCounty);

                // create marker from centroid
                var lon = centroid.geometry.coordinates[0];
                var lat = centroid.geometry.coordinates[1];
                
                var marker = L.marker([lat, lon]).addTo(map).bindTooltip(`${distance} Miles`).openTooltip();

                var distanceGeoJSON = marker.toGeoJSON();

                var from = searchedFeature
                var to = distanceGeoJSON
                var options = {units: 'miles'};

                var distance = turf.distance(from, to, options);
                console.log(distance)
  
            }
        }```
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error