Select to view content in your preferred language

weather

4286
8
Jump to solution
01-15-2013 11:34 AM
BillShockley
Deactivated User
Flex has a nice weather layer that can be added to a viewer to show the latest weather in Motion.  Is there one available for the javascript API?

Thanks,
0 Kudos
1 Solution

Accepted Solutions
MattDriscoll
Esri Contributor
Are you looking for Radar?

I found something on GitHub and modified it a litte and converted to AMD.

http://driskull.github.com/esri-weatherunderground/
https://github.com/driskull/esri-weatherunderground

Originally came from this: https://github.com/brandoncopeland/esri-weatherunderground

This is just a simple example and could be expanded. I believe there's other API's that can do radar motion as well.

View solution in original post

0 Kudos
8 Replies
MattDriscoll
Esri Contributor
Are you looking for Radar?

I found something on GitHub and modified it a litte and converted to AMD.

http://driskull.github.com/esri-weatherunderground/
https://github.com/driskull/esri-weatherunderground

Originally came from this: https://github.com/brandoncopeland/esri-weatherunderground

This is just a simple example and could be expanded. I believe there's other API's that can do radar motion as well.
0 Kudos
BillShockley
Deactivated User
Are you looking for Radar?

I found something on GitHub and modified it a litte and converted to AMD.

http://driskull.github.com/esri-weatherunderground/
https://github.com/driskull/esri-weatherunderground

Originally came from this: https://github.com/brandoncopeland/esri-weatherunderground

This is just a simple example and could be expanded. I believe there's other API's that can do radar motion as well.


OK, if I understand this correctly I will need an api key from http://www.wunderground.com correct to get this to work correctly?
0 Kudos
MattDriscoll
Esri Contributor
OK, if I understand this correctly I will need an api key from http://www.wunderground.com correct to get this to work correctly?


Yep. correct.
0 Kudos
KevinMacLeod1
Frequent Contributor
Yep. correct.


Matt that's great! Thank you!

I downloaded the file, and placed it in my javascript folder in my Basic Viewer template project site. I then added the following to my index.html file:

                <script type="text/javascript" src="javascript/WURadarLayer.js"></script>

I saved this file as a plain file with a .js extension and didn't modify it. I signed up for an API key (###) which I then put in where you showed us in the ReadMe. I put the following line in layout.js at the top ....

require([
    "dojo/ready",
    "dojo/_base/connect",
    "modules/WURadarLayer"

]);


(I guess this new Dojo syntax is a bit different from the past, with things like   dojo.require("esri.dijit.Popup");  )
I then put .....

        var wuradar = new WURadarLayer('#####');


