def __init__(self, shape, text, parent=None): QGraphicsItemGroup.__init__(self, parent=parent) text = QGraphicsSimpleTextItem(text, parent=shape) br = shape.boundingRect() x = br.right() + 10 y = br.top() + 3 text.setPos(x, y) self.addToGroup(shape) self._text = text
def __init__(self, other_item, text, parent=None, min_zoom_visibility=None): QGraphicsSimpleTextItem.__init__(self, text, parent=parent) MapItem.__init__(self) self.other_item = other_item self._min_zoom = min_zoom_visibility self._border = QGraphicsRectItem(parent=self) self._border.setPen(QPen(Qt.NoPen)) self._border.setBrush(QBrush(QColor(190, 190, 190, 160)))
def __init__(self, longitude, latitude, text, parent=None, min_zoom_visibility=None): QGraphicsSimpleTextItem.__init__(self, text, parent=parent) MapItem.__init__(self) self._min_zoom = min_zoom_visibility self._lon, self._lat = longitude, latitude self._border = QGraphicsRectItem(parent=self) self._border.setPen(QPen(Qt.NoPen)) self._border.setBrush(QBrush(QColor(190, 190, 190, 160)))
def __init__(self, longitude, latitude, text, parent=None, min_zoom_visibility=None): QGraphicsSimpleTextItem.__init__(self, text, parent=parent) MapItem.__init__(self) self._min_zoom = min_zoom_visibility self._lon, self._lat = longitude, latitude
def __init__(self): QMainWindow.__init__(self) view = MapGraphicsView(tileSource=MapTileSourceHere()) self.setCentralWidget(view) view.scene().setCenter(10.065990, 44.861041) view.setOptimizationFlag(QGraphicsView.DontSavePainterState, True) view.setRenderHint(QPainter.Antialiasing, True) view.setRenderHint(QPainter.SmoothPixmapTransform, True) pointItem = view.scene().addCircle(10.068640, 44.860767, 3.0) pointItem.setBrush(Qt.black) pointItem.setToolTip('10.068640, 44.860767') pointItem.setFlag(QGraphicsItem.ItemIsSelectable, True) lats = list() lons = list() for p in POINTS: pointItem = view.scene().addCircle(p[1], p[0], 5.0) pointItem.setBrush(Qt.green) pointItem.setPen(QPen(Qt.NoPen)) pointItem.setToolTip('%f, %f' % (p[1], p[0])) pointItem.setFlag(QGraphicsItem.ItemIsSelectable, True) lons.append(p[1]) lats.append(p[0]) lineItem = view.scene().addLine(10.191037, 44.832810, 10.201736, 44.837632) lineItem.setPen(QPen(QBrush(Qt.blue), 3.0)) polylineItem = view.scene().addPolyline(lons, lats) polylineItem.setPen(QPen(QBrush(Qt.red), 3.0)) pix = QPixmap(24, 24) pix.fill(Qt.red) pixmapItem = view.scene().addPixmap(10.090598, 44.857893, pix) pixmapItem.setOffset(-12, -12) pointItemPixmapOrigin = view.scene().addCircle(10.090598, 44.857893, 3.0) pointItemPixmapOrigin.setBrush(Qt.black) pointItemWithChild = view.scene().addCircle(10.083103, 44.858014, 3.0) pointItemWithChild.setBrush(Qt.blue) pointItemWithChild.setPen(QPen(Qt.NoPen)) textItem = QGraphicsSimpleTextItem('Annotation\nfor blue point', parent=pointItemWithChild) textItem.setBrush(QBrush(QColor(Qt.blue))) textItem.setPos(-5, 3) lats_2 = list() lons_2 = list() for p in POINTS_2: lons_2.append(p[1]) lats_2.append(p[0]) linesGroupItem = view.scene().addLinesGroup(lons_2, lats_2) linesGroupItem.setLineStyle(POINTS_2_COLORS, width=POINTS_2_SIZES) legendItem = view.scene().addLegend() legendItem.addPoint('Point 1', '#FF0000', border=None) legendItem.addRect('Rect 2', '#00FF00', border=None) legendItem.addPoint('Circle 3', '#0000FF', border=None) legendItem.addRect('Sphere 4', '#00FFFF', border=None) legendItem.addPoint('Polygon 5', '#FF00FF', border=None) scaleItem = view.scene().addScale(anchor=Qt.BottomRightCorner)