What are the functions that can use with feature.getStyle() function in Openlayers 3? - kml

I have used the following code to read the KML file. How to get the Styles which extracted from the kml file. Am i using the getStyle() function properly?
var parser = new ol.format.KML({extractStyles: true});
var testfeat=parser.readFeatures(kmlAsString,{featureProjection:'EPSG:3857' });
for(i=0;i<testfeat.length;i++)
{
console.log(testfeat[i].getStyle()); // What are the functions that use with getStyle()?
}

OpenLayers' ol.format.KML reads the style definitions within the KML file and stores them internally. When setting the style to a feature, the format object does it using a style function, i.e. ol.FeatureStyleFunction, see: http://openlayers.org/en/latest/apidoc/ol.html#.FeatureStyleFunction
It does so here, using the feature setStyle method: https://github.com/openlayers/ol3/blob/v3.20.0/src/ol/format/kml.js#L1852
I style function can't return properties like a normal ol.style.Style object can. It relies on the map resolution to calculate properties on the fly that can change.
In summary: you can't access to the style definitions from those read out of a KML file using the ol.format.KML.

Related

How to set a List value with JScript

In FileNet, using FEM or ACCE, it is possible to use JScript in order to set attributes' values to an object. The official IBM guide provides this example (for Strings):
importClass(Packages.com.filenet.api.property.Properties);
importClass(Packages.com.filenet.api.constants.RefreshMode);
function OnCustomProcess (CEObject)
{
CEObject.refresh();
CEObject.getProperties().putValue("DocumentTitle", "Test1");
CEObject.save(RefreshMode.REFRESH);
}
But is it possible to do the same thing for more complex objects? I'm referring, in particular, to StringList type. There are no examples on the web, and defining a JS-like array doesn't work.
It is definitely possible to do this for more complex objects. Most of it is just following the path you would follow using Java, but changing the name of the variable types to var. Therefore the code for setting the value of a multivalue string property is as follows:
importClass(Packages.com.filenet.api.constants.RefreshMode);
importClass(Packages.com.filenet.api.core.Factory);
function OnCustomProcess (CEObject)
{
CEObject.refresh();
var list = Factory.StringList.createList();
list.add("Value 1");
list.add("Value 2");
CEObject.getProperties().putObjectValue("TestMultiValueProperty1", list);
CEObject.save(RefreshMode.REFRESH);
}
I often use the putObjectValue() method instead of the putValue() method because JavaScript sometimes has problems determining which type safe version of the putValue() it should use.
For a lot of examples you could go to the Global Configuration > Data Design > Add-ons section in the domain tab of the ACCE. The pre- and post-import scripts of the different Add-ons contain a lot of relevant JavaScript code.

Using Custom Functions with "I" in Page Object and Custom Helper in CodeceptJS

Hi CodeceptJS Community,
Is there a way to use custom defined functions (under steps_file.js) as I. customFunction() in page object files.
Is there a way to use native codeceptjs functions (like I.click()) in my custom helper files
I couldn't find any help in the documentation and in other sources. Is there any way to achieve this?
And is there any way to use xpath locators in puppeteer helper?
this.helpers['Puppeteer'].page.click(xpath);
I had the same problem to use custom steps in pageObjects.
To avoid it, i passed the actor (I) as parameter to my pageObject function.
page object:
const I = actor();
module.exports = {
doSomething(I){
I.login();
}
};
Test scenario:
Scenario('Test something' (I,pageObject)=>{
pageObject.doSomething(I)
})
In this case, pageObjects will has access to all custom steps from I :)
Thank you for your sharing Matheus. I have used a different solution. Instead of writing "I" object in every page object method (which was also one option for me), I have created a custom helper file and written all methods using puppeteer helper like below;
async method() {
await this.helpers['Puppeteer'].click(xpath);
}
I can call this method both in tests and page objects
I.method();
I was facing the same issue and when I looked into the typescripts definitions I noticed that actor() which is required in every page object etc. has custom steps arguments.
So this worked for me to extend the const I = actor(); witht the custom steps form steps_file.js;
const customSteps = require('./steps_file');
const I = actor(customSteps());
After that, I can use all methods in page objects like in tests scenarios which are accessing the methods from steps_file.js

