Add a POI on the map (ii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.