2

I am doing some basic work with G Sheets and Sheetsee.js library.

I have it working as far as I get my coordinates showing up on a map. I'm using the demo-map file as my starter, I just changed the URL key and added my own column names to optionsJSON function.

My problem is, none of my column data is being called into the pop up template. I cannot find out what I'm doing wrong.

Here's my code for the script part:

    <script type="text/javascript">
  document.addEventListener('DOMContentLoaded', function() {
    var gData
    var URL = "XXXX_MY-KEY-ID-HERE_XXXX" 
    Tabletop.init( { key: URL, callback: showInfo, simpleSheet: true } )
  })

  function showInfo(data) {
    gData = data
    var optionsJSON = ["name", "message", "image"]
    var template = "<ul><li><a href='{{image}}' target='_blank'>"
                 + "<img src='{{image}}'></a></li>"
                 + "<li>Comment: {{message}}</li>"
                 + "<li><h4>Journey: {{name}}</h4></li></ul>"
    var geoJSON = Sheetsee.createGeoJSON(data, optionsJSON)
    var map = Sheetsee.loadMap("map")
    Sheetsee.addTileLayer(map, 'jllord.n7aml2bc')
    Sheetsee.addMarkerLayer(geoJSON, map, template)
  }

</script>
1

I have answered my own question but it might help for other novice users like myself if I note down the error I was making.

My mistake was that I did not call my coordinates columns 'Lat' and 'Long', but rather was using 'Lat' and 'Lng'. This was because I'm using a script to pull coordinates from location info (sourced via another answer at How to Geocode a Google SpreadSheet?). Once I'd realised this and changed column names, everything worked just dandy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.