How do you add the "you are here" marker to Bing Maps Control - bing-maps

How do you add the "you are here" marker to the Bing Maps control? On the phone this is represented as a circle within a square and then there is an outer circle representing the location accuracy.
It looks like you could do it with a pushpin and a polgon but I'm hoping there is an easier/better way

You can use the GeoCoordinateWatcher class, which gives your current location, and then add a simple pushpin. I don't think the pushpin is a bad choice and/or a hard one to use.
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
GeoCoordinate loc = watcher.Position.Location;
if (loc.IsUnknown == true)
{
// Cannot retrieve the GPS position
return;
}
MyBingMap.SetView(loc, 17);
MapLayer pushPinLayer = new MapLayer();
MyBingMap.Children.Add(pushPinLayer);
Pushpin p = new Pushpin();
p.Content = "YOU ARE HERE";
p.Location = loc;
pushPinLayer.AddChild(p, loc, PositionOrigin.BottomLeft);

You asked two questions and Tuco has given you a good answer to the first one: how to add the pushpin. Here's the answer to your second question: how to style it.
To get the pushpin to look like a yellow dot in a black diamond with a white nimbus, you need to define this style and apply it to the pushpin. I could also tell you how to style white numbers centred on a black circle with a white nimbus, but then I'd have to kill you.
xmlns:m="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
<Style x:Key="CurrentLocationPushpinStyle" TargetType="m:Pushpin">
<Setter Property="BorderBrush" Value="#FFF4F4F5" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
<Rectangle Fill="Black" Height="25" Stroke="White" StrokeThickness="2" Width="25" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<CompositeTransform Rotation="45" TranslateX="-10" TranslateY="11"/>
</Rectangle.RenderTransform>
</Rectangle>
<Ellipse Fill="Yellow" Height="11" Stroke="Yellow" Width="11">
<Ellipse.RenderTransform>
<CompositeTransform TranslateX="-10" TranslateY="11"/>
</Ellipse.RenderTransform>
</Ellipse>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
A yellow dot is soooo last year. Mango uses a blue dot.

Related

DYMO print label text getting cut off

I am trying to print Address label on dymo labelwriter 450 turbo
But the text is getting cutoff
I am using the below xml to format the text
function getAddressLabelXml()
{
var labelXml = '<?xml version="1.0" encoding="utf-8"?>\
<DieCutLabel Version="8.0" Units="twips">\
<PaperOrientation>Landscape</PaperOrientation>\
<Id>Address</Id>\
<PaperName>30252 Address</PaperName>\
<DrawCommands>\
<RoundRectangle X="0" Y="0" Width="1581" Height="5040" Rx="270" Ry="270" />\
</DrawCommands>\
<ObjectInfo>\
<AddressObject>\
<Name>Address</Name>\
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />\
<BackColor Alpha="0" Red="255" Green="255" Blue="255" />\
<LinkedObjectName></LinkedObjectName>\
<Rotation>Rotation0</Rotation>\
<IsMirrored>False</IsMirrored>\
<IsVariable>True</IsVariable>\
<HorizontalAlignment>Left</HorizontalAlignment>\
<VerticalAlignment>Middle</VerticalAlignment>\
<TextFitMode>ShrinkToFit</TextFitMode>\
<UseFullFontHeight>True</UseFullFontHeight>\
<Verticalized>False</Verticalized>\
<StyledText/>\
<ShowBarcodeFor9DigitZipOnly>False</ShowBarcodeFor9DigitZipOnly>\
<BarcodePosition>BelowAddress</BarcodePosition>\
<LineFonts/>\
</AddressObject>\
<Bounds X="332" Y="150" Width="4455" Height="1260" />\
</ObjectInfo>\
</DieCutLabel>';
return labelXml;
}
Depending on the length and height of the text, the text is either getting cutoff on the top or on the right
I am looking for a way to auto fit the text inside the label
Thanks in advance.
Change the TextFitMode value from 'ShrinkToFit' to 'AlwaysFit'

sapui5 how to display value over 100 percentage on radial chart