handlebars get server data for helper functions

I am setting-up the server response of a query to couchbase and want to use handlerbars to render the response data.
I understand that the best practice is to have my helper functions into a separate file and not be embedded in a script tag in my html file.
My question is what is the best practice or technique to pass the data from the server response to my hanldbars helper file to then be manipulated?
I am using hapijs on the server and jQuery on the client.
Well I might be wrong, but following this example I found, it seems like you export the helper file like you would any other module with the module.exports
http://codyrushing.com/using-handlebars-helpers-on-both-client-and-server/
According to the API documentation for hapi the helper file must export a single method with the signature `function(context).
Helpers are functions used within templates to perform transformations
and other data manipulations using the template context or other
inputs. Each '.js' file in the helpers directory is loaded and the
file name is used as the helper name. The files must export a single
method with the signature function(context) and return a string.
Sub-folders are not supported and are ignored. Defaults to no helpers
support (empty path). Note that jade does not support loading helpers
this way.
https://github.com/hapijs/hapi/blob/master/docs/Reference.md#route-options

How to access values from alfresco-global.properties in freemarker and YUI javascript files

I have numerous custom variables in Alfresco's alfresco-global.properties file that I'd like to use throughout various freemarker ftl files as well as the various YUI files, which will greatly alter the behavior of Share and how it displays information.
I have the property values accessible through various javascript calls (for example, getNetworkName() will return the custom app.network.name variable set in the properties), but I am uncertain of how I'd expose these javascript functions to either freemarker or the YUI files, or if I even need to, as opposed to just accessing the variables directly.
If you have defined global variables and functions you don't need to do anything special to access them from YUI.
You can optionally do something like this to take advantage of YUI's sandboxing ability so that each sandbox can't affect the other by changing the global configuration:
YUI_config = {
app: {
network: {
name: 'foo' // or getNetworkName()
}
}
};
YUI().use('node', function (Y) {
console.log(Y.config.app.network.name); // foo
Y.config.app.network.name = 'bar';
});
YUI().use('tabview', function (Y) {
console.log(Y.config.app.network.name); // still foo!
});

How to create control at runtime using app.config?

I would like to create simple objects at runtime (textbox, label, etc) and add them to a Grid in my WPF application. My problem is that I need to define these in the app.config file. I am reading in the config data by using the “ConfigurationManager.GetSection” method. Shown below is an example of the XML that defines two textboxes. The Key values are always defined as Labels so the following defines two labels called “ID:” and “Name:” and two associated TextBoxes
<HardwareControls>
<add key="ID:" value="System.Windows.Controls.TextBox"/>
<add key="Name:" value="System.Windows.Controls.TextBox"/>
</HardwareControls>
At the moment I use the following code to create a TextBox object but need to modify it so that the control types are defined by the config data and not hardcoded. Can anyone help in how I would go about doing this based on me knowing the control type as defined by a string?
TextBox tb1 = new TextBox();
tb1.Width = 100;
tb1.SetValue(Grid.ColumnProperty, 1);
tb1.SetValue(Grid.RowProperty, i);
I can also see a situation where I may want to define additional values such as the textbox width in the config file. Is there a better solution to store this in the app.config as it looks like the “GetSection” method only supports a key/value pair (I may be rog in that assumption as I haven’t read too much about this yet).
You can use Activator.CreateInstance
Example:
string typeName = "System.Windows.Controls.TextBox";
Type type = Type.GetType(typeName);
object control = Activator.CreateInstance(type); // control is your TextBox
You can use Reflection to create a type from a string name - e.g.
http://en.csharp-online.net/CSharp_FAQ:_How_create_an_instance_of_a_type_using_only_its_name
or
How can I pass an argument to a C# plug-in being loaded through Assembly.CreateInstance?

Resources