We help IT Professionals succeed at work.
Get Started

Anybody ever heard of "leaflet.js" or "heatmap.js"?

Bruce Gust
Bruce Gust asked
Last Modified: 2020-03-26
Here's a screenshot of my page:

Here's what you're looking at:

This particular company doesn't have any address information .Within the code, there's a piece that's looking for some relevant data based on the postal code. If that info doesn't exist, the page will just sit there until it finally times out leaving the user confused and bewildered.

To solve that dilemma, once I found the relevant syntax, I just qualified things by engaging that query only if there were some postal codes to query.

So, now for the first time in days, I'm actually able to look at some data on the page that, beforehand was simply timing out with no real explanation, at least as far as the user was concerned.


As you can tell by the screenshot, while the page is firing, beneath the hood there's an error message that references "leaflet.js."

Upon closer inspection, "heatmap.js" is involved as well.

So, here's my dilemma...

Although there's only one row in my database at this point, there will most certainly be multiple rows, most of which will represent a complete array of information. In other words, they will have some postal codes.

But in those instances where you've got a renegade row with no postal codes, I want to prevent "heatmap" from firing.

Here's the twig file:

<table id="main-dt" class="table custom make-datatable table-bordered table-striped dataTable no-footer" data-route="/companies/datatable" data-layout="tlipr" data-callback="initHeatMap();">
          <th scope="col" data-field=":checkbox" data-searchable="0" data-sortable="0">
            <div class="pretty p-default">
                <input type="checkbox" class="table-all" />
                <div class="state p-primary">
          <th scope="col" data-field="name" data-searchable="0" data-sortable="1">Company</th>
          <th scope="col" data-field="owner" data-searchable="0" data-sortable="1">Lead Owner</th>
            <th scope="col" data-field="contacts" data-searchable="0" data-sortable="1">Contacts</th>
          <th scope="col" data-field="addresses" data-searchable="0" data-sortable="1">Location</th>
          <th scope="col" data-field="meta.ftes" data-searchable="0" data-sortable="1">FTE's</th>
          <th scope="col" data-field="meta.premium" data-searchable="0" data-sortable="1">Premium</th>
          <!-- th scope="col" data-field=":actions">&nbsp;</th -->

Open in new window

I'm looking for a "for" loop and I don't see one.

How can I evaluate each hypothetical row and prevent any attempt on the part of the system to try and plot that on the map?

BTW: I'm more than happy to provide as much code as you want or need in order to comment intelligently, but I thought I would start with the basics first - especially since both heatmap.js is a third party thing and I'm hoping there's some ninjas who've worked with it before that can point me in the right direction.

Watch Question
Distinguished Expert 2020
This problem has been solved!
Unlock 3 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE