How to specify the size Yandex maps? - yandex-maps

The problem with the options property.panelMaxMapArea
https://tech.yandex.ru/maps/doc/jsapi/2.1/ref/reference/Balloon-docpage/#param-options.panelMaxMapArea
How do I specify the size of the map, so the balloon in the form of a panel was only if the map width is less than 480px?

Seems, documentation contains inaccuracy description, just use setter for options properties, something like this:
balloon.options.set('panelMaxMapArea', 480);
balloon.options.set('closeButton', false);
// and etc...

Related

standardize Vaadin form widths in Vaadin 14 Java API

I notice that when I use LoginForm it has a default size. I can't quite figure out how it gets this size. I would like to standardize the sizes of all my forms, e.g. FormLayout and LoginForm. I do not mind making my FormLayouts match the size of the LoginForm -or- set the LoginForm and FormLayouts to my own preset size. The problem is that when I set the LoginForm's width as a percentage, it never seems to match the same size as the FormLayouts... the LoginForm always comes out smaller for the same percentage.
Is there any way to set my LoginForms and FormLayouts to have the same width consistently?
Currently, there does not seem to be a way how to get the fields from a LoginForm with the Java API. There is a GitHub issue for a similar issue.
As described in the issue, you could execute JavaScript to get the relevant element. Then, you could modify its CSS manually. To set the width of a LoginForm, you could use vaadin-login-form-wrapper.
UI.getCurrent().getPage().executeJavaScript("document.getElementsByTagName('vaadin-login-form-wrapper')[0].style.width = '200px';");
Alternatively, you could use raw CSS and change the attributes of this element.
After investigating the CSS, you could find out that the width of the form is defined by the CSS variable --lumo-size-m. The max-width of the vaadin-login-form-wraper is defined by calc(var(--lumo-size-m) * 10). Therefore, you could also change the theme or just get the width from there and use it for your FormLayouts.

Only print ol.style.Text to polygon if text label fits inside its geometry

In OpenLayers I use ol.style.Text to add a text label to federal states polygons. The states have names of different length and also polygons of different sizes. It looks like this:
Is it possible to only print the text marker if it fits inside its polygon (e.g. after zooming in)? For instance, in the above example Hessen, Thüringen, Sachsen and Bayern would be printed, but Rheinland-Pfalz, Saarland and Baden-Württemberg would be omitted because the text goes beyond its feature's geometry...
I know I can set the font property of an ol.style.Text to a particular size based on the resolution but this does not help here as text would still overlap the borders sometimes...
This is currently not possible with help from the library. But you can use CanvasRenderingContext2D#measureText() in your vector layer's stlyeFunction to get the width of the label, and compare that with the extent's width of the polygon at a certain resolution, and decide based on that whether to render or not. You can also get smarter than using the extent's width, but it is probably a good enough approximation for many cases.

Get KML style in OpenLayers 3

I need access to extracted style attributes (e.g. fill color, stroke color, etc.) for a KML file once loaded. I can't seem to find a way to access the style once the layer has been added. The myLayer.getStyle() returns a function as expected but how does one access the style attributes?
You get the styles by calling the function.
As the docs say, you should pass an ol.Feature object and a resolution value.
But it seems to return something also when you leave the parameters undefined.
var styleFn = myLayer.getStyle();
console.log(styleFn());

How to layout fields correctly

I've been trying to layout fields in blackberry and when I think I have it working I try another simulator and my field's are laid out differently.
If I call setPositionChild(field, 0, 100); I would expect on all phone resolutions that
the fields would be positioned at position x=0, y=100. This is not the case.
Reading the RIM doc for setPositionChild, the y parameter is - "y - Offset of the top of the field in its manager." The y offset returned by field.getTop is consistently 0, so position should be consistent across screens? Maybe a good explanation of how setpositionChild works would suffice.
Thank you.
I suspect your variable results are from extending MainScreen. That class contains separators etc that will be offsetting your 0,100 to something else.
Either try using FullScreen which is a single VerticalFieldManager
Or override sublayout on your MainScreen and set its width and height to the full size of the display.

