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).


  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);
    PopupDefinition* popdef = new PopupDefinition(geoElement);
    Popup* popup = new Popup(geoElement, popdef);
    // create a popup manager
    PopupManager* popupManager = new PopupManager{popup, this};
    // append popup manager to list
    // notify QML that m_popupManagers has changed and to display the popup(s).
    emit popupManagersChanged();

} }


enter image description here

  • Added code lines, also attached output popup. Aug 8 at 12:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.