I need to pass the lat and long for two address
function calculate_distance($lat1, $lon1, $lat2, $lon2, $unit) {
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
if ($unit == "K") {
return ($miles * 1.609344);
} else if ($unit == "N") {
return ($miles * 0.8684);
} else {
return $miles;
}
}
echo calculate_distance(32.9697, -96.80322, 29.46786, -98.53506, "M") . " Miles<br>";
Related Posts:
- ReferenceError: google is not defined
- google map API zoom range
- Is there a way to display all my posts on a single Google Map?
- WordPress Google Maps
- Google Maps in WordPress
- Google Maps API problem – initMap()
- ‘SiteOrigin Google Maps’ widget conflicting with ‘ProtheusThemes’
- Anyway to have google maps display multiple AND unique locations per individual posts/pages?
- Google Map is not working on the second tab of Tab Plugins
- How to pinpoint posts location with Google map v3?
- Geo Mashup Maps show only specified categories
- Maps search box autocomplete with callback JS function?
- create dynamic google map with iframe api
- Google map API Key restrictions does not recognize website IP
- How to get input value after google maps autocomplete?
- Google Maps API in wordpress
- Implement Google Maps JS on WordPress
- Add different custom markers for different post types in Google maps API
- ACF Google Maps – Multiple Pins
- Using Custom Field in Google Map Embed Code Works in One Theme, Not Another
- Google Map Integration
- Mixed Content: The page at ‘https://www.taylortireauto.com/?s=contacts’ was loaded over HTTPS [closed]
- Google map iframe into wordpress theme [closed]
- google map Info window [closed]
- Google Map not displayed [closed]
- WordPress – Generate Longitude Latitude Map into Page
- This page didn’t load Google Maps correctly. See the JavaScript console for technical details
- JSON to pandas DataFrame
- How can I change the color of a Google Maps marker?
- InvalidValueError: not an instance of HTMLInputElement
- Using google API to tell how busy a place is
- Google Maps API DeletedApiProjectMapError
- Google Maps JS API v3 – Simple Multiple Marker Example
- Getting “Cannot call a class as a function” in my React Project
- google my maps ~ custom map embed into wordpress
- Remove extra Google Maps script
- Google Maps not displaying in wordpress using Google Maps Javascript API
- Integrating Google Maps with custom marker and hover?
- Integrating PHP into Javascript to display map markers with Google API
- WordPress Google Maps in Custom Theme
- Travel Blog Plugins
- How can I automatically attach posts to a map?
- AJAX in WordPress, sending coords data to MySQL and show after into map
- Problem Building a Simple Google Maps Plugin
- Google Map iframe in a tab issue
- How to display Unicode correctly?
- I need to get an array from the wordpress database
- How to implement a Google map store locator
- Google Map Shortcode for Custom Taxonomy/Post Types
- Location-Based Pages displaying results near customer
- Google Map Latitude and Longitude values in form
- Display a post map on a blank/new page
- How to build a site with a map that shows where people offer and need help?
- Integrating PHP into Javascript to display map markers with Google API – problem with wp_localize
- Refresh Markercluster after ajax call
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- PHP array to JS array to use in google map
- GeoMashup plugin: how to customize cluster markers / icons? [closed]
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Extracting Address from Custom Post via Javascript for Google Maps API
- Plot location on Google map using full address specified in custom field
- This page can’t load Google Maps correctly [closed]
- passing markup thought a shortcode attribute
- Google map that plot’s several markers – each one with custom data
- how to display google maps with javascript
- Where is my google maps on my page? [closed]
- ACF Maps admin error: “For development purposes only” even after supplying api key
- Anybody knows if i could upload a leaflet or openlayers3 map to wordpress webpage?
- ACF google map not working [closed]
- Where to paste Google Map Snippet / JavaScript / CSS for WordPress integration
- how can i show a google map in custom post type
- Using the loop to set locations for all posts on a single google map
- How to automatically create an index of child sites at the root url for a multisite installation?
- Google Maps with categories
- PHP variables in a post?
- Javascript Function Called Too Early in PHP Script
- MapPress Easy Google Map in Jquery Tabs Problem
- Form behaving differently on small screens vs desktop screen
- Adding geographical information on a registration page
- Adding External Gmap JS to WordPress
- Insert Google Maps HTML in WordPress
- create a shortcode for embedding google map in a page
- mutiple shortcode instance on the same page
- Where is fusion-gmap-container?
- Advanced Custom Fields – Google Map Won’t Render Unless Variable Dumped
- Dealing with multiple Google maps API calls
- Querying latitude and longitude into google maps correctly
- Add routes between multiple ACF google maps markers [closed]
- Plugin options with googlemap iframe
- I want to split this into two functions
- Why won’t the Comprehensive Google Map Plugin load?
- Plugin – including external javascript calling google maps
- Geolocate Custom Post Type on Save
- How to extract specific image meta for all images?
- Cannot Hide Google Map if custom field is blank
- Search Results with googlemaps
- Elfsight Google Maps Plugin Version 2.1.0 : Location image input not found [closed]
- In WP, Google map error initMap is not a function [closed]
- Custom Backend data for map to JSON file?
- Google Map JavaScript error after migrating