I am trying to show percentage value on radial chart, but radial chart's percentage property only allow me to display value between 0 and 100.
How can I do this?
Having a view with id__xmlview0,
and a chart with id RadialMicroChart1:
$("#__xmlview0--RadialMicroChart1 > svg > text").text(yourText)
It will work even if you have several charts.
SAP does not allow values over 100% for Radial Micro Charts, you could try setting the value using JQuery and manipulating fraction and total to fit your case.
Using the charts unique id for the first chart chartRadial1 to get it's element.
Update:
Bare in mind that, depending on the layout of your view, the children might change and you would have to research more into nth and children selectors to make sure you are selecting the right one but for this example its the svg's 6th child.
var percent = $(".sapSuiteRMCFont");
percent.text("200%");
OR In Controller & View:
press: function(oEvent) {
var myVal = 150,
myTotal = 200,
actTotal = 100,
newVal = (myVal * actTotal) / myTotal;
this.getView().byId("chartRadial1").setPercentage(newVal);
//with the given id in xml view, you can be certain only the text for chartRadial1 will change using child selector
setTimeout(function() {
$("div#__xmlview2--chartRadial1 > svg.sapSuiteRMC.sapSuiteRMCSizeResponsive.sapSuiteRMCNeutralTextColor :nth-child(6)").text(myVal + "%");
}, 500);
}
div#__xmlview2--chartRadial1>svg.sapSuiteRMC.sapSuiteRMCSizeResponsive.sapSuiteRMCNeutralTextColor :nth-child(6) {
font-family: fantasy !important;
}
div#__xmlview2--chartRadial2>svg.sapSuiteRMC.sapSuiteRMCSizeResponsive.sapSuiteRMCNeutralTextColor :nth-child(6) {
font-family: arial !important;
}
<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="sap.sample.Detail" xmlns:semantic="sap.m.semantic" xmlns:c="sap.suite.ui.microchart">
<content>
<Label text="6.25rem x 6.25rem" width="12.5rem" class="sapUiSmallMargin" />
<FlexBox width="6.25rem" height="6.25rem">
<items>
<c:RadialMicroChart id="chartRadial1" size="Responsive" percentage="99" press="press"></c:RadialMicroChart>
</items>
</FlexBox>
<FlexBox width="6.25rem" height="6.25rem">
<items>
<c:RadialMicroChart id="chartRadial2" size="Responsive" percentage="99" press="press"></c:RadialMicroChart>
</items>
</FlexBox>
</content>
</mvc:View>

Change icon color if condition

I am using a list that prints data from a model and one should have an icon. The thing is that the icon changes depending on the value and I should also change its color.
I have in my view :
<ObjectListItem title="State" type="Active" number="{/Data/8/state}"
icon="{= ${/Data/8/state}.toUpperCase() === 'OK' ? 'sap-icon://accept' :
'sap-icon://decline' }"></ObjectListItem>
Options like addStyleClass doesn't seem to work. I have changed the color by adding css to the id that SAP adds to the Icon, but since it has to change according to the value I don't know how to achieve it.
Another option was to add color directly to these two icons but I wasn't able to add the classes.
You can use CustomData and then create a css selector to match it:
<ObjectListItem title="State" type="Active" number="{/Data/8/state}"
icon="{= ${/Data/8/state}.toUpperCase() === 'OK' ? 'sap-icon://accept' :
'sap-icon://decline' }">
<customData>
<core:CustomData writeToDom="true" key="class" value="{= ${/Data/8/state}.toUpperCase()}" />
</customData>
</ObjectListItem>
This will render your control with an additional data-class attribute (actually, data-{key}, where key is the key that you defined on your core:CustomDatatag).
You can then match that with the CSS selector
[data-class='OK'] {
color: blue !important;
}
[data-class='NOT-OK']{
color: red !important;
}

How to create dynamic color for text field?