BCB: how to get the (approximate) width of a character in a given TFont?

It's a TMemo, not that that should make any difference.
Googling suggests that I can use Canvas->TextWidth() but those are Delphi examples and BCB doesn't seem to offer this property.
I really want something analogous to memo->Font->Height for width.
I realize that not all fonts are fixed width, so a good estimate will do.
All that I need is to take the width of a TMemo in pixels and make a reasonable guess at how many characters of the current font it will hold.
Of course, if I really want to be lazy, I can just google for the average height/width ratio, since height is known. Remember, an approximation is good enough for me if it is tricky to get exact.
http://www.plainlanguagenetwork.org/type/utbo211.htm says, " A width to height ratio of 3:5 (0.6) is recommended for most applications"
Actually your google search is not entirely off. You do need access to a canvas object, or at least a handle to a DC object. In general when searching for help concerning VCL classes it often pays to search for delphi examples since these are more common.
Anyway to calculate the size of a string you could have a look at the TextExtent function, it is a function for the TCanvas class. Simply pass the character which width you want to test, and the return value will be a TSize construct. However there is also a TextWidth function, as well as a TextHeight function. You can use these as well. Actually these call the TextExtent internally.
You have to note one thing though, the functions use the current font of the TCanvas object, more specifically the font bound to the DC the canvas uses. So assign the font you wish to test with first, and then pass the character.
I have some old code that calculates the width of a string like this:
// This canvas could be the form canvas: canvas = Form1->Canvas or the
// memo canvas which will probably be what you want.
canvas->Font->Assign(fontToTest);
int textwidth = TextWidth(textToTest);
If you want more control of what to do, you can also do this using the Windows API, this is essentially what the VCL does for you, in that case the following example would look like this:
// This canvas could be the form canvas: canvas = Form1->Canvas
canvas->Font->Assign(fontToTest);
// The initial size, this is really important if we use wordwrapping. This is
// the text area of the memo control.
TRect rect = ClientRect;
// This is the font format we wish to calculate using, in this example our text
// will be left aligned, at the top of the rectangle.
fontformat = DT_LEFT | DT_TOP;
// Here we calculate the size of the text, both width and height are calculated
// and stored in the rect variable. Also note that we add the DT_CALCRECT to the
// fontformat variable, this makes DrawTextEx calculate the size of the text,
// without drawing it.
::DrawTextEx(canvas->handle,
textToTest.c_str(),
textToTest.Length(),
&rect,
fontformat | DT_CALCRECT,
NULL);
// The width is:
int width = rect.Width();
The fontformat is a parameter that specifies different options for how to align and layout the text, if you plan on drawing text it will be a good idea to check out the different possibilities it offers: DrawTextEx Function [1]
EDIT: Reading through your question again, it struck me that the function you might be searching for is: GetTextExtentExPoint Windows API documentation states the following about this function:
The GetTextExtentExPoint function
retrieves the number of characters in
a specified string that will fit
within a specified space and fills an
array with the text extent for each of
those characters. (A text extent is
the distance between the beginning of
the space and a character that will
fit in the space.) This information is
useful for word-wrapping calculations.
You can find more information about the GetTextExtentExPoint function here: GetTextExtentExPoint Function [2]
[1] http://msdn.microsoft.com/en-us/library/dd162499%28VS.85%29.aspx
[2] http://msdn.microsoft.com/en-us/library/dd144935%28VS.85%29.aspx
What you could do, if you have access to Win32 API functions, is create a RichEdit Window the same size as your TMemo window, place the text in the RichEdit window, send the EM_FORMATRANGE message to the window and from the result determine how many characters it will hold. Of course this method will work with multiple lines etc...

Resources