Select to view content in your preferred language

How to show the new earthquake every minute?

730
2
02-21-2020 04:19 PM
YiqunChen
Emerging Contributor

I am studying arcgis javascript and I saw a few examples using geoJson from USGS to mark the earthquakes globally.

USGS claims that the past hour geoJson file is updated every minute so I want to only mark the new earthquake every minute. How should I do it? Should I save the ids from the past hour geoJson file in the last minute and find out the new earthquakes by comparing ids from last minute to ids from current minute (earthquake ids are unique)? or should I check the time of the earthquake? which way sounds better or any other simple way?

This is the code to load the past hour earthquake:

const url3 =
           "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson";
const geojsonLayer = new GeoJSONLayer({
          url: url3,
          copyright: "USGS Earthquakes",
          popupTemplate: template,
          renderer: renderer //optional
        });

This is how I will reload USGS url every 60 seconds:

language="javascript">
    setInterval(function(){
         window.location.reload(1); //refresh all
         //alert('refresh');
         //map.getLayer("geojsonLayer2").refresh(); //refresh only one
      }, 60000);

Then I hesitate whether to query the time of the earthquake or query the ids to find out the new earthquake.

Thank you!

Tags (2)
0 Kudos
2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

GeoJSONLayer is not a refreshable layer at 4.14. We plan on making this layer refreshable in the future release. So at 4.14, you have to recreate the GeoJSONLayer at your specified interval add it to your map. You can also set the timeInfo information on the layer whenever you initialize layer. This will help you to do time query on the layer.  I created a simple test app that applies FeatureEffect to the GeoJSONLayer based on the timeExtent. In this example app, the only earthquakes features that were added will have the layer's renderer applied while the older features will have effects applied.  

Hope this helps,

-Undral

YiqunChen
Emerging Contributor

Hi Undral,

Before I saw your reply, I did try querying the field "time" and compared it to the time from Date() every minute after reloading. I really appreciate that you even made an example code for me to study, thank you!

Yiqun

0 Kudos