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
- function updateMap for Google Maps API
- Type error: cannot convert the series to
- JSON to pandas DataFrame
- How can I change the color of a Google Maps marker?
- Using google API to tell how busy a place is
- Google Maps API DeletedApiProjectMapError
- “google is not defined” when using Google Maps V3 in Firefox remotely
- ApiNotActivatedMapError for simple html page using google-places-api
- google my maps ~ custom map embed into wordpress
- How to query posts based on lat-lng coordinate as post meta?
- Remove extra Google Maps script
- Google Maps not displaying in wordpress using Google Maps Javascript API
- Custom Post Type with Input fields to seperate table on database.
- Integrating Google Maps with custom marker and hover?
- How can I run shortcode after click with ajax
- Geocoding an Exploded Custom Field Array
- WordPress Google Maps in Custom Theme
- Google Maps and Yandex Maps doesn’t work correctly
- Show posts on a Google Map
- 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
- Locate authors on Google map version 3
- Problem Building a Simple Google Maps Plugin
- Google Map iframe in a tab issue
- Putting PHP variables into javascript [duplicate]
- Google maps causing mixed content in header
- 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
- Refresh Markercluster after ajax call
- 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]
- Querying posts by latitude and longitude to build a Google Maps with several markers
- passing markup thought a shortcode attribute
- Anybody knows if i could upload a leaflet or openlayers3 map to wordpress webpage?
- Understanding WordPress Search
- Using custom post types WordPress network
- 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?
- PHP variables in a post?
- Javascript Function Called Too Early in PHP Script
- MapPress Easy Google Map in Jquery Tabs Problem
- Updating failed. The response is not a valid JSON response. specific to my browser when I include javascript in my html
- Nearby locations using Advanced custom fields, maps?
- Form behaving differently on small screens vs desktop screen
- ACF Map with custom styles field
- Adding External Gmap JS to WordPress
- Insert Google Maps HTML in WordPress
- Filtering markers on google map by WordPress category[SOLVED]
- Post title and url not showing on google map marker [closed]
- Generate a radius search of custom post type locations
- Advanced Custom Fields – Google Map Won’t Render Unless Variable Dumped
- Display posts on a map
- Foreach loop inside foreach loop?
- Show different Google Map markers for different post_meta values
- Querying latitude and longitude into google maps correctly
- Plugin options with googlemap iframe
- Plugin – including external javascript calling google maps
- Geolocate Custom Post Type on Save
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Adding a google map to a metabox, map has inline style height=0
- Search Results with googlemaps
- Elfsight Google Maps Plugin Version 2.1.0 : Location image input not found [closed]
- Custom Backend data for map to JSON file?
- Including Google Map within a wordpress plugin
- How can i add a script with parameters?
- Googlemap not initialising