draw icons of the points of interest loaded from a .osm file
BIN
icons/atm.png
Normal file
After Width: | Height: | Size: 548 B |
BIN
icons/bank.png
Normal file
After Width: | Height: | Size: 611 B |
BIN
icons/bus_stop.png
Normal file
After Width: | Height: | Size: 522 B |
BIN
icons/cinema.png
Normal file
After Width: | Height: | Size: 616 B |
BIN
icons/drinking_water.png
Normal file
After Width: | Height: | Size: 437 B |
BIN
icons/fuel.png
Normal file
After Width: | Height: | Size: 505 B |
BIN
icons/hospital.png
Normal file
After Width: | Height: | Size: 477 B |
BIN
icons/hostel.png
Normal file
After Width: | Height: | Size: 502 B |
BIN
icons/hotel.png
Normal file
After Width: | Height: | Size: 467 B |
BIN
icons/museum.png
Normal file
After Width: | Height: | Size: 516 B |
BIN
icons/parking.png
Normal file
After Width: | Height: | Size: 453 B |
BIN
icons/pharmacy.png
Normal file
After Width: | Height: | Size: 342 B |
BIN
icons/recycling.png
Normal file
After Width: | Height: | Size: 599 B |
BIN
icons/speed_camera.png
Normal file
After Width: | Height: | Size: 456 B |
BIN
icons/telephone.png
Normal file
After Width: | Height: | Size: 673 B |
BIN
icons/toilets.png
Normal file
After Width: | Height: | Size: 647 B |
BIN
icons/viewpoint.png
Normal file
After Width: | Height: | Size: 636 B |
25
poilayer.cpp
@ -22,7 +22,9 @@
|
||||
#include "mapwidget.h"
|
||||
#include "projection.h"
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtXml/QXmlStreamReader>
|
||||
|
||||
PoiLayer::PoiLayer(MapWidget *map) :
|
||||
@ -30,8 +32,15 @@ PoiLayer::PoiLayer(MapWidget *map) :
|
||||
m_points(),
|
||||
m_pointsOnScreen(),
|
||||
m_icons(),
|
||||
m_pointsOffset(0, 0)
|
||||
m_pointsOffset(0, 0),
|
||||
m_iconPath(),
|
||||
m_iconCache()
|
||||
{
|
||||
QSettings set(QDir::homePath()+"/Maps/nanomap.conf", QSettings::NativeFormat);
|
||||
|
||||
set.beginGroup("poi");
|
||||
m_iconPath = set.value("iconpath", "/usr/share/NanoMap/icons").toString();
|
||||
set.endGroup();
|
||||
}
|
||||
|
||||
void PoiLayer::load(const QString &filename)
|
||||
@ -83,9 +92,15 @@ void PoiLayer::load(const QString &filename)
|
||||
foreach (const QString &c, categories) {
|
||||
QString t = tags.value(c, "");
|
||||
if (!t.isEmpty()) {
|
||||
m_points << pos;
|
||||
m_icons << t;
|
||||
break;
|
||||
QString icon = m_iconPath+"/"+t+".png";
|
||||
if (QFile::exists(icon)) {
|
||||
if (!m_iconCache.contains(t)) {
|
||||
m_iconCache.insert(t, new QPixmap(icon));
|
||||
}
|
||||
m_points << pos;
|
||||
m_icons << t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
tags.clear();
|
||||
@ -120,7 +135,7 @@ void PoiLayer::paint(QPainter *painter)
|
||||
QPoint p;
|
||||
for (int i = 0; i < m_pointsOnScreen.count(); ++i) {
|
||||
p = m_pointsOnScreen.at(i);
|
||||
painter->drawEllipse(p + m_pointsOffset, 5, 5);
|
||||
painter->drawPixmap(p + m_pointsOffset, *m_iconCache.value(m_icons.at(i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ private:
|
||||
QList<QPoint> m_pointsOnScreen;
|
||||
QStringList m_icons;
|
||||
QPoint m_pointsOffset;
|
||||
QString m_iconPath;
|
||||
QHash<QString, QPixmap*> m_iconCache;
|
||||
|
||||
};
|
||||
|
||||
|