Sunday, 1 August 2021

How to get click handler on animated canvas dot on MapBox map?

I am looking at this demo from MapBox:

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Add an animated icon to the map</title>
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <link href="https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.css" rel="stylesheet">
  <script src="https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.js"></script>
  <style>
    body { margin: 0; padding: 0; }
    #map { position: absolute; top: 0; bottom: 0; width: 100%; }
  </style>
</head>

<body>
  <div id="map"></div>
  <script>
    mapboxgl.accessToken = 'pk.thekey.12345';
    var map = new mapboxgl.Map({
      container: 'map',
      style: 'mapbox://styles/mapbox/streets-v9'
    });
    var size = 200;
    // This implements `StyleImageInterface`
    // to draw a pulsing dot icon on the map.
    var pulsingDot = {
      width: size,
      height: size,
      data: new Uint8Array(size * size * 4),
      // When the layer is added to the map,
      // get the rendering context for the map canvas.
      onAdd: function() {
        var canvas = document.createElement('canvas');
        canvas.width = this.width;
        canvas.height = this.height;
        this.context = canvas.getContext('2d');
      },
      // Call once before every frame where the icon will be used.
      render: function() {
        var duration = 1000;
        var t = (performance.now() % duration) / duration;
        var radius = (size / 2) * 0.3;
        var outerRadius = (size / 2) * 0.7 * t + radius;
        var context = this.context;
        // Draw the outer circle.
        context.clearRect(0, 0, this.width, this.height);
        context.beginPath();
        context.arc(
          this.width / 2,
          this.height / 2,
          outerRadius,
          0,
          Math.PI * 2
        );
        context.fillStyle = 'rgba(255, 200, 200,' + (1 - t) + ')';
        context.fill();
        // Draw the inner circle.
        context.beginPath();
        context.arc(
          this.width / 2,
          this.height / 2,
          radius,
          0,
          Math.PI * 2
        );
        context.fillStyle = 'rgba(255, 100, 100, 1)';
        context.strokeStyle = 'white';
        context.lineWidth = 2 + 4 * (1 - t);
        context.fill();
        context.stroke();
        // Update this image's data with data from the canvas.
        this.data = context.getImageData(
          0,
          0,
          this.width,
          this.height
        ).data;
        // Continuously repaint the map, resulting
        // in the smooth animation of the dot.
        map.triggerRepaint();
        // Return `true` to let the map know that the image was updated.
        return true;
      }
    };
    map.on('load', function() {
      map.addImage('pulsing-dot', pulsingDot, {
        pixelRatio: 2
      });
      map.addSource('dot-point', {
        'type': 'geojson',
        'data': {
          'type': 'FeatureCollection',
          'features': [{
            'type': 'Feature',
            'geometry': {
              'type': 'Point',
              'coordinates': [0, 0] // icon position [lng, lat]
            }
          }]
        }
      });
      map.addLayer({
        'id': 'layer-with-pulsing-dot',
        'type': 'symbol',
        'source': 'dot-point',
        'layout': {
          'icon-image': 'pulsing-dot'
        }
      });
    });
  </script>
</body>

</html>

How do make it so I can handle on click on the dot, and make the cursor a pointer when you hover over it?



from How to get click handler on animated canvas dot on MapBox map?

Add "rel"-attribute to img tag in TinyMCE 5 editor

I search a solution to add automatically a "rel-attribute" to every image which is added in the TinyMCE 5 editor. So the html tag should look like:

<img class="imageborder" src="https://xy.jpg" rel="lightbox" width="500" height="333" />

I've tried it like that, but it doesn't get added. This is the JSFiddle.

tinyMCE.init({
    selector: '#myTextarea',
    plugins: 'code image autolink link lists charmap print preview textcolor',
    toolbar: 'code image link | undo redo | insert | ',
    menubar: false,
    min_height: 300,
    image_class_list: [
        { title: 'imageborder', value: 'imageborder' },
    ],
    image_rel_list: [
        { title: 'lightbox', value: 'lightbox' },
    ],
    setup: function (ed) {
        ed.on("keyup", function () {
            $('#preview').html(tinymce.activeEditor.getContent());
        });
    }
});


