小编Hel*_*rns的帖子

Openlayers 3:为功能添加文本标签

我在这里设置了当前设置:功能齐全的小提琴示例,虽然我已设法缩放到每个多边形功能,但我还想在每个...上显示集中文本标签... field_titleget_fields方法中找到的变量.我不知道如何做到这一点,我的所有谷歌搜索都提出了这篇文章:http://openlayers.org/en/v3.3.0/examples/vector-labels.html我发现这完全令人困惑,因为我是一个OL的新鲜事!

javascript openlayers-3

8
推荐指数
1
解决办法
1万
查看次数

Openlayers 3具有相对于特征尺寸的标签位置?

我在OL地图上有几个图层,其中包含相同大小的要素的轮廓,背景颜色和标签,因此您可以显示或隐藏一个或多个图层.其中两个层只是标签......样式不包含填充或描边.一个标签应位于要素中心的另一个上方,但OL似乎相对于要素多边形的高度将它们垂直地远离或更靠近地展开,如下所示:

在此输入图像描述

我尝试offsetY: 15在下标签的文本样式块中设置一个,在下标签之前添加换行符textBaseline:'top',在下标签和textBaseline:'bottom'顶部设置换行(这是最后一次尝试!)但它们总是以不同的方式展开!

这是我的上标签的样式块:

    function fields_label_style() {
        return [
            new ol.style.Style({
                    fill: new ol.style.Fill({
                        color: 'rgba(255,255,255,0)'
                    }),
                    stroke: new ol.style.Stroke({
                        color: 'rgba(255,255,255,0)',
                        width: 1
                    }),
                    text: new ol.style.Text({
                        font: '13px Calibri,sans-serif',
                        fill: new ol.style.Fill({ color: '#ffffff' }),
                        stroke: new ol.style.Stroke({
                            color: '#000000', width: 2
                        }),
                        // get the text from the feature - `this` is ol.Feature
                        // and show only under certain resolution
                        text: map.getView().getZoom() > 14 ? this.get('description') : ''
                    })
                })
        ]; …
Run Code Online (Sandbox Code Playgroud)

openlayers-3

7
推荐指数
1
解决办法
1391
查看次数

Openlayers 3:动画点功能

我在这里设置了当前的设置:功能齐全的小提琴示例,我需要为点功能设置动画...使其像 Google 上的 GPS 位置一样脉动等。我找到了这篇文章:http ://openlayers.org/en/ master/examples/feature-animation.html但发现它真的很混乱并且不知道如何将其应用到我的代码中。

这是创建点特征并将其应用到地图的小提琴部分......

function locate_me() {
    var locationPoint = new ol.Feature({
        geometry: new ol.geom.Point([0.3901863098144531, 52.803332200169166])
    });
    locationPoint.getGeometry().transform('EPSG:4326', 'EPSG:3857');

    // A vector layer to hold the location point
    var locationLayer = new ol.layer.Vector({
        source: new ol.source.Vector({
            features: [
                locationPoint
            ]
        })
    });
    map.addLayer(locationLayer);
}
Run Code Online (Sandbox Code Playgroud)

javascript openlayers-3

5
推荐指数
1
解决办法
4638
查看次数

从"打开图层Bing地图"中删除默认控件

我正在构建一个使用Geolocation的应用程序,使用Open Layers加载Bing Map Layer.我想仅通过触摸来控制缩放,因此想要删除默认的缩放按钮.理想情况下,我想至少移动"i"按钮,这样它就不会与圆形白色按钮发生冲突.

这是当前呈现方式的屏幕截图:

应用截图 所以我在谈论白色圆形下面的蓝色按钮.

除了Geolocation代码之外,这就是我添加Bing Maps图层的方式,我假设我会添加代码来删除这些,但我尝试的所有内容都没有区别:

var styles = [
    'Road',
    'Aerial',
    'AerialWithLabels',
    'ordnanceSurvey'
];
var layers = [];
var i, ii;
for (i = 0, ii = styles.length; i < ii; ++i) {
    layers.push(new ol.layer.Tile({
        visible: false,
        preload: Infinity,
        source: new ol.source.BingMaps({
            key: 'my key is here in the real version',
            imagerySet: styles[i],
            disableZooming: true,
            // use maxZoom 19 to see stretched tiles instead of the BingMaps
            // "no photos at this zoom level" tiles
            maxZoom: 19 …
Run Code Online (Sandbox Code Playgroud)

javascript bing-maps ios openlayers-3

4
推荐指数
1
解决办法
3256
查看次数

javascript clearTimeout没有清除超时!这应该不难?

我正在使用setTimeout和clearTimeout进行自动注销.应该是非常直接但是明确的超时似乎不会停止超时并且无论如何都会调用该函数.我设置了会话变量填充javascript然后读取的文本输入并与现在的时间进行比较.如果差异大于或等于20秒,则重叠div显示给出更新会话的选项,否则它将在10秒内注销.检查上次活动的脚本每十秒自动运行一次.显然,一旦我开始工作,时间会更长 - 这些仅用于测试目的.

我已经在网上搜索过,但似乎找不到一个明显的解决方案,因为它不是那么复杂,看起来它应该真正起作用!

这是我的代码:

var t = 0;
function check_status(){
    var time_now = Math.floor(new Date().getTime() / 1000);
    var last_activity = document.getElementById("last_activity").value;
    var since_last_activity = time_now-last_activity;
    console.info(since_last_activity);

    if(since_last_activity >= 20){
        // show div
        document.getElementById("logout_warning").style.height = document.documentElement.clientHeight+"px";
        document.getElementById("logout_warning").style.display = 'block';

        // start countdown
        var t = setTimeout("logout();", 10000);
    }
}

function logout(){
    document.getElementById("logout_warning").style.display = 'none';
    location.href="/user/logout";
}

function renew(){
    clearTimeout(t);

    var time_now = Math.floor(new Date().getTime() / 1000);
    document.getElementById("last_activity").value = time_now;
    document.getElementById("logout_warning").style.display = 'none';
}

setInterval('check_status()', 10000);
Run Code Online (Sandbox Code Playgroud)

然后在身体......

<div id="logout_warning" style="display:none; width:100%; …
Run Code Online (Sandbox Code Playgroud)

javascript

3
推荐指数
1
解决办法
5537
查看次数

返回false不停止表单提交

我很确定这不应该那么难.我有一个表单在onsubmit上运行以下函数:

function FORMVALIDATE_add_rota_entry() {
    var rota_date = $("#rota_date").val();
    var rota_id = $("#rota_id").val();
    var am_pm = $("#am_pm").val();
    if(rota_date == "")
    {
        alert("Please enter a date.");
        return false;
    }
    if(rota_id == "error")
    {
        alert("Please select a rota from the list.");
        return false;
    }
    // check if that rota has already been entered for that date and am/pm
    $.ajax({
        async:false,
        type:"POST",
        url:"/modules/rotas/check_rota_entry_existence",
        data:{rota_date:rota_date, rota_id:rota_id, am_pm:am_pm},
        success: function(result) {
            if(result != "0")
            {
                alert("This rota has already been added to this date, "+am_pm+".");
                return …
Run Code Online (Sandbox Code Playgroud)

javascript forms jquery

3
推荐指数
1
解决办法
2万
查看次数

只允许从所属网站访问目录中的文件

我知道那里有很多类似的问题,我已经对它们进行了全部搜索,但我似乎无法找到任何可行的解决方案。

我的网站根目录中有一个文件夹,其中包含上传的文件,当用户登录时可以从网站查看和下载这些文件。它们位于: https: //example.com/uploads(例如)。我需要该网站继续能够访问它们以显示它们(有些是图像)并提供下载链接(pdf 等),以便用户可以下载它们,但我想避免任何人掌握可以直接下载特定文件,如下所示: https: //example.com/uploads/2020/02/myfile.pdf。或者这些网址进入搜索引擎(或者如果进入,服务器会阻止它们被直接访问)。

我尝试在上传目录中添加一个 .htaccess 文件,其中包含以下内容:

Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Run Code Online (Sandbox Code Playgroud)

我已经尝试过

Order Allow,Deny
Deny from all
Allow from 127.0.0.1
Run Code Online (Sandbox Code Playgroud)

...据我了解,这可能允许来自站点本身以及本地 URL 的 HTTPS 调用。

但它禁止该站点和直接的 url 请求,这不好。

有没有办法做到这一点?

apache .htaccess server

2
推荐指数
1
解决办法
1991
查看次数

标签 统计

javascript ×5

openlayers-3 ×4

.htaccess ×1

apache ×1

bing-maps ×1

forms ×1

ios ×1

jquery ×1

server ×1