into my list of layers and put it in my layer loading list...

 map.addLayers([wuradar,  more layers...)


But I got an error "0x800a1391 - JavaScript runtime error: 'WURadarLayer' is undefined" from Vis Studio / IE.

So did I declare right? I am just beginning at Javascript thank you for any help. This was exactly what I was looking for, a radar loop! Thanks to you both!

And, does anyone know of an example using the standard RIDGE Radar? http://atlas.resources.ca.gov/ArcGIS/rest/services/Atmosphere_Climate/RIDGE_Precip_Radar/MapServer
That may also be helpful as the Wunderground API limits the amount of use.
0 Kudos
BillShockley
Deactivated User
Matt that's great! Thank you!

I downloaded the file, and placed it in my javascript folder in my Basic Viewer template project site. I then added the following to my index.html file:

                <script type="text/javascript" src="javascript/WURadarLayer.js"></script>

I saved this file as a plain file with a .js extension and didn't modify it. I signed up for an API key (###) which I then put in where you showed us in the ReadMe. I put the following line in layout.js at the top ....

require([
    "dojo/ready",
    "dojo/_base/connect",
    "modules/WURadarLayer"

]);


(I guess this new Dojo syntax is a bit different from the past, with things like   dojo.require("esri.dijit.Popup");  )
I then put .....

        var wuradar = new WURadarLayer('#####');


into my list of layers and put it in my layer loading list...

 map.addLayers([wuradar,  more layers...)


But I got an error "0x800a1391 - JavaScript runtime error: 'WURadarLayer' is undefined" from Vis Studio / IE.

So did I declare right? I am just beginning at Javascript thank you for any help. This was exactly what I was looking for, a radar loop! Thanks to you both!

And, does anyone know of an example using the standard RIDGE Radar? http://atlas.resources.ca.gov/ArcGIS/rest/services/Atmosphere_Climate/RIDGE_Precip_Radar/MapServer
That may also be helpful as the Wunderground API limits the amount of use.


I think I had the same error and the problem I found was that the .js file was in the wrong place and it could be read.  I was using firebug to check the error.
0 Kudos
KevinMacLeod1
Frequent Contributor
I think I had the same error and the problem I found was that the .js file was in the wrong place and it could be read.  I was using firebug to check the error.


Thanks Bill. You are right, firebug shows me it looks for WURadar at "NetworkError: 404 Not Found - http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/dojo/modules/WURadarLayer.js".

How did you get yours working, as an AMD module or inline code?

The new code by Matt Driscoll is AMD and a module, from my understanding. Our site calls the ESRI edge server for the API and thus also Dojo. So the Dojo is a hosted CDN (wherever ESRI points to).

I am just beginning to learn Dojo.... There is documentation on the Dojo site regarding use of a CDN while using local modules. Furthermore, since I am still developing the site it does not have a final URL yet, it just runs out of the local webserver folder Visual Studio 2012 generates on the fly. However there is a way to "detect" the current URL with Javascript, then tack on something additional, to tell it to load a local module, in dojoConfig, even though the library itself is CDN hosted.

http://dojotoolkit.org/documentation/tutorials/1.8/dojo_config/ has this exact exdample of a local module with Google CDN of Dojo Lib loading a local module "demo'.

If you need to detect the local URL the Javascript syntax location.pathname.replace(/\/[^/]+$/, "") is supposed to find current URL so you can append soemthing e.g. "+ /javascript" to get the path to our local module. For example, in my project structure, which is the Basic Viewer template, I have a javascript folder. (ProjectName/javascript which contains layout.js as well as WURadar.js).  So I put the appropriate code into dojoConfig which we made a separate file, preLoad.js. I put it above the ESRI API (and tried it below, every which place) in the index.html.

So this is our preLoad.js

var dojoConfig = {
    parseOnLoad: true,
    packages: [{
        name: "esriTemplate",
        location: location.pathname.replace(/\/[^/]+$/, '')
    },
    
    {name: "WURadarLayer.js",
    location: location.pathname.replace(/\/[^/]+$/, "") + '/javascript/WURadarLayer.js'
    },

    {
        name: "utilities",
        location: location.pathname.replace(/\/[^/]+$/, '') + '/javascript'
    }]
};


I also tried putting it in the root of the project folder and referring to just / above.

In my layout.js I tried both the old 1.6 require syntax dojo.require("modules.WURadarLayer"); as well as the new AMD syntax, no luck.


It always says 'WURadar is undefined'. When I tried inline code, using brandoncopeland's original code as well as Matt's, I got other weird syntax errors. While keeping it modular would be best, as Matt designed, if anyone has this working via inline code in layout.js that works, I'd be glad if you could share that as well. Or could you share the steps you took to get it working Bill, as a module?


Other documentation I reviewed: http://dojotoolkit.org/reference-guide/1.8/loader/amd.html  and   http://dojotoolkit.org/reference-guide/1.7/quickstart/cross-domain.html
0 Kudos
KevinMacLeod1
Frequent Contributor
var radarloop = new modules.WURadarLayer('###');

The namespace is modules and that is how it must be called, per above. Now it works nicely.
0 Kudos
MattDriscoll
Esri Contributor
var radarloop = new modules.WURadarLayer('###');

The namespace is modules and that is how it must be called, per above. Now it works nicely.


Yeah, the example I used was using Dojo AMD format which is a little different. glad you got it working!
0 Kudos