@@ -1558,6 +1558,19 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
1558
1558
featureElement.appendChild ( attributeElement );
1559
1559
}
1560
1560
1561
+ // add maptip attribute based on html/expression (in case there is no maptip attribute)
1562
+ if ( layer->fieldNameIndex ( layer->displayField () ) < 0 )
1563
+ {
1564
+ QString displayField = layer->displayField ();
1565
+ if ( !displayField.isEmpty () )
1566
+ {
1567
+ QDomElement maptipElem = infoDocument.createElement ( " Attribute" );
1568
+ maptipElem.setAttribute ( " name" , " maptip" );
1569
+ maptipElem.setAttribute ( " value" , QgsExpression::replaceExpressionText ( displayField, &feature, layer ) );
1570
+ featureElement.appendChild ( maptipElem );
1571
+ }
1572
+ }
1573
+
1561
1574
// append feature bounding box to feature info xml
1562
1575
if ( hasGeometry && mapRender )
1563
1576
{
@@ -2608,6 +2621,20 @@ QDomElement QgsWMSServer::createFeatureGML(
2608
2621
typeNameElement.appendChild ( fieldElem );
2609
2622
}
2610
2623
2624
+ // add maptip attribute based on html/expression (in case there is no maptip attribute)
2625
+ if ( layer->fieldNameIndex ( layer->displayField () ) < 0 )
2626
+ {
2627
+ QString displayField = layer->displayField ();
2628
+ if ( !displayField.isEmpty () )
2629
+ {
2630
+ QString fieldTextString = QgsExpression::replaceExpressionText ( displayField, feat, layer );
2631
+ QDomElement fieldElem = doc.createElement ( " qgs:maptip" );
2632
+ QDomText maptipText = doc.createTextNode ( fieldTextString );
2633
+ fieldElem.appendChild ( maptipText );
2634
+ typeNameElement.appendChild ( fieldElem );
2635
+ }
2636
+ }
2637
+
2611
2638
return typeNameElement;
2612
2639
}
2613
2640
0 commit comments