Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
71b84a0
Added ImageButtons and Navigation:
bhonecode Oct 15, 2017
54012d4
added zoom level to mapscene setCenter
bhonecode Jan 17, 2018
46e5476
pytilemap commit did not go well
bhonecode Jan 25, 2018
919f97f
unable to undo accidentail delete of pytilemap directory, so adding i…
bhonecode Jan 25, 2018
fed1717
Revert "unable to undo accidentail delete of pytilemap directory, so …
bhonecode Jan 25, 2018
328e8a7
Revert "pytilemap commit did not go well"
bhonecode Jan 25, 2018
ddfdbdc
fixed tile loading problem in maptilesourcehere
bhonecode Jul 27, 2018
8b812ef
added geo registered pixmap
bhonecode Jul 28, 2018
bdecbb9
added right-click area selection to mapscene
bhonecode Jul 29, 2018
f291f16
experimented with different tile soures, fixed rectangle drawing
bhonecode Jul 31, 2018
024f546
- Added "Pin" Icons
bhonecode Aug 16, 2018
811d6e8
fixed map pin support
bhonecode Aug 16, 2018
b9087ca
fixed lines group - it was iterating over one too few lines in update
bhonecode Aug 18, 2018
57f8c2e
mapscene rubberband drawing now is generic - has an enable to start a…
bhonecode Aug 28, 2018
9a3f883
mapscene emits a signal when scene shifts/zooms, using custom tile ca…
bhonecode Aug 30, 2018
79893f4
added geo svg to mapitems
bhonecode Aug 27, 2019
f864bcb
added geo svg
bhonecode Aug 27, 2019
a07a65a
better use of qt api in image scaling
bhonecode Aug 27, 2019
3db839a
added GeoPixmapItemCorners
bhonecode Aug 29, 2019
614ef5c
updated readme
bhonecode Aug 29, 2019
1ec9612
more readme fixes
bhonecode Aug 29, 2019
d3aaae2
adde screenshot
bhonecode Aug 29, 2019
d724656
Added screenshot to readme
bhonecode Aug 29, 2019
5d35a20
try image again
bhonecode Aug 29, 2019
72ba8ff
try image again
bhonecode Aug 29, 2019
aa5e231
working rotation code
bhonecode Oct 7, 2019
2d545aa
cleanups to example
bhonecode Oct 3, 2020
671c243
updated README and remove debug printouts
bhonecode Oct 3, 2020
11f321a
synced mapitems from sandbox
bhonecode Oct 5, 2020
6cfab97
updated README
May 27, 2022
3350ec6
fixed __init__
Jan 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
__pycache__/
*.py[cod]

# Ctags
tags