Background: Jaspersoft studio 6.2
How to change forecolor of a text field based on an expression.
How can I apply a expression so the font color (forecolor) will be based on the value in that field? I can't find anywhere to set a expression for the forecolor property.
Maybe there is an option:
You need to set markup to style.
And then use an expression in the text field:
F{value1}=="GREEN"?$F{value1}:"<style backcolor='red'>"+$F{value1}+"</style>"
You can also add conditions and set multiple colors:
F{value1}=="GREEN"?"<style backcolor='green'>"+$F{value1}+"</style>":"<style backcolor='red'>"+$F{value1}+"</style>"
Maybe this will work for you.
Another possibility would be to use a style property expression in your textfield:
<textField ...>
<reportElement ...>
<propertyExpression name="net.sf.jasperreports.style.forecolor">
<![CDATA["#00FF00"]]>
</propertyExpression>
</reportElement>
...
</textField>
This setting will override the current forecolor attribute for the textfield, and a green text will be printed out.
Here are listed all dynamic style properties available for report elements.
You use conditionalStyle, to achieve this
Example
<style name="myStyle" forecolor="#0000FF">
<conditionalStyle>
<conditionExpression><![CDATA[$F{myField}<0]]></conditionExpression>
<style forecolor="#CC0000"/>
</conditionalStyle>
</style>
Then set the style to the textField when you like to use it
<textField>
<reportElement style="myStyle" x="448" y="5" width="100" height="20" uuid="b75e4497-e952-4051-8640-2f6b498dd152"/>
<textFieldExpression><![CDATA["Hello world"]]></textFieldExpression>
</textField>
In JasperSoft Studio, right click on style in outline to create "Conditional Style" and set the properties in the properties tab

How to create an SVG "tooltip"-like box?

Given an existing valid SVG document, what's the best way to create "informational popups", so that when you hover or click on certain elements (let's say ) you popup a box with an arbitrary amount (i.e. not just a single line tooltip) of extra information?
This should display correctly at least in Firefox and be invisible if the image was rasterized to a bitmap format.
This question was asked in 2008. SVG has improved rapidly in the intervening four years. Now tooltips are fully supported in all platforms I'm aware of. Use a <title> tag (not an attribute) and you will get a native tooltip.
Here are the docs:
https://developer.mozilla.org/en-US/docs/SVG/Element/title
<svg>
<text id="thingyouhoverover" x="50" y="35" font-size="14">Mouse over me!</text>
<text id="thepopup" x="250" y="100" font-size="30" fill="black" visibility="hidden">Change me
<set attributeName="visibility" from="hidden" to="visible" begin="thingyouhoverover.mouseover" end="thingyouhoverover.mouseout"/>
</text>
</svg>
Further explanation can be found here.
Since the <set> element doesn't work with Firefox 3, I think you have to use ECMAScript.
If you add the following script element into your SVG:
<script type="text/ecmascript"> <![CDATA[
function init(evt) {
if ( window.svgDocument == null ) {
// Define SGV
svgDocument = evt.target.ownerDocument;
}
tooltip = svgDocument.getElementById('tooltip');
}
function ShowTooltip(evt) {
// Put tooltip in the right position, change the text and make it visible
tooltip.setAttributeNS(null,"x",evt.clientX+10);
tooltip.setAttributeNS(null,"y",evt.clientY+30);
tooltip.firstChild.data = evt.target.getAttributeNS(null,"mouseovertext");
tooltip.setAttributeNS(null,"visibility","visible");
}
function HideTooltip(evt) {
tooltip.setAttributeNS(null,"visibility","hidden");
}
]]></script>
You need to add onload="init(evt)" into the SVG element to call the init() function.
Then, to the end of the SVG, add the tooltip text:
<text id="tooltip" x="0" y="0" visibility="hidden">Tooltip</text>
Finally, to each of the element that you want to have the mouseover function add:
onmousemove="ShowTooltip(evt)"
onmouseout="HideTooltip(evt)"
mouseovertext="Whatever text you want to show"
I've written a more detailed explanation with improved functionality at http://www.petercollingridge.co.uk/interactive-svg-components/tooltip
I haven't yet included multi-line tooltips, which would require multiple <tspan> elements and manual word wrapping.
This should work:
nodeEnter.append("svg:element")
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; })
.append("svg:title")
.text(function(d) {return d.Name+"\n"+d.Age+"\n"+d.Dept;}); // It shows the tool tip box with item [Name,Age,Dept] and upend to the svg dynamicaly