小编jaa*_*lah的帖子

如何在Javascript中使用传单滑块和markercluster?

我正在制作一个使用滑块来显示或隐藏标记的地图,我想添加聚类功能,每个单独工作完美,但我希望滑块显示标记,并且在标记非常接近的情况下使用集群. 问题是,个体和标记集群都在显示,我希望显示的标记集群而不是一直存在的集群

 <script type="text/javascript">
		var sliderControl = null;
                    //creating layers
                    var cities = new L.LayerGroup();
                    var mbAttr = 'Map data &copy; <a href="http://openstreetmap.org">OpenstreetMap</a> contributors, ' +
                    '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
                    'Imagery © <a href="http://mapbox.com">Mapbox</a>',
                    mbUrl = 'https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png';
                    var grayscale = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {id: 'remote-sensing.n8k508ak', attribution: mbAttr, accessToken: 'pk.eyJ1IjoicmVtb3RlLXNlbnNpbmciLCJhIjoiYWNiYzg0ZWU2Mjk3ZTU5NjE4MmQyZWEzZTY2ZWNlYjIifQ.U7mp4MXdcjaIwW_syAqriQ'})
                    , streets = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {id: 'remote-sensing.84f6c85a', attribution: mbAttr, accessToken: 'pk.eyJ1IjoicmVtb3RlLXNlbnNpbmciLCJhIjoiYWNiYzg0ZWU2Mjk3ZTU5NjE4MmQyZWEzZTY2ZWNlYjIifQ.U7mp4MXdcjaIwW_syAqriQ'});
                    //create and add the layers to the map
                    var map = L.map('map', {
                    center: [33.9, 35.877],
                            zoom: 10,
                            layers: [ streets, cities]
                    }); …
Run Code Online (Sandbox Code Playgroud)

html javascript openstreetmap leaflet

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

服务器工作者已注册两次

调用register函数时,我正在使用FCM Web通知服务:

if ('serviceWorker' in navigator) {
         window.addEventListener('load', function() {
        navigator.serviceWorker.register('/sw.js').then(function(registration) {
          // Registration was successful
          console.log('ServiceWorker registration successful with scope: ', registration.scope);
        }).catch(function(err) {
          // registration failed :(
          console.log('ServiceWorker registration failed: ', err);
        });
      });
    }
Run Code Online (Sandbox Code Playgroud)

服务工作者被注册两次,一次是由于此功能,一次是通过FCM脚本注册。这是我的服务人员代码:

importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-messaging.js');

    'messagingSenderId': '<my senderid>'
});

const messaging = firebase.messaging();


messaging.setBackgroundMessageHandler(function (payload) {


    self.addEventListener('notificationclick', function (event) {
        event.notification.close();

        var promise = new Promise(function (resolve) {
            setTimeout(resolve, 1000);
        }).then(function () {
            return clients.openWindow(payload.data.locator);
        });

        event.waitUntil(promise);
    });

    var notificationTitle = payload.data.title;
    var …
Run Code Online (Sandbox Code Playgroud)

javascript web-notifications firebase service-worker firebase-cloud-messaging

5
推荐指数
0
解决办法
701
查看次数

NOT IN 不能在谷歌 BigQuery 标准 sql 中工作

我正在使用 Google BigQuery,我试图从“table2”中查找“userid”,但不包括存储在“table1”中 2 次或更多次的用户 ID。这是代码:

#standardSQL
WITH t100 AS (
SELECT count_table.userid 
From(
SELECT userid,COUNT(`project.dataset.table1`.userid) as notification_count 
FROM `project.dataset.table1`
 GROUP BY userid) as count_table 
where notification_count >= 2 
)

SELECT userid FROM `project.dataset.table2` WHERE userid NOT IN (SELECT userid  FROM t100)
Run Code Online (Sandbox Code Playgroud)

问题是,这是从 'table1' 返回存储 2 次或更多次的 'userid's,我曾尝试添加WHERE userid IS NOT NULLSELECT userid FROM t100,但它没有任何区别。为了让一切都更清楚,这个 : SELECT userid FROM t100不是空的,并且由于某种原因返回的结果仍然显示在上面第一个代码的结果中。

sql database google-bigquery

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

Google Chrome中的服务工作者警告

我正在使用FCM发送网络通知.我收到此警告并单击通知不会给出通常的结果(打开通知URL).这是Service-Worker代码

importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-messaging.js');
firebase.initializeApp({
'messagingSenderId': '<my senderid>'
});

const messaging = firebase.messaging();


messaging.setBackgroundMessageHandler(function(payload) {


  self.addEventListener('notificationclick', function(event) {
    event.notification.close();

    var promise = new Promise(function(resolve) {
      setTimeout(resolve, 1000);
    }).then(function() {
      return clients.openWindow(payload.data.locator);
    });

    event.waitUntil(promise);
  });

  var notificationTitle = payload.data.title;
  var notificationOptions = {
    body: payload.data.body,
    icon: payload.data.icon
  };
  return self.registration.showNotification(notificationTitle,
    notificationOptions);
});
Run Code Online (Sandbox Code Playgroud)

firebase-messaging-sw.js:108 Event handler of 'notificationclick' event must be added on the initial evaluation of worker script.
Run Code Online (Sandbox Code Playgroud)

这是警告信息,108引用此行

self.addEventListener('notificationclick', function(event) {

这是在Chrome版本55.在Firefox上,没有任何错误,它运行完全正常.提前致谢.

javascript google-chrome firebase-cloud-messaging

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

如何使用knock out更改表的行顺序.拖放或使用向上/向下按钮

如何使用knockout更改表的行顺序.我有小提琴:

使用knockout-sortable.js.例

请协助.我的小提琴如下:

JSFiddle示例

  [1]:http://jsfiddle.net/rniemeyer/hw9B2/
  [2]:https://jsfiddle.net/nagarajputhiyavan/x9vc10zu/3/
Run Code Online (Sandbox Code Playgroud)

html jquery knockout.js knockout-sortable

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