-
Notifications
You must be signed in to change notification settings - Fork 35
Conversation
|
||
// Parse GeoJSON data from USGS on earthquakes in the past week. | ||
DispatchQueue.global().async { | ||
guard let url = URL(string: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson") else { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This URL should never fail to initialize and can be safely force-unwrapped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URLs themselves are also different — the objc example uses the static GL-JS version of this feed.
guard let url = URL(string: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson") else { return } | ||
DispatchQueue.main.async { | ||
self.displayEarthquakes(url: url, style: style) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you say more about what the intention is here, re: threading? It appears that you’re creating the URL on a background thread, then doing the actual fetching and rendering on the main thread.
MGLShapeSourceOption.clusterRadius: 20, | ||
MGLShapeSourceOption.maximumZoomLevel: 15] as [MGLShapeSourceOption : Any] | ||
|
||
let earthquakeSource = MGLShapeSource(identifier: "earthquakes", url: url, options: options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is where the remote fetching happens, should there be some protection against it failing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the source to a Mapbox hosted one. Will look into using this live data source for a tutorial/different example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So cool! I have some style suggestions - feel free to incorporate as you see fit :)
- Consider making the colors more opaque, so that the land features are not as obscured below the heatmap.
- Maybe use the dark or light style, so that the colors used in the heatmap stand out more 🌞 🌚
Is there anything else to address with this? @friedbunny @captainbarbosa |
3712231
to
6172ba2
Compare
No, I don't think so @jmkiley - looks good! 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌶♨️🔥🌭
Ported this example from GL-JS. I switched the data source to use the USGS earthquake live data.