addBalloonStyle: Add BalloonStyle to KML Object

addBalloonStyleR Documentation

Add BalloonStyle to KML Object

Description

After creating a kml object, this method defines a style that can be used by Balloon features within the object. When a feature uses a balloon, be sure that the feature's styleUrl matches the desired styleid argument. See references for documentation on how to effectively use the text argument.

Usage

yourKMLobj$addBalloonStyle(styleid, bgColor, textColor, text, displayMode)

Arguments

styleid

Mandatory. Define the id for this style. kml features will need to reference this id to use the defined style. You may choose an id that has already been defined in other styles types such as LineStyle or PolyStyle.

bgColor

Define the background color of the balloon. This can be one of the predefined colors(), color as hex, or color as rgb object. (Default: "white")

textColor

Define the text color of the balloon. This can be one of the predefined colors(), color as hex, or color as rgb object. (Default: "black")

text

Define what text will appear in the balloon. This can be customized with each feature by using markup within the text. See references for more details. (Default: A CDATA markup that resembles the default kml balloon)

displayMode

Either "display" or "hide". Choose weather balloon will be displayed. (Default: "display")

Value

Does not return a value, simply adds style to kml objects style list

Note

styleid
Do not attempt to define more than one balloonstyle for the same styleid.
text
For advanced text arguments, wrap html in CDATA tags. You can use packages to build html such as R2HTML(uses headers that are not required by CDATA) or, if you are comfortable with html, just add your html text inside CDATA enclosures.
text = ''<![CDATA[
<b><font color='#CC0000' size='+3'>$[name]</font></b>
<br/><br/>
<font face='Courier'>$[description]</font>
]]>''

Author(s)

Brent Cameron
Department of Fisheries and Oceans Canada
Population Ecology Division

References

KML balloonStyle Reference

Examples


mykml = RKmlObject()
customtext = "This is the $[name]. <br/> Click on this to look at $[description]. <br/> See references for more custom text insert  options."
 
mykml$addBalloonStyle(styleid = "colorstyle1", bgColor = "violetred4", textColor = rgb(.2, .2, 1))
mykml$addBalloonStyle(styleid = "textstyle1", bgColor = "black", textColor = "white", text = customtext, displayMode = "display")
 
x = data.frame(cbind(c(45.9178, 46.807), c(-59.967, -60.321), c("colorstyle1", "textstyle1"), c("Color Example", "Text Example"), c("Louisbourg", "Neil's Harbour" )))
names(x) = c("lat", "lon", "styleUrl", "name", "description")
  
mykml$addPoint(x)
#mykml$preview()


brent0/kmlbuilder documentation built on Feb. 2, 2024, 2:05 a.m.