M1Geolocation Library

These functions provide access to different options on geolocation using the Google API.

 

Import


To use this library and its functions, you must use the import line at the beginning of your Base Python code.

import M1Geolocation

 

Functions

 

M1Geolocation.get_address_from_geopoint

Usage: M1Geolocation.get_address_from_geopoint(latitude,longitude)

Returns the address associated to the geopoint in parameters

  • Credit cost: 1
  • Parameters:
    • latitudestr Latitude of the geopoint
    • longitudestr Longitude of the geopoint
  • Sample Code:
    import M1Geolocation
    value = M1Geolocation.get_address_from_geopoint("YOUR_LATITUDE","YOUR_LONGITUTDE")
  • Returns:
    • list List of dicts of the form:
      [{"geometry":
      {"location_type":"ROOFTOP",
      "viewport":
      {"northeast":{"lat":33.8897619802915,"lng":-118.1983450197085},
      "southwest":{"lat":33.8870640197085,"lng":-118.2010429802915}},
      "location":{"lat":33.888413,"lng":-118.199694}},
      "address_components":[
      {"long_name":"4006","short_name":"4006","types":["street_number"]},
      {"long_name":"East Alondra Boulevard","short_name":"E Alondra Blvd","types":["route"]},
      {"long_name":"Compton","short_name":"Compton","types":["locality","political"]},
      {"long_name":"Los Angeles County","short_name":"Los Angeles County","types":["administrative_area_level_2","political"]},
      {"long_name":"California","short_name":"CA","types":["administrative_area_level_1","political"]},
      {"long_name":"United States","short_name":"US","types":["country","political"]},
      {"long_name":"90221","short_name":"90221","types":["postal_code"]},
      {"long_name":"4669","short_name":"4669","types":["postal_code_suffix"]}],
      "place_id":"ChIJlXGZHKTMwoAR7Tn_xz5MOd8",
      "formatted_address":"4006 East Alondra Boulevard, Compton, CA 90221, USA",
      "types":["street_address"]
      },
      ...
      ]



M1Geolocation.get_geopoint_from_address

Usage: M1Geolocation.get_geopoint_from_address(address)

Returns the geopoint associated to the address in parameter

  • Credit cost: 1
  • Parameters:
    • addressstr
  • Sample Code:
    import M1Geolocation
    value = M1Geolocation.get_geopoint_from_address("YOUR_ADDRESS")
  • Returns:
    • list List of dicts of the form:
      [{"geometry":
      {"location_type":"ROOFTOP",
      "viewport":
      {"northeast":{"lat":33.8897619802915,"lng":-118.1983450197085},
      "southwest":{"lat":33.8870640197085,"lng":-118.2010429802915}},
      "location":{"lat":33.888413,"lng":-118.199694}},
      "address_components":
      [{"long_name":"4006","short_name":"4006","types":["street_number"]},
      {"long_name":"East Alondra Boulevard","short_name":"E Alondra Blvd","types":["route"]},
      {"long_name":"Compton","short_name":"Compton","types":["locality","political"]},
      {"long_name":"Los Angeles County","short_name":"Los Angeles County","types":["administrative_area_level_2","political"]},
      {"long_name":"California","short_name":"CA","types":["administrative_area_level_1","political"]},
      {"long_name":"United States","short_name":"US","types":["country","political"]},
      {"long_name":"90221","short_name":"90221","types":["postal_code"]},
      {"long_name":"4669","short_name":"4669","types":["postal_code_suffix"]}],
      "place_id":"ChIJlXGZHKTMwoAR7Tn_xz5MOd8",
      "formatted_address":"4006 East Alondra Boulevard, Compton, CA 90221, USA",
      "types":["street_address"]
      },
      ...
      ]



M1Geolocation.get_location_from_ip

Usage: M1Geolocation.get_location_from_ip(ip)

  • Credit cost: 100
  • Parameters:
    • ipstr
  • Sample Code:
    import M1Geolocation
    value = M1Geolocation.get_location_from_ip("YOUR_IP")
  • Returns:
    • dict Dict of the form:
      {
      "city":     {
      "names": {}
      },
      "country":   ...,
      "continent": ...,
      ...
      }
Have more questions? Submit a request

0 Comments

Article is closed for comments.