from Add "rel"-attribute to img tag in TinyMCE 5 editor

Zebra SDK cant write tag

Device:TC20

I am getting an exception com.zebra.rfid.api3.OperationFailureException on last line

override fun writeTagID(tagId: String, newId: HexString, password: HexString) {

    // конфигурация взята из офф. документации https://techdocs.zebra.com/dcs/rfid/android/2-15/guide/tagwrite/

    reader.Config.setAccessOperationWaitTimeout(3000)

    reader.Actions.Inventory.stop()
    reader.Config.dpoState = DYNAMIC_POWER_OPTIMIZATION.DISABLE

    val tagData: TagData? = null
    val tagAccess = TagAccess()
    val writeAccessParams = tagAccess.WriteAccessParams()
    val writeData: String = newId.value

    writeAccessParams.accessPassword = password.value.toLong(16)
    writeAccessParams.memoryBank = MEMORY_BANK_EPC
    writeAccessParams.offset = 2 // offset is two for EPC ID

    writeAccessParams.setWriteData(writeData)
    // set retries in case of partial write happens
    writeAccessParams.writeRetries = 3
    // data length in words
    writeAccessParams.writeDataLength = writeData.length / 4
    // 5th parameter bPrefilter flag is true which means API will apply pre filter internally
    // 6th parameter should be true in case of changing EPC ID it self i.e. source and target both is EPC
    reader.Actions.TagAccess.writeWait(tagId, writeAccessParams, null, tagData, true, true)
}

I read the documentation. Tried increasing the timeout but still getting an exception. Вот логи ошибки

2021-07-30 14:26:09.978 13780-13998/ru.app.rfid_android W/System.err: com.zebra.rfid.api3.OperationFailureException
2021-07-30 14:26:09.979 13780-13998/ru.app.rfid_android W/System.err:     at com.zebra.rfid.api3.j1.a(SourceFile:4)
2021-07-30 14:26:09.979 13780-13998/ru.app.rfid_android W/System.err:     at com.zebra.rfid.api3.TagAccess.writeWait(SourceFile:34)
2021-07-30 14:26:09.980 13780-13998/ru.app.rfid_android W/System.err:     at ru.app.rfid_android.core.reader.zebra.ZebraReaderAndroid.writeTagID-e7Vaky0(ZebraReaderAndroid.kt:218)
2021-07-30 14:26:09.980 13780-13998/ru.app.rfid_android W/System.err:     at ru.app.rfid_android.core.model.ReaderRec.writeAndReadTag-ToYnHGU(ReaderRec.kt:269)
2021-07-30 14:26:09.980 13780-13998/ru.app.rfid_android W/System.err:     at ru.app.rfid_android.core.model.ReaderRec$writeBank$1.invoke(ReaderRec.kt:246)
2021-07-30 14:26:09.981 13780-13998/ru.app.rfid_android W/System.err:     at ru.app.rfid_android.core.model.ReaderRec$writeBank$1.invoke(ReaderRec.kt:30)
2021-07-30 14:26:09.982 13780-13998/ru.app.rfid_android W/System.err:     at ru.app.rfid_android.core.model.ReaderRec$runCatchingAndTimeout$1.invoke(ReaderRec.kt:371)
2021-07-30 14:26:09.982 13780-13998/ru.app.rfid_android W/System.err:     at ru.app.rfid_android.core.model.ReaderRec$runCatchingAndTimeout$1.invoke(ReaderRec.kt:30)
2021-07-30 14:26:09.983 13780-13998/ru.app.rfid_android W/System.err:     at ru.app.rfid_android.core.UtilsKt$runWithTimeout$stuffToDo$1.run(Utils.kt:82)
2021-07-30 14:26:09.983 13780-13998/ru.app.rfid_android W/System.err:     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
2021-07-30 14:26:09.984 13780-13998/ru.app.rfid_android W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2021-07-30 14:26:09.984 13780-13998/ru.app.rfid_android W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
2021-07-30 14:26:09.984 13780-13998/ru.app.rfid_android W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
2021-07-30 14:26:09.984 13780-13998/ru.app.rfid_android W/System.err:     at java.lang.Thread.run(Thread.java:764)


from Zebra SDK cant write tag