def test_location(): g = geocoder.location('45.4215296, -75.6971931') assert g.ok g = geocoder.location({'lat': 45.4215296, 'lng': -75.6971931}) assert g.ok g = geocoder.location([45.4215296, -75.6971931]) assert g.ok
def change_pos_by_line(self): self.coords = ','.join( list( reversed( list( map(str, geocoder.location(self.lineEdit.text()).latlng))))) print(self.coords) self.pointer = self.coords if self.coords == '': self.coords = '90,0' self.params = self.params = { "ll": self.coords, "z": str(self.zoom), "size": '650,450', "l": self.layer } else: self.params = { "ll": self.coords, "z": str(self.zoom), "size": '650,450', "l": self.layer, "pt": self.coords + ',pm2rdm' } self.update_map()
def _get_forecast(location): a = geocoder.location(location=location) lat = a.latlng[0] lng = a.latlng[1] forecast = forecastio.load_forecast(API_KEY, lat, lng) return forecast
def weather_latest(loca): a = geocoder.location(location=loca) api_key = "c5dde0bafce3442350c75b743864339a" lat = a.latlng[0] lng = a.latlng[1] forecast = forecastio.load_forecast(api_key, lat, lng, time=datetime.now()) this = forecast.currently().d return this
def weather_on(loca): a = geocoder.location(location=loca) api_key = "c5dde0bafce3442350c75b743864339a" lat = a.latlng[0] lng = a.latlng[1] forecast = forecastio.load_forecast(api_key, lat, lng, time=datetime.now()) byHour = forecast.hourly() return byHour
def map_creator(data): """ list -> None :param data: list of the strings, where contains names of different users. Create folium map with icons, each icon corresponds with one account location. """ twi_fg = folium.FeatureGroup(name='Users') twi_map = folium.Map(location=geocoder.location('Lisabon'), zoom_start=2, tiles='Stamen Toner') for i in data: user = twitter_data.account(i) place = user.get('location', False) if place: # get coordinates coor = geocoder.location(place) twi_fg.add_child( folium.Marker(location=coor, popup=info(user), icon=folium.Icon())) twi_map.add_child(twi_fg) twi_map.save('templates/Twi_map.html')
def getLocations(results,markers): for tweet in results: if tweet['coords'] != None: info = {} info['icon'] = 'http://maps.google.com/mapfiles/ms/icons/green-dot.png' info['lat'] = tweet['coords'][0] info['lng'] = tweet['coords'][1] info['infobox'] = "<img src='"+tweet["userimageurl"]+"'/>" markers.append(info) elif tweet['location'] != None: match = regex.match(tweet['location']) if match: try: loc = geocoder.location(tweet['location']) info = {} info['icon'] = 'http://maps.google.com/mapfiles/ms/icons/green-dot.png' info['lat'] = loc.latlng[0] info['lng'] = loc.latlng[1] info['infobox'] = "<img src='"+tweet["userimageurl"]+"'/><br>"+tweet["username"] markers.append(info) except: print("no coorinates for location: ", tweet['location'], " could be found")
import geocoder #to get the lattitude and longitude of my current location import location g = geocoder.ip('me') #print(g.latlng) city_name = input("Enter city name: ") geoloc_city = geocoder.location(city_name) print geoloc_city