I have a KML layer on my map. I want to have a customized popup that will appear on click of placemark on my KML layer. I want to have customized fields in my popup.
I am using C++ qt SDK and tried to create the popup (as shown in the below code), but it is not working properly, It still gives me a default popup with the placemark city name (Attaching result below).
code:
for (GeoElement* geoElement : elements)
{
QJsonObject root;
root["Name"] = "Sample1";
root["Age"] = "20";
root["city"] = "Mumbai";
QJsonDocument doc(root);
QList<PopupElement*> elist;
QString strJson(doc.toJson(QJsonDocument::Compact));
PopupElement* ele = PopupElement::fromJson(strJson,this);
elist.append(ele);
PopupDefinition* popdef = new PopupDefinition(geoElement);
popdef->setElements(elist);
Popup* popup = new Popup(geoElement, popdef);
// create a popup manager
PopupManager* popupManager = new PopupManager{popup, this};
// append popup manager to list
m_popupManagers.append(popupManager);
// notify QML that m_popupManagers has changed and to display the popup(s).
emit popupManagersChanged();
}
} }
Output: