Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

[WIP] Heatmap example #87

Merged
merged 7 commits into from
Jun 14, 2017
Merged

[WIP] Heatmap example #87

merged 7 commits into from
Jun 14, 2017

Conversation

jmkiley
Copy link
Contributor

@jmkiley jmkiley commented May 12, 2017

Ported this example from GL-JS. I switched the data source to use the USGS earthquake live data.

  • Write example
  • Add comments
  • Incorporate revisions

screenshot 2017-05-12 11 30 13


// 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 }
Copy link
Contributor

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.

Copy link
Contributor

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)
}
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@captainbarbosa captainbarbosa left a 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 🌞 🌚

@jmkiley
Copy link
Contributor Author

jmkiley commented May 24, 2017

screenshot 2017-05-23 10 20 09

Changed the opacity and colors, switched to dark style.

@jmkiley
Copy link
Contributor Author

jmkiley commented Jun 14, 2017

Is there anything else to address with this? @friedbunny @captainbarbosa

@captainbarbosa
Copy link
Contributor

No, I don't think so @jmkiley - looks good! 👍

Copy link
Contributor

@friedbunny friedbunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌶♨️🔥🌭

@jmkiley jmkiley merged commit f39ccb4 into master Jun 14, 2017
@jmkiley jmkiley deleted the jk-heatmap-example branch June 14, 2017 17:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants