def search(self): try: global coords, scale, point coords, json_response = self.get_coords(self.search_area.text()) scale = map_scale(json_response) point = "{0},{1}".format(str(coords[0]), str(coords[1])) self.load_map() except Exception: print('Адрес не найден')
def search(self): try: global coords, scale, point coords, json_response = self.get_coords(self.search_area.text()) scale = map_scale(json_response) point = "{0},{1}".format(str(coords[0]), str(coords[1])) toponym = json_response["response"]["GeoObjectCollection"][ "featureMember"][0]["GeoObject"] toponym_address = toponym["metaDataProperty"]["GeocoderMetaData"][ "text"] self.address_label.setText(toponym_address) self.load_map() except Exception: self.address_label.setText('Адрес не найден')
def search(self): global coords, scale, point try: coords, json_response = self.get_coords(self.search_area.text()) scale = map_scale(json_response) point = "{0},{1}".format(str(coords[0]), str(coords[1])) toponym = json_response["response"]["GeoObjectCollection"]["featureMember"][0]["GeoObject"] toponym_address = toponym["metaDataProperty"]["GeocoderMetaData"]["text"] if not postal_index: self.address_label.setText(toponym_address) else: index = toponym["metaDataProperty"]["GeocoderMetaData"]['Address']['postal_code'] self.address_label.setText(toponym_address + ' Почтовый индекс:' + index) self.load_map() except Exception: self.address_label.setText('Адрес не найден')