Trying to add GEOJSON as marker on mapbox - javascript

I would like my map to display GEOJSON as markers which it currently does.
I created 3 files to make 3 different API calls.
However, only the first script file is executed and the rest are ignored.
I would like the markers to be displayed based on the users chosen file path . (e.g "/daily", "/", "monthly")
At the moment the mapbox markers are is only using the data from the first script. The data only changes when I manually swap the script files around.
This is my first StackOverFlow question, so I am unable to post picture of my results. I have linked my issue with pictures of the the marker rendering out data based on the order of script files.
My Pr: https://github.com/Rhianna20/disaster_check/pull/13
My issue: https://github.com/Rhianna20/disaster_check/issues/14
I would appreciate any tips or advice on this, thank you!
My code
dailyMapbox.js
The client/monthly, client/daily files all contain the same code apart from the url value being different.
I then placed the script files inside of document.js
Here is my app.js file structure. Which does not use my client/public files. Instead document.js is called on each file path.

In your Issue we can see this error : Identifier map has been declared.
The problem is that you add 3 scripts to your HTML, and the same variable map is declared in the 3 scripts.
Do you have control on the files client/daily and client/monthly ?
If yes and if you know a little javascript, you can implement the user-chosen
map yourself.
If not, you can create a select element where users can choose an existing
file and then choose to only display this file...
In either way you will need to get your hands dirty in javascript.
We can help you more, but we will need you to add some relevant code in your question

Related

Is it possible to load external js files/libraries into Acumatica?

I'm working on a new Acumatica screen for our company that will require some javascript code to retrieve and display a map object (from ESRI).
This code requires an external .js file that is included to the HTML by the javascript code itself. Everything works fine if I use a blank HTML page to test this.
The problem I have is that when I try using the same code from inside the Acumatica screen, it doesn't load this required external file, and therefore the code does not work properly.
I attempted to load the full .js file code along with my code, but it returned the following error:
error CS8095: Length of String constant exceeds current memory limit. Try splitting the string into multiple constants.
I haven't tried splitting this file into multiple strings (as the error message suggests), because I want to make sure there isn't a cleaner and more professional, direct/right way to do this.
Is it possible to manually import this external .js file into our Acumatica instance, so I can point to it instead? (in case it makes a difference if it's hosted in the same environment)
or, is there any way to make Acumatica able to load external files so we can keep using our current approach? (any setting that may be preventing external files from loading?)
I'm not sure i fully understand the question. What comes to mind however is you may be looking to use the PXJavaScript control. I used this link to help get my head wrapped around how to use the control. We had a need to trigger something off with Java Script and the PXJavaScript control got us to the end result we needed. Let me know if this gets you in the right direction?
Dynamically Change Button Color

Unable to view output of script in bl.ocks.org

I have been trying to figure out why my code is unable to be viewed in bl.ocks.org. I'd really like to see it up somewhere.
My code is for a bar chart that can handle changes in records and values created from a .csv file.
I have made sure that my code is working outside of this loading it from a local server from it's folder that contains the .html file and the .csv file.
I've ensured that it's not the browser cache either.
It can be found here: http://bl.ocks.org/parnelandr/7887491
Any help would be appreciated. I'm sure I've just missed something along the way.
The d3.js script you're referencing in your gist has a local path, i.e. it would need to be part of the gist as well, which it isn't. It should work fine if you either add d3.js or (preferably) reference the global URL to it instead.

Can you change the output location for the Randori generated html files?

I'm creating a new project and I want to customize the location of the generated files from Randori. How can I do this?
Check out Lesson-02: Creating an Initial HTML file & Run Configuration
From here you will see how to edit your Randori configuration. You can make the generated output anything you want. However just make sure to update your main html file and point to the correct (customized) generated folder.
One more point on this when you call the launch() method of RandoriBootstrap, you can pass two arguments. The first is whether you want debug mode on or off (debug mode does cache busting) the second is the URL that the class loader will use to find your classes. Should you put things in generatedFoo folder, you need to make sure the RandoriBootstrap knows this.

Managing page specific Javascript: 1 big file with conditionals or multiple files

In my project I have a load of functions that are used on every page, so I have put these in a single javascript file common.js and have included it in my footer template. My questions is, what is the best way to handle page-specific javscript?
For example, on one of my pages I have a google map. If my map js code is run on a page where I don't have an element with id map_canvas, I get an error.
Method 1: I could write some PHP which echos an additional script tag requesting map.js if and only if I'm on a map page.
Method 2: I could give the <body> of my map page an id of "map_page", then I could write a conditional clause in common.js along the lines of:
if (#map_page exists){
put contents of map.js here
}
The problem with method 1 is that it increases the number of requests to the server.
The problem with method 2 is that it bloats my common javascript file.
Please can somebody explain, which, if any would be the preferred method to do this, or if neither are suitable, what I should do instead?
I have approximately 10 page-specific javascript files to deal with.
Thanks
I would say that simpler is better. On every page, just add a script tag calling map.js. Or, in your common.js, you don't need to paste all of map.js's code. You can just create a new script tag with the js and call map.js like that. I would not recommend the php method. The easiest and simplest, therefore the least likely to be buggy method, is just to add another script tag to the pages that need it. Or if that is not an option, common.js could include this:
if(need map.js){
var mapjs=document.createElement("script");
mapjs.type="text/javascript";
mapjs.src="map.js";
document.body.appendChild(mapjs);
}

Using Components.utils.import in a firefox extension

I am trying to create some global variables in a firefox extension. In my content folder, I have two javascript files:
1) Main JS file that holds the functions for the different events, etc
2) A file that stores only an object with the pieces of state I want to maintain. Also, I set the array EXPORTED_SYMBOLS.
I am having issues with the following line found in my main JS file:
Components.utils.import("resource:///globalVariables.js");
When it is at the top of the file, nothing seems to work. If I move it into the function where I need the variable, the rest of my code works, but the function with this line does nothing. Any advice that would help me with this problem would be great. Thanks
Chances are resource:///globalVariables.js is not the right URI. Make sure you register it properly, and include the aliasname when you reference it.

Categories