custom build with pointerEvent - openlayers-3

I can not find where to export "pointerEvent" for my custom build. I am checking the "shiftKey" status of the pointerEvent in two places.
on a singleclick event:
evt.pointerEvent.shiftKey
on a boxend event:
evt.mapBrowserEvent.pointerEvent.shiftKey
I can't seem to figure out what I need in my build config.json file. I've tried various combinations of "ol.interaction.*" and "ol.events.*" without sucess. I've grep'd the source for occurrences of "pointerEvent" and "mapBrowserEvent.pointerEvent" and tried to reference those in my exports but I'm pretty much guessing at this point.
Thanks

Probably not a great answer because I don't understand the "why", but for the record - I'm checking the shiftKey status after a singleClick event. With a debug build of ol3 the following code works:
myVar = evt.pointerEvent.shiftKey; // only works with a debug build
But fails with a non-debug ol3 build. The version below works with non-debug builds:
myVar = ol.events.condition.shiftKeyOnly(evt);
to check the shiftKey status after a boxend event add the mapBrowserEvent property of the event object:
myVar = ol.events.condition.shiftKeyOnly(evt.mapBrowserEvent);
When I say a "non-debug" ol3 build above I'm referring to "compilation_level" directive being set to "ADVANCED".

UPDATE:
Some tests:
custom-build.json and fiddle with this custom build (86KB).
{
"exports": [
"ol.Map",
"ol.Map#on",
"ol.Map#addInteraction",
"ol.layer.Tile",
"ol.source.OSM",
"ol.interaction.DragBox",
"ol.interaction.DragBox#on",
"ol.events.condition.shiftKeyOnly",
"ol.View"
],
"compile": {
"externs": [
"externs/closure-compiler.js",
"externs/oli.js",
"externs/olx.js",
"externs/proj4js.js"
],
"define": [
"ol.ENABLE_DOM=false",
"ol.ENABLE_WEBGL=false",
"ol.ENABLE_PROJ4JS=false",
"ol.ENABLE_VECTOR=false",
"goog.array.ASSUME_NATIVE_FUNCTIONS=true",
"goog.DEBUG=false"
],
"extra_annotation_name": [
"api", "observable"
],
"compilation_level": "ADVANCED",
"manage_closure_dependencies": true
}
}
There's nothing special you should put in you config.json.
Add to your exports array:
"exports": [
...
"ol.events.condition.shiftKeyOnly"
]
Try this after build:
map.on('singleclick', function(evt){
console.info(ol.events.condition.shiftKeyOnly(evt));
});

Related

VSCode run formatter on save without needing to save twice

I have a command that runs on save and formats the file, obviously then the file changes and needs to be saved again. Is there a way to make it so I don't need to hit save twice?
"runItOn": {
"commands": [
{
"match": ".rb",
"isShellCommand": false,
"cmd": "extension.rubyReplace"
}
]
}
Enter shortcut keys"ctrl+shift+P",open the file "setting.json",
add the following lines to this file:
"editor.formatOnType": true,
"editor.formatOnSave": true,
This will format the code on save.

gyp — how to set FRAMEWORK_SEARCH_PATH?

How do I set FRAMEWORK_SEARCH_PATH with gyp?
If I do
"libraries": [ "foo.framework", ],
that field is left blank and Xcode can't find header files.
After checking tests I found proper way:
"xcode_settings": {
'FRAMEWORK_SEARCH_PATHS': [
'/foo/',
],
},

When creating a custom build for OpenLayers3 some methods are obfuscated

When creating an OL3 build based on https://github.com/openlayers/ol3/blob/master/config/ol.json
I am able to access the ol.Map#renderSync prototype method. However, if I use the following custom "exports": [...] array (to trim library size), #renderSync is obfuscated (or perhaps removed):
[
"ol.Map",
"ol.View",
"ol.control.*",
"ol.interaction.*",
"ol.style.*",
"ol.layer.Tile",
"ol.layer.Group",
"ol.source.XYZ",
"ol.layer.Layer",
"ol.layer.Vector",
"ol.format.GeoJSON",
"ol.source.Vector",
"ol.Overlay",
"ol.has.*",
"ol.events.condition.*",
"ol.inherits"
]
How can I export a custom, trimmed down, build without losing access to ol.Map#renderSync while (ideally) retaining closure ADVANCED optimization?
Any ol.Map method you want to use, add it to exports section:
"exports": [
"ol.Map",
"ol.Map#updateSize",
"ol.Map#renderSync",
"ol.View",
"ol.View#*",
...
]
Or use an asterisk to export all methods:
"exports": [
"ol.Map",
"ol.Map#*",
...
]

Dust.js - iterate through an iterated anonymous array

I have this data structure in dust:
{ 'items' : [
[ 'apples', "$1.00" , "Delicious" ],
[ 'oranges', "$2.00" , "Juicy" ],
]
}
I'm trying to access the inner items, and can't figure out how.
I can address the entire array of the current loop via {.} , but i can't seem to access the items within it. ( I could do this in Mustache )
I was expecting something like this to work...
{#items}
<b>{.[0]}</b> <em>only {.[1]}!</em>
<p>{.[2]}</p>
{/items}
When I ran your example in the dust playground: http://linkedin.github.io/dustjs/test/test.html
the output I got was:
<b>apples</b> <em>only $1.00!</em><p>Delicious</p><b>oranges</b> <em>only $2.00!</em><p>Juicy</p>
This looks to be what you were expecting. I believe fixes in this area after your post likely made this work. Grab the latest version of dust.

Sublime Text 2 - key binding to change syntax

I want to make a new key binding to change syntax to, let's say, HTML or CSS. I searched the official and unofficial documentation to see if there are any answers to my problem.
Use the following key combination to pull up the command palette:
Ctrl+Shift+P
then type:
sshtml (for example, to set the syntax to HTML)
This is how i roll, if that's what you meant exaclty:
// Syntax Change
{"keys": ["alt+shift+h"], "command": "set_file_type",
"args": {"syntax": "Packages/HTML/HTML.tmLanguage"}
},
{"keys": ["alt+shift+m"], "command": "set_file_type",
"args": {"syntax": "Packages/Markdown/Markdown.tmLanguage"}
},
{"keys": ["alt+shift+p"], "command": "set_file_type",
"args": {"syntax": "Packages/PHP/PHP.tmLanguage"}
},
{"keys": ["alt+shift+j"], "command": "set_file_type",
"args": {"syntax": "Packages/Javascript/JSON.tmLanguage"}
},
There is an easy way to do that.
On the right bottom, there is a button, click on that button you will get all the available syntax.
You can use the Command Pallet (ctrl + shift + p) to change the Syntax, but sometimes using "ss" or "sshtml" brings up other commands that are un-related to the "Set Syntax" options.
You can also add a new Key Binding User Preference that brings up the Command Pallet with the text "Set Syntax: " already in it. Then you just have to type the language you want to set it to.
To setup this key-binding shortcut:
Open the Command Pallet (ctrl + shift + p)
Find and select the "Preferences: Key Bindings" option
Update your User ".sublime-keymap" file to have the "keys" json-object listed in the array:
[
"// additonal/exsiting key comands go here...",
{ "keys": ["ctrl+alt+l"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Set Syntax: "} }
]
Now you can use ctrl+alt+l to bring up the command prompt. Then just type HTML, CSS, or whatever language you're looking to switch too.
Feel free to change the "keys" combination from ctrl+alt+l to anything else you want the shortcut to be too.
dzhi's answer doesnt work anymore for JSON in Sublime 4.
The correct path is
Packages/JSON/JSON.tmLanguage

Resources