Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
QGIS Blueprints

You're reading from   QGIS Blueprints Develop analytical location-based web applications with QGIS

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher Packt
ISBN-13 9781785289071
Length 258 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ben Mearns Ben Mearns
Author Profile Icon Ben Mearns
Ben Mearns
Arrow right icon
View More author details
Toc

Putting it all together


Now, we'll connect the Google Sheets feed with our Mapbox tiles service in our final application.

Parsing the sheets JSON feed

Previously, we parsed the JSON feed with jQuery for each loop to print two attribute values for each element. Now, we'll remap the feed onto an object that we can use to look up data for the geographic objects triggered in UTFGrid. Review the following code, to see how this done:

// Create a data object in public scope to use for mapping
// of JSON data, using id for key
var d = {};

// url variable is set with code from previous section
// url contains public sheet id

$.getJSON(url, function(data) {
  var entry = data.feed.entry;
  var title = '';

  $(entry).each(function(index, value){
    // Column names are name, type, etc.
    $('.results').prepend('<h2>'+this.gsx$name.$t+'</h2><p>'+ this.title.$t +'</p>'+'<p>'+this.gsx$type.$t+'</p>');
    title = this.title.$t;
    $.each(this, function(i, n){
   ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image