Incrementing values on a map

Hey all,

I am currently struggling with something and was hoping to get some ideas/workarounds/assistance. I have a project due in a couple weeks, and the client just decided they want it to have more complex functionality. My first thought on accomplishing this extra functionality was to use Intuiface.

The new project requirements:

Quick summary:
An interactive world map that visually represents how many people are attending the event from each country by displaying a running tally “score keeper” over each country.

A customer walks up to a display at a conference with a world map on it. Their is a search bar at the bottom of the map for the customer to type in the city or postal code they come from. When they type this in and hit enter, the map moves to the region they entered. Then it zooms out and resets to the central world view, shows a number over the country of the city they just entered, and increments that number by 1, adding the customers presence to the tally.

Here’s what I’ve got so far:

Map functionality
I have a text input asset whose value is bound to an Address to Coordinate asset. The Address to Coordinate asset’s latitude and longitude values are bound to a map (using mapbox). So right now functionally I can type in a city or zip code and have the map move to that location.

Running tally functionality
I have an excel file with all the countries in the world and their latitude and longitude coordinates. Within intuiface, within my map asset, I have my excel asset, and beneath that a text asset to work as a “score keeper” template for each country. That “score keeper” text asset has it’s latitude and longitude values bound to the corresponding latitude and longitude cells in the excel sheet.

So right now functionally I have a map that has numbers automatically placed over each country on the map, waiting for action.

My main struggle:

I’m having difficulty connecting these two pieces so that when I hit enter, the corresponding score for the country entered goes up.

When this project started I was coding a simpler version in HTML and Javascript where each country had it’s own button in a sliding UI. I was storing all of the country names and country scores in arrays of equal length, so their indices represented universal IDs that corresponded across arrays. In order to increment the values for each country, I told it to increment the value of the country score at the same index. I’m still fairly new to Javascript so their is probably a better way, but it worked without having to use an API.

I’m not sure how to do that here, how to make an identifier for each country’s “score keeper” that can be triggered to increment if it’s country is found.

What I’ve tried:

I’ve used the Address to Coordinates asset to move the map, and then bound those latitude and longitude values to a Coordinates to Address asset to give me back the country associated with the city or postal code entered. So I can tell which country the city the user entered is in.

Then I’ve tried using the Two Value Comparison asset, binding the Coordinates to Asset country value to Value A, and binding Value B to the name of the country in the excel file, so I can compare the map country to a value within the country list. With this setup, I can trigger a Simple Counter asset to add one to a text asset if the results match. However, this only works for a single bound value. Is there a way to pass in a relative value (like you would pass in an argument in a function) so that it can compare multiple values for Value B against Value A instead of having to hard code and duplicate this setup for each country?

A friend suggested possibly looking into using excel formulas to compare and/or increment the score values instead of doing it within intuiface. That way I could just have a score column in intuiface, compare values and increment the right number within excel, and find a way to spit that back out to the “score keeper” text asset for it’s associated country. That sounds like it’s probably a viable solution, but I don’t know enough yet about excel formulas or using them within Intuiface. I will keep playing with it tomorrow, if this is (or isn’t) a realistic solution please let me know.

I’ve also considered writing my own custom interface asset in Javascript because I can better visualize how this “missing piece” would function through code, but I feel like there is a simpler way to do it within Intuiface that I’m missing.

Anyway, it’s been a long day and my brain is a little fried so I apologize if this is too wordy or makes no sense. I will upload a project file of my current set up as soon as I can (might not be until tomorrow morning).

Any help would be greatly appreciated.

Thanks.

As Justin also started a thread on our Support, got an answer that solved his issue and was willing to share, here is a copy/paste:

The way to link the detected country, increment the number of attendee can be achieved this way:

  • once you get the country from the Geocoding, store it in a Global Variable Asset
  • filter your Excel Results file using the “Name” column with the Country from the Global variable above
  • simulate a tap on a button (see below)

Create a button, set a trigger “is tapped” with 2 conditions:

  • if (rows = 0): create a new row with the country, latitude, longitude and number of attendee being 1
  • if (rows != 0): update the unique row with number of attendee incremented by 1

For the map display, don’t forget to bind your Excel result file to your map so you can display every Country that have attendees.