# C extensions
*.so

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include pytilemap/*.png
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
# PyTileMap

Tile map visualization for PyQt4.
PyQt Map System forked from:

This project allows the visualization of Open Street Map, HERE and other maps
in a PyQt4 GUI.
https://github.com/allebacco/PyTileMap

The project has been inspired from of https://github.com/emka/python-lightmaps.
Simple to use map widget that can be used in a PyQt GUI.

# Install:
python setup.py install

# Example:

examples/main_gs.py

# Map Widgets

- MapGraphicsLineItem - a line between two lat/lon points
- MapGraphicsPolyLineItem - lines between a series of lat/lon points
- MapGraphicsPixmapItem - place a pixmap at a given lat/lon (does not scale with map zoom)
- MapGraphicsTextItem - place text at a given lat/lon
- MapGraphicsLinesGroupItem - a group of lines
- MapGraphicsCircleItem - draw a circle centered at a lat/lon
- MapGraphicsRectItem - draw a rectangle given upper left and lower right lat/lon (scales with zoom)
- MapGraphicsRectShapeItem - draw a rectangle with a fixed with and height (does not scale with zoom)
- MapGraphicsGeoSvgItem - draw an svg given upper left and lower right lat/lon (scales with zoom)
- MapGraphicsGeoPixmapItem - draw a pixmap given upper left and lower right lat/lon (scales with zoom)
- MapGraphicsGeoPixmapItemCorners - draw a pixmap given all four lat/lon corners (scales with zoom)
- MapGraphicsLabelItem - a label that is attached to another map item

# Screenshot
![Screenshot](screenshot.png)

# Other Python Maps

https://github.com/TomSchimansky/TkinterMapView
52 changes: 45 additions & 7 deletions example/main_gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pytilemap import MapGraphicsView, MapTileSourceHere, MapTileSourceOSM



POINTS = [(44.837632, 10.201736),
(44.837621, 10.201474),
(44.837594, 10.201205),
Expand Down Expand Up @@ -77,7 +78,7 @@ def __init__(self):

self.setCentralWidget(view)

view.scene().setCenter(10.065990, 44.861041)
view.scene().setCenter(10.065990, 44.861041, zoom=13)
view.setOptimizationFlag(QGraphicsView.DontSavePainterState, True)
view.setRenderHint(QPainter.Antialiasing, True)
view.setRenderHint(QPainter.SmoothPixmapTransform, True)
Expand Down Expand Up @@ -111,13 +112,46 @@ def __init__(self):
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))
# Pixmap with both corners geo-referenced
geo_pixmap = QPixmap(36,36)
geo_pixmap.fill(Qt.blue)
geo_pixmap_item= view.scene().addGeoPixmap(10.090598, 44.8709, 10.092, 44.873, geo_pixmap)
geo_pixmap_item.setLabel("GeoPixmapItem")
geo_pixmap_item.showLabel()

# Blue Point with an HTML label
blue_point = view.scene().addCircle(10.083103, 44.868014, 3.0)
blue_point.setBrush(Qt.blue)
blue_point.setPen(QPen(Qt.NoPen))
blue_point.setLabel("<div style='background-color: #ffff00;'>" + "Label for Blue Point" + "</div>", html=True)
blue_point.showLabel()

# Location Pin
pin_item = view.scene().addPin(10.06, 44.84)
pin_item.setLabel("<div style='background-color: #00ff00;'><I>Pin Item</I></div>",html=True)
pin_item.showLabel()

# Pixmap with all four corners geo-referenced
lon0r = 10.06
lat0r = 44.83
lon1r = 10.110000000000001
lat1r = 44.743397459621555
lon2r = 9.936794919243113
lat2r = 44.64339745962155
lon3r = 9.886794919243112
lat3r = 44.73

clr = QColor(0,255,0,100)
pix = QPixmap(100,100)
pix.fill(clr)

view.scene().addGeoPixmapCorners(lon0r, lat0r,
lon1r, lat1r,
lon2r, lat2r,
lon3r, lat3r,
pix)


textItem = QGraphicsSimpleTextItem('Annotation\nfor blue point', parent=pointItemWithChild)
textItem.setBrush(QBrush(QColor(Qt.blue)))
textItem.setPos(-5, 3)

lats_2 = list()
lons_2 = list()
Expand All @@ -134,8 +168,12 @@ def __init__(self):
legendItem.addRect('Sphere 4', '#00FFFF', border=None)
legendItem.addPoint('Polygon 5', '#FF00FF', border=None)

navItem = view.scene().addNavItem(anchor=Qt.TopRightCorner)

scaleItem = view.scene().addScale(anchor=Qt.BottomRightCorner)




def main():
w = MapZoom()
Expand Down
7 changes: 6 additions & 1 deletion pytilemap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

from .mapscene import MapGraphicsScene
from .mapview import MapGraphicsView
from .mapitems import MapGraphicsCircleItem, MapGraphicsLineItem, \
from .mapitems import MapItem, MapGraphicsCircleItem, MapGraphicsLineItem, \
MapGraphicsPolylineItem, MapGraphicsPixmapItem, MapGraphicsTextItem, \
MapGraphicsRectItem
from .maplegenditem import MapLegendItem
from .mapescaleitem import MapScaleItem
from .maptilesources import MapTileSource, MapTileSourceHere, MapTileSourceHereDemo, \
MapTileSourceOSM, MapTileSourceHTTP
from .mapnavitem import MapNavItem
from .imagebutton import ImageButton


__all__ = [
Expand All @@ -26,6 +28,9 @@
'MapTileSourceHereDemo',
'MapTileSourceOSM',
'MapTileSourceHTTP',
"MapNavItem",
"ImageButton",
"MapItem"
]

__version__ = '1.0.0'
39 changes: 39 additions & 0 deletions pytilemap/imagebutton.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from __future__ import print_function, absolute_import

from qtpy.QtCore import Qt, Signal
from qtpy.QtWidgets import QGraphicsObject, QGraphicsItemGroup, QGraphicsPixmapItem

class ImageButton(QGraphicsObject):
'''
Custom Image Holder Class that Allows for event handling -
- QGraphicsPixmapItem is not a QObject, so cannot catch events.
'''
QtParentClass = QGraphicsObject

clicked = Signal(int)

def __init__(self, img, parent=None):
'''
Args:
img: A QPixmap instance

Keyword Args:
parent: A pyqt window instance
'''
QGraphicsObject.__init__(self, parent=parent)
self.image = QGraphicsPixmapItem(img, parent=self)
self.parent = parent

def paint(self, painter, option, widget):
self.image.paint(painter,option,widget)

def boundingRect(self):
return self.image.boundingRect()

def mouseReleaseEvent(self, event):
self.clicked.emit(1)

def mousePressEvent(self, event):
pass
# end ImageButton

Loading