当我尝试导出使用 OpenLayer 创建的多层地图时遇到问题。
这是我的JS代码:
map.once('postcompose', function(event) {
var img = new Image,
canvas = event.context.canvas;
img.crossOrigin = "anonymous";
img.src = canvas.toDataURL('image/png');
});
Run Code Online (Sandbox Code Playgroud)
其中map是我的 OpenLayers 地图的 JavaScript 变量。
当地图由多个级别组成时,我收到此类错误:
未捕获的安全错误:无法在“HTMLCanvasElement”上执行“toDataURL”:受污染的画布可能无法导出
如果尝试在不向地图添加级别的情况下执行相同的操作(仅使用默认的 OpenLayer 地图),我可以生成数据 URL 并以 png 格式下载地图。
这似乎是 CrossOrigin 问题,但应该在我的服务器上启用 COR。
有什么帮助吗?谢谢!
编辑
这里是 JS 代码示例,我将图层添加到导致此问题的地图。
var layer = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://pubblicazioni.provincia.fi.it/geoserver/wms',
params: {
'LAYERS': 'layer_name',
'FORMAT': 'image/png',
'TRANSPARENT': 'true'
},
crossOrigin: null
})
});
map.addLayer(layer);
Run Code Online (Sandbox Code Playgroud) 我使用libwebsocket在C ++中实现了一个websocket客户端。
我想发送大消息,但我将消息有效负载限制为8K,我需要使用该有效负载值。
这是我的初始化代码的片段:
void
WSManager::initProtocols(void)
{
memset(protocols, 0, sizeof(protocols));
protocols[0].name = "default";
protocols[0].callback = callback;
protocols[0].per_session_data_size = 1500;
protocols[0].rx_buffer_size = 8000;
/* End of the list */
protocols[1].name = NULL;
protocols[1].callback = NULL;
protocols[1].per_session_data_size = 0;
protocols[1].rx_buffer_size = 0;
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是如何发送大于8K的消息。
有没有一种方法可以缓冲数据,或者我必须使用fraggle?
我在Ubuntu 11.10上编译我的C++和OpenSSL项目时遇到了严重的问题.编译命令是:
g++ -Wall -lssl -lm -lcrypto -I ./src ./src/server.cpp -o ./bin/server
Run Code Online (Sandbox Code Playgroud)
我收到这些错误:
server.cpp:(.text+0x8ff): undefined reference to `RSA_new'
server.cpp:(.text+0x92d): undefined reference to `PEM_read_RSAPrivateKey'
server.cpp:(.text+0xa85): undefined reference to `RSA_size'
server.cpp:(.text+0xaa1): undefined reference to `RSA_size'
server.cpp:(.text+0xae7): undefined reference to `RSA_private_decrypt'
server.cpp:(.text+0xd84): undefined reference to `BF_set_key'
server.cpp:(.text+0xf1d): undefined reference to `BF_ecb_encrypt'
server.cpp:(.text+0x13c6): undefined reference to `BF_ecb_encrypt'
collect2: ld returned 1 exit status
make: *** [server] Error 1
Run Code Online (Sandbox Code Playgroud)
我成功安装了openssl和libssl-dev,但问题仍然存在.我尝试使用内核3.0在Linux Mint 12上编译项目,我遇到了同样的问题.在我使用内核2.6的旧Linux操作系统上,项目编译并运行良好(使用相同的Makefile和相同的源代码).请帮我!
我正在尝试使用django-cors-headers将COR添加到我的服务器,但是当我加载页面时,我在服务器上收到此错误.
ImproperlyConfigured: Error importing module corsheaders.middleware.CorsMiddlewaredjango.middleware.common: "No module named CorsMiddlewaredjango.middleware.common"
Run Code Online (Sandbox Code Playgroud)
我已经使用pip安装了cors-header app:
pip install django-cors-headers
Run Code Online (Sandbox Code Playgroud)
我的settings.py文件以这种方式配置:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'social.apps.django_app.default',
'corsheaders',
'dashboard',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware'
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
CORS_ORIGIN_ALLOW_ALL = True
Run Code Online (Sandbox Code Playgroud)
我正在使用python 2.7版本.
我正在尝试自定义我的AppCompat主题(Base.Theme.AppCompat.Light.DarkActionBar)来更改搜索建议背景颜色和文本.
这是我的样式文件:
<resources>
<!-- extend one of the Theme.AppCompat themes -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- customize the color palette -->
<item name="colorPrimary">@color/material_blue_500</item>
<item name="colorPrimaryDark">@color/material_blue_700</item>
<item name="colorAccent">@color/material_blue_200</item>
<item name="android:windowBackground">@color/material_blue_200</item>
<item name="android:actionBarStyle">@style/ActionBar</item>
<item name="android:actionBarWidgetTheme">@style/ActionBarWidget</item>
</style>
<!-- Actionbar Theme -->
<style name="ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/material_blue_200</item>
<item name="android:icon">@drawable/ic_launcher</item>
</style>
<style name="ActionBarWidget" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- SearchView customization-->
<item name="searchViewSearchIcon">@drawable/ic_action_search</item>
<item name="searchViewCloseIcon">@drawable/ic_action_remove</item>
<item name="searchViewTextField">@drawable/ab_textfield_searchview</item>
<item name="searchViewAutoCompleteTextView">@style/AutoCompleteTextView</item>
</style>
<style name="AutoCompleteTextView" parent="Widget.AppCompat.Light.AutoCompleteTextView">
<item name="android:textColor">@android:color/white</item>
<item name="android:textCursorDrawable">@null</item>
<item name="android:textColorHighlight">@color/material_blue_200</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
编译后,我收到这种错误:
错误:(24,21)找不到匹配给定名称的资源:attr'searchViewAutoCompleteTextView'.
错误:(22,21)找不到与给定名称匹配的资源:attr'searchViewCloseIcon'.
错误:(21,21)找不到与给定名称匹配的资源:attr'searchViewSearchIcon'.
错误:(23,21)找不到与给定名称匹配的资源:attr'searchViewTextField'.
有什么建议吗?
c++ ×2
android ×1
background ×1
canvas ×1
cors ×1
dictionary ×1
django ×1
g++ ×1
javascript ×1
linux ×1
middleware ×1
openlayers-3 ×1
openssl ×1
pip ×1
search ×1
themes ×1
wms ×1