GUIDE4YOU - layermenu extend with show/hide text features - openlayers-3

Is there a way to extend the layermenu?
For featurelayers users should be able to click on a image or button to show/hide the text of the features of that specific layer.
Showing or hiding the text of a feature is handled by the stylefunction on base of the current ''showfeaturetext'' property of the layer.
Is this possible with the current code?
Kind regards,
Sam

You could extend the layerselector if you are creating custom guide4you builds (see https://github.com/KlausBenndorf/guide4you#how-to-install-and-build-guide4you and https://github.com/KlausBenndorf/guide4you/wiki/How-to-create-an-own-guide4you-module) and overwrite the buildLayerButton method. Sadly the buildLayerButton does not return the button, which would make it a little more straightforward.
export class MyLayerSelector extends LayerSelector {
buildLayerButton (layer, $target) {
super.buildLayerButton(layer, $target)
$target.children(':last-child') // <- this should be your button as a jquery object
}
}

I've been trying this without success.
These are my steps:
I made a new file in the source dir: (.\src\controls\MyLayerSelector.js)
Content:
import $ from 'jquery'
import {LayerSelector} from './LayerSelector'
export class MyLayerSelector extends LayerSelector {
buildLayerButton (layer, $target) {
super.buildLayerButton(layer, $target)
$button = $target.children(':last-child') // <- this should be your button as a jquery object
}
}
Edit entry.js. I've added this line:
import { MyLayerSelector } from '../../src/Controls/MyLayerSelector'
Edit entry.js. I've also added this line:
window.createG4U = function (target, clientConf = defaultClientConf, layerConf = defaultLayerConf) {
return createG4UInternal(target, clientConf, layerConf, [
new MyLayerSelector()
])
}
NPM run build output:
warnings:
[ './src/Controls/Control.js\nThere is another module with an equal name when case is ignored.\nThis can lead to unexpected behavior when compiling on a filesystem with other case-semantic.\nRename module if multiple modules are expected or use equal casing if one module is expected.',
'./src/controls/Control.js\nThere is another module with an equal name when case is ignored.\nThis can lead to unexpected behavior when compiling on a filesystem with other case-semantic.\nRename module if multiple modules are expected or use equal casing if one module is expected.',
'./src/Controls/LayerSelector.js\nThere is another module with an equal name when case is ignored.\nThis can lead to unexpected behavior when compiling on a filesystem with other case-semantic.\nRename module if multiple modules are expected or use equal casing if one module is expected.',
'./src/controls/LayerSelector.js\nThere is another module with an equal name when case is ignored.\nThis can lead to unexpected behavior when compiling on a filesystem with other case-semantic.\nRename module if multiple modules are expected or use equal casing if one module is expected.',
'./src/Controls/ControlLogicMixin.js\nThere is another module with an equal name when case is ignored.\nThis can lead to unexpected behavior when compiling on a filesystem with other case-semantic.\nRename module if multiple modules are expected or use equal casing if one module is expected.',
'./src/controls/ControlLogicMixin.js\nThere is another module with an equal name when case is ignored.\nThis can lead to unexpected behavior when compiling on a filesystem with other case-semantic.\nRename module if multiple modules are expected or use equal casing if one module is expected.' ]
When I ignore these warnings I get a javascript error:
Uncaught TypeError: Cannot read property 'selectL10N' of undefined

Related

Strange compilation error with #testable import

I've just added some unit tests to a new project. Normally I use #testable import to import the production code, so I can test non-public methods:
#testable import My-Project
import XCTest
final class MyTests: XCTestCase {
func testOne() {
// ...
}
}
However I'm seeing some strange compilation errors, which I've never seen before:
Tests.swift:1:25: Consecutive statements on a line must be separated by ';'
Tests.swift:1:25: Expected expression after unary operator
Tests.swift:1:25: Expressions are not allowed at the top level
Tests.swift:1:18: No such module 'My'
I've checked and double checked everything and just cannot work out why this compilation error is produced.
What am I missing?
Project and target names can contain special characters (like spaces or dashes), but module names can not. By default, Xcode generates the module name from the target name by replacing invalid characters with an underscore.
Therefore, in your case
#testable import My_Project
would fix the issue. Alternatively, assign a custom “Product Module Name” in the build settings of the target.
There is no need to rename the entire project (or target).
The project name (and therefore internal module name) contains a dash (-) character.
To fix this:
Select the top level project file icon in the Xcode Project Navigator
Press enter to rename the project
Remove the dash from the project name
Follow prompts to do the final refactoring
Update your #testable import ... statement to reflect the new module nam.

Unhandled exception: type 'A' is not a subtype of type 'A' of 'x' where A is from

I get a runtime error that reads something like this:
Unhandled exception:
type 'A' is not a subtype of type 'A' of 'x' where
A is from file:///path/to/source/a.dart
A is from package:my_package/a.dart
A is the exact same type as the other A -- there is no naming conflict.
The two indented lines ('A is from ...') only differ in their way of specifying the path. One goes through 'package:' and the second one is the file path on the file system.
TL;DR:
Use import 'package:...' everywhere, even when importing files from your own package.
Explanation:
The two URLs (file:///... and package:...) are equivalent but Dart has no way of knowing that. When you import source via both relative path and via the package: scheme, you'll get this error.
To fix this issue, make sure to be consistent in how you import files in your own package.
Wrong:
In file foo.dart:
import '../path/to/a.dart';
In file bar.dart:
import 'package:my_package/a.dart';
This results in an error.
Correct:
In file foo.dart:
import 'package:my_package/a.dart';
In file bar.dart:
import 'package:my_package/a.dart';
This will be fine.

excel xlwings_udfs module is empty

Using xlwings 0.7.1 UDF on Windows in 64-bit virtual env python 2.7.6.
I see now that instead of requiring full path to module, it takes module names. However it fails silently to import any UDFs when the module name has package name prefixed. Eg:
PYTHONPATH = ThisWorkbook.Path & ";C:\pathTo\Pydev\myproj\src"
UDF_MODULES = "pkg.myudfs"
If I move the package name 'pkg' from UDF_MODULES to PYTHONPATH, then it fails at imports inside myudfs.py (like 'import pkg.module2').
After hit & trial, I fixed it by adding multiple source folders:
PYTHONPATH = ThisWorkbook.Path & ";C:\pathTo\Pydev\myproj\src\pkg;C:\pathTo\Pydev\myproj\src"
Am I expected to do this? Can't I just point UDF_MODULES to base src folder and provide qualified module name like 'pgk.myudfs'?
You're actually doing it right for right now (v0.7.1). I have, however, opened an issue on GitHub so we might make this easier in a future release.

How to include non-api methods in custom build in ol3?

I need to use a method that is not marked as #api in OpenLayers 3, i.e. it is not exported in the default minimized build that comes with releases of OpenLayers 3. The method in question is: getTileCoordExtent, of the ol.tilegrid.TileGrid class.
I tried to add "ol.tilegrid.TileGrid#getTileCoordExtent" in the build json configuration, as suggested in the configuration documentation, but I got the following error:
ERR! No matching symbol found: ol.tilegrid.TileGrid#getTileCoordExtent
Does that mean that methods that are not marked as #api can't be exported ? Is there a way to accomplish what I'm trying to do other than editing the code and add the #api myself ?
To borrow Andreas Hocevar's response:
The exports are determined by tasks/generate-exports.js reading symbols from build/info,json. If you want custom symbols, you can add them to the symbols object in info.json, e.g.
{
"symbols": [
{
"name": "ol.tilegrid.TileGrid#getTileCoordExtent",
}
]
}
Of course you should not be doing that, unless you are aware that you have no guarantee that what you add this way will be stable.
Original answer: https://groups.google.com/forum/#!msg/ol3-dev/HwWRoJF0eRU/MYvEa6-aAwAJ

Dart library and parts are not bi-directionally resolved

I have a library, 'foo', which consists of a part, 'bar', and imports the dart:io library. The library and the part are declared as follows, in 'foo.dart':
// in foo.dart
library foo;
import 'dart:io';
part "bar.dart"; // resolves
class Foo {
Bar bar = new Bar(); // resolves
HttpServer server = new HttpServer(); // resolves
}
'foo.dart' and 'bar.dart' are located in the same directory.
'bar.dart' refers back to library foo, like so:
// in bar.dart
part of foo; // does not resolve
class Bar {
Foo foo = new Foo(); // does not resolve
HttpServer server = new HttpServer // does not resolve
}
But in Dart Editor, I see a warning in 'bar.dart', saying 'Cannot resolve foo'. Accordingly, any imports (such as 'dart:io') I declare in foo.dart are not available to bar.dart, nor are any of my foo.dart definitions, and since bar.dart is a part of foo, it is not permitted to import any further libraries or declare any further parts.
I would like to organize my code in such a way that:
* any imports I bring into foo.dart to be available to bar.dart (and other source parts)
* library definitions made in one library source part are available to other library source parts.
* (obviously) library definitions made in bar.dart are available to foo.dart (this already works as expected)
Can someone please help me understand how to accomplish these?
I think this is just a bug in the Editor. Have you tried running your program? It should work.
The Editor still gets stuck warnings sometimes, and closing the file or closing the Editor for really stuck ones, usually clears it up. I'll see if I find the bug report so you can star it or maybe add a log file if it keeps happening to you.

Resources