def getPostion(self): if len(self.response["features"]) == 0: return None toponym = self.response["features"][0] coords = toponym['geometry']['coordinates'] toponym_longitude, toponym_lattitude = coords return Vector(float(toponym_longitude), float(toponym_lattitude))
def __init__(self): self.position = Vector(0, 0) self.size = 1 self.layer = "map" self.focusedAddress = None self.image = None self.markers = [] self.update()
def checkMouse(self, event): absX, absY = event.pos relX = absX - self.x relY = absY - self.y if relX >= self.width or relX < 0: return if relY >= self.height or relY < 0: return relCoords = Vector(relX - self.width // 2, -(relY - self.height // 2)) pixelAbs = Vector( merc_x(MapClassObject.position.x, MapClassObject.size), merc_y(MapClassObject.position.y, MapClassObject.size)) pixelAbs += relCoords lat, long = intoLatAndLong(pixelAbs.x, pixelAbs.y, MapClassObject.size) gradAbs = Vector(long, lat) self.callback(gradAbs, event)
def unitPositionSet(vect): positionDeltaX = 360 / (2**MapClassObject.size) positionDeltaY = 180 / (2**MapClassObject.size) return Vector(vect.x * positionDeltaX, vect.y * positionDeltaY)
def getPostion(self): toponym = self.response["response"]["GeoObjectCollection"][ "featureMember"][0]["GeoObject"] toponym_coodrinates = toponym["Point"]["pos"] toponym_longitude, toponym_lattitude = toponym_coodrinates.split(" ") return Vector(float(toponym_longitude), float(toponym_lattitude))
def main(): MapClassObject.setPosition(Vector(0, 0)) MapClassObject.update() while True: MainWindowClassObject.tick()