小编use*_*815的帖子

Google Map KML图层地标点击事件返回ZERO_RESULTS

将侦听器附加到KML层:

var layer = new google.maps.KmlLayer('http://sites.google.com/site/kmlprototypes/kmls/temp.kml?dc_=' + Math.random(),
{suppressInfoWindows:true,preserveViewport:true});

layer.setMap(map);

google.maps.event.addListener(layer, 'click', function (obj) {
    alert(obj.featureData.id);
});
Run Code Online (Sandbox Code Playgroud)

KML文件有效(通过验证api检查),您可以在此处找到它.XML中的每个地标都有id属性,如:

<Placemark id="46">
  <Style>
    <IconStyle>
      <Icon>
        <href>
          <![CDATA[http://chart.apis.google.com/chart?chf=bg,s,EAF7FE02&chxt=y&chbh=a,4,4&chs=48x48&cht=bvg&chco=FF0000,0000FF&chds=20,9048.00,0,9048.00&chd=t:8149.00|9048.00]]>
        </href>
      </Icon>
    </IconStyle>
  </Style>
  <Point>
    <coordinates>30.49566650390625,50.721378326416016</coordinates>
  </Point>
</Placemark>
Run Code Online (Sandbox Code Playgroud)

当点击谷歌地图对象中的地标时返回正确的ID,但有时大约50%的时间obj.featuredData.idnull(ZERO_RESULTS状态在status字段中).我尝试过不同的数据集(从100点到1000点),但没有用.我也尝试过lat,lng的不同精度.

javascript kml google-maps-api-3

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

带反压的反应式 SQS 轮询器

尝试创建 SQS 轮询器:

  • 进行指数轮询(如果队列中没有消息,则减少请求数量)
  • 如果队列中有很多消息,则更频繁地查询 SQS
  • 如果收到一定数量的消息有背压,它会停止轮询
  • 不受 AWS API 速率限制的限制

作为一个例子,我正在使用这个JavaRx 实现,它很容易转换为 Project Reactor 并通过背压对其进行丰富。

private static final Long DEFAULT_BACKOFF = 500L;
private static final Long MAX_BACKOFF = 8000L;
private static final Logger LOGGER = LoggerFactory.getLogger(SqsPollerService.class);
private static volatile boolean stopRequested;

public Flux<Message> pollMessages(GetQueueUrlResult q)
{
    return Flux.create(sink -> {
        long backoff = DEFAULT_BACKOFF;

        while (!stopRequested)
        {
            if (sink.isCancelled())
            {
                sink.error(new RuntimeException("Stop requested"));
                break;
            }

            Future<ReceiveMessageResult> future = sink.requestedFromDownstream() > 0
                    ? amazonSQS.receiveMessageAsync(createRequest(q))
                    : completedFuture(new ReceiveMessageResult());

            try …
Run Code Online (Sandbox Code Playgroud)

java amazon-sqs project-reactor

6
推荐指数
1
解决办法
1937
查看次数