In the previous article to implement an icon + label marker need to use two Tangram marker, today, after analyzing the source of Tangram, found Tangram support a single marker display at the same time, which requires the use of nested style.
The style used in the previous article is two:
Style:pointsWhite, size: [3px,false
And
text: function () {return ' label '}, 100
But in fact points style supports the Text property, two merged into:
false, text :' function () {return \ ' title\ '} ', 100
The code is as follows
voidMarkerimpl::createmarker (ConstSTD::string&iconuri,ConstSTD::string&title) {qimage img (QString (ICONURI.C_STR ())); intwidth =img.width (); intHeight = img.height(); Auto ARGB=NewUnsignedint[Width *height]; for(inth=height-1; h>-1; --h) { for(intw=0; w<width; ++W) { intPIX =Img.pixelcolor (W, h). Rgba (); intPB = (pix >> -) &0xFF; intPR = (pix << -) &0x00ff0000; intpix1 = (pix &0xff00ff00) | PR |PB; Argb[w+ H*width] =pix1; }} M_map-Markersetbitmap (m_id, width, height, argb); Delete[] ARGB; Static Const Char* Marker_style_template ="{style: ' Points '," "color: ' White '," "size: [%1px,%2px]," "order:100," "Collide:false," "text: {" "Text_source: ' function () {return \ '%3\ '} '," "priority:100}}"; QString Iconstyle=QString (marker_style_template). Arg (width). arg (height). Arg (TITLE.C_STR ()); M_map-markersetstyling (m_id, Iconstyle.tostdstring (). C_STR ());}
A single-line YAML notation is used here, see http://baike.baidu.com/link?url=oZjxiBc2gjv6W4Kx3UpMIjzsBhmmY2MJ9VayYJx-1qAZZiN_ R16j2h8mmxh0j2a-eywjioi5zkkcy1ehsf8wik#2_2
Add a POI on the map (ii)