I have been adding the following files in my cshtml page.
<script src="http://code.highcharts.com/maps/highmaps.js" )"></script>
<script src="https://code.highcharts.com/maps/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/offline-exporting.js"></script>
<script src="https://code.highcharts.com/maps/modules/drilldown.js"></script>
<script src="~/Content/js/balochistan.geojson"></script>
And the code for higmaps is present on the same page with script tag. Everything is working fine but hte map is not displaying and giving error for geojson file not being loaded.
http://localhost:9090/Content/js/balochistan.geojson net::ERR_ABORTED 404 (Not Found)
Can anyone please helpthat how a geojson file can be loaded properly and how to give static path to it correctly?
the file ends with .geojson can not be loaded like that - as script - because is a json file
Add this file is a set of json data - you need to loaded them on highcharts either with ajax load, either add them as variable at the beginning and connected to the chart.
Resolved:
The problem resolved by doing few steps like:
adding script tags in proper order.
secondly highmaps.js and highcharts.js file conflict with each other when used on the same page.
In order to resolve this issue you have to add
<script src="http://code.highcharts.com/highcharts-more.js"></script>
script tag in addition to highcharts.js and also replace the highmaps.js with:
<script src="//code.highcharts.com/maps/modules/map.js"></script>
like this:
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="//code.highcharts.com/maps/modules/map.js"></script>
This resolved my problem and map is showing now.
I am trying to run Google Map on a WordPress site. The code is running perfectly on this JSFIDDLE but when I take it to WordPress I am getting this error
Google Maps API warning: SensorNotRequired:
https://developers.google.com/maps/documentation/javascript/error-messages
I also tried this code
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
but the result is same.
Finally I tried to get a key from API and use it
<script src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxxx&callback=initMap"
async defer></script>
and now I am getting this error
Uncaught TypeError: window.initMap is not a function
can you please let me know why this is happening and how I can fix it?
Instead of:
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
Try:
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?v=3"></script>
From the Google Maps API documentation:
The sensor parameter is no longer required for the Google Maps
JavaScript API. It won't prevent the Google Maps JavaScript API from
working correctly, but we recommend that you remove the sensor
parameter from the script element.
We are hosting wordpress sites on wpengine. On this one site we are using gravity forms but for some reason it stopped working. All we get is a js error
Uncaught ReferenceError: gformInitSpinner is not defined (index):135
(anonymous function) (index):135
o jquery.min.js:2
p.fireWith jquery.min.js:2
e.extend.ready jquery.min.js:2
c.addEventListener.B
Now if I set up the site on my local machine it works perfectly fine. Has anyone come across this problem? Anyone got any idea why this is happening?
The most common cause of this issue is the gravityforms.js file being included down in the footer when it should be up in the header.
If you are embedding the form using the function call there is a second function call you should use to include the scripts and stylesheets in the header.php
// gravity_form_enqueue_scripts($form_id, $ajax);
gravity_form_enqueue_scripts(4, true);
https://docs.gravityforms.com/gravity_form_enqueue_scripts/
I had exactly the same problem, and managed to track it down to some theme code.
I was using the bones theme, which de-registers the default jQuery JS and adds its own using the Google CDN, like:
// we don't need the Wordpress jquery as we are loading our own version
add_action('wp_enqueue_scripts', 'stnic_remove_jquery');
function stnic_remove_jquery(){
if(!is_admin()) {
wp_deregister_script('jquery');
}
}
// loading modernizr and jquery, and reply script
function bones_scripts_and_styles() {
if (!is_admin()) {
wp_register_script( 'cdn-jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js', array(), '', false );
}
}
As you can see, it deregister's the default jquery script, and then adds its own cdn-jquery script, which is fine, apart from the fact that the Gravity forms scripts have a dependency on jquery and not cdn-jquery!
Because they can't see the default jquery script, they don't load, and it would seem that they fail silently, simply emitting this JavaScript error because said JavaScript is loaded without checking dependencies.
In any case, I fixed it by re-naming the bones register script to jquery, might not be the best way to fix this, but it works.
Alternatively, commenting out both pieces of code would also fix this (and leave the default Wordpress JS in there).
Not sure if other themes do this, but might be worth doing a search all in your theme for wp_deregister_script('jquery'); or at least switching to the default theme to see if you experience the same problem (that's how I pinpointed this).
OK I solved the problem. For some reason the file form_display.php was for some reason not up to date. So I simply pushed that one file to the server and this fixed it.
You can also add the GF`s necessary scripts manually to header.php (no actions with registering/deregistering jQuery needed!). Example:
<link rel='stylesheet' id='gforms_formsmain_css-css' href='/wp-content/plugins/gravityforms/css/formsmain.min.css' type='text/css' media='all' />
<link rel='stylesheet' id='gforms_ready_class_css-css' href='/wp-content/plugins/gravityforms/css/readyclass.min.css' type='text/css' media='all' />
<link rel='stylesheet' id='gforms_browsers_css-css' href='/wp-content/plugins/gravityforms/css/browsers.min.css' type='text/css' media='all' />
<script type='text/javascript' src='/wp-content/plugins/gravityforms/js/jquery.json-1.3.js'></script>
<script type='text/javascript' src='/wp-content/plugins/gravityforms/js/gravityforms.min.js'></script>
I just had this problem and, in my case, it was caused by CloudFlare RocketLoaderâ„¢.
After I disabled it, the form loaded with no problem.
Move Gravity forms` scripts to footer
add_filter("gform_init_scripts_footer", "init_scripts");
function init_scripts() {
return true;
}
under some conditions (that only god or google knows), this is not sufficient to provide the js tag...
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
... in order to load the Google V3 API. I must provide in these cases the following tag that loads the corresponding main.js:
<script type="text/javascript" src=" http://maps.gstatic.com/intl/pt_br/mapfiles/api-3/8/7/main.js"></script>
Because this file doesn't load automatically from the first script.
Do someone already experienced the same behaviour?
Probably that's because you don't specify api-version in script tag. This works fine for me:
<script src="http://maps.google.com/maps/api/js?v=3.5&sensor=false"></script>
I inserted the following code in a WordPress plugin:
wp_deregister_script('jquery');
wp_register_script('jquery', "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js");
wp_enqueue_script('jquery');
The following is echoed to the browser:
<script type='text/rocketscript' data-rocketsrc='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js?ver=3.3.1'></script>
Instead of:
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
I don't know what is happening. Perhaps wp_register_script() is supposed to work in this way. I also tested if any jQuery code worked on the client side but it didn't.
It is easy to fix.
You must change the following tag: <script type="text/javascript"></script>
add: data-cfasync="false"
example:
<script data-cfasync="false" type="text/javascript"></script>
Probably one of wordpress plugins is using CloudFlare.
https://support.cloudflare.com/hc/en-us/articles/200168056-What-does-Rocket-Loader-do-
Try disabling all the plugins and re-enabling them one by one to find out which one is causing this issue. It's not a problem actually.
Rocket Loader is not included in any WordPress plugins. You would have to disable Rocket Loader by going to: settings->CloudFlare settings (Performance Settings)->Rocket Loader->Toggle Off (this feature is optional and has to be turned on).
I was facing this issue with
WP Rocket plugin which was adding type='text/rocketscript' to the script tags.
Fixed it by adding
data-cfasync="false"
to the script tags.