Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

google map distance

function haversine_distance(mk1, mk2) {
      var R = 3958.8; // Radius of the Earth in miles
      var rlat1 = mk1.position.lat() * (Math.PI/180); // Convert degrees to radians
      var rlat2 = mk2.position.lat() * (Math.PI/180); // Convert degrees to radians
      var difflat = rlat2-rlat1; // Radian difference (latitudes)
      var difflon = (mk2.position.lng()-mk1.position.lng()) * (Math.PI/180); // Radian difference (longitudes)

      var d = 2 * R * Math.asin(Math.sqrt(Math.sin(difflat/2)*Math.sin(difflat/2)+Math.cos(rlat1)*Math.cos(rlat2)*Math.sin(difflon/2)*Math.sin(difflon/2)));
      return d;
    }
Comment

Google map distance

# importing googlemaps module
import googlemaps
  
# Requires API key
gmaps = googlemaps.Client(key='Your_API_key')
  
# Requires cities name
my_dist = gmaps.distance_matrix('Delhi','Mumbai')['rows'][0]['elements'][0]
  
# Printing the result
print(my_dist)
Comment

PREVIOUS NEXT
Code Example
Python :: del(list) python 
Python :: Tree recursive function 
Python :: rstrip python3 
Python :: print column name and index dataframe python 
Python :: django cache framework 
Python :: python3 
Python :: what are while loops 
Python :: subtract constant from list 
Python :: Python - How To Convert String to ASCII Value 
Python :: InsertionSort 
Python :: pd column to one hot vector 
Python :: pydantic numpy ndarray type 
Python :: python string: index error 
Python :: Python - Comment vérifier une corde est vide 
Python :: how to join two string series python 
Python :: summary r language equivalent in python 
Python :: how to add the number to email address in faker library in python? 
Python :: print prime nos from 1 to n 
Python :: reverse every word from a sentence but maintain position 
Python :: django Mixed Content: The page at ' was loaded over HTTPS, but requested an insecure resource swagger 
Python :: pandas add prefix to some range of columns 
Python :: video in python without cv2 
Python :: python code to open facebook and login with username and password 
Python :: pytest rerun last failed 
Python :: convert dictionary to 2d array python 
Python :: how to replace zero with null in python 
Python :: pycharm writing issue 
Python :: yield value from csv file python 
Python :: python - matching people based on city 
Python :: nlp.Defaults.stop_words.add spacy 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =