View Full Version : Customized/parameterized radar HTML pages
jkish
04-09-2008, 09:27 AM
How are you offseting the radar page start position to hide the gray border?
BTW, I have built a radar html page with javascript that lets you specify the zoom level and which overlay to use (radar, clouds, temperature, etc) as parameters so you can have a single html page and just set various url parameters to display different looks via buttons like the demo shows in this thread (http://www.charmedquark.com/vb_forum/showthread.php?t=6458). I can post if anybody is interested.
jkish
04-09-2008, 05:27 PM
That sounds like a great enhancement.
I would like to see how you did it.
Here's the html I put together to parameterize the radar page:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var parameters = new Array();
function getParameters()
{
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++)
{
var pos = parms[i].indexOf('=');
if (pos > 0)
{
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
parameters[key] = val;
}
}
}
parameters['layer']='radar';
parameters['zoom']='8';
parameters['base']='h';
parameters['lat']='34.10744';
parameters['long']='-84.40876';
parameters['width']='720';
parameters['height']='540';
parameters['animate']='true';
getParameters();
</script>
</head>
<style type="text/css">
body
{
overflow: hidden;
padding: 0px;
margin: 0px;
}
</style>
<body>
<script>document.write('<object id ="radar" width="'+parameters['width']+'" height="'+parameters['height']+'" border="0" hspace="0"><embed src="http://image.weather.com/web/flash/FMMain.swf?lat='+parameters['lat']+'&long='+parameters['long']+'&initialWeatherLayerType='+parameters['layer']+'&viewPortWidth='+parameters['width']+'&viewPortHeight='+parameters['height']+'&initialZoomLevel='+parameters['zoom']+'&wxAnimateOnStart='+parameters['animate']+'&baseMap='+parameters['base']+'" width="'+parameters['width']+'" height="'+parameters['height']+'"></embed></object>')</script>
</body>
</html>
The possible parameters are:
layer - which type of weather layer to show (radar, sat, satrad, temp, dewpoint, rain)
zoom - zoom level
base - base layer to show (h, r)
lat - latitude
long - longitude
width - width of radar image
height - height of radar image
animate - whether to show animated or static radar
For example, you could set your url to something like radar.html?layer=rain&zoom=6 to show 24 hour rainfall totals at zoom level 6. All parameters that you don't specify default to the settings in the <head> section. You probably want to change the default locations (lat and long) to your own. I have buttons on my radar overlay that set Variable driver fields to remember the zoom and layer settings and update the web widget url as appropriate.
I've also figured out how to remove the gray border from the radar screen like Dean's picture above and I'll post a modified version of the html that does that with a "border" parameter that can be set to true/false when I get a chance to code it up.
Enjoy.
lpott6
04-10-2008, 06:23 AM
Here's the html I put together to parameterize the radar page:
The possible parameters are:
layer - which type of weather layer to show (radar, sat, satrad, temp, dewpoint, rain)
zoom - zoom level
base - base layer to show (h, r)
lat - latitude
long - longitude
width - width of radar image
height - height of radar image
animate - whether to show animated or static radar
For example, you could set your url to something like radar.html?layer=rain&zoom=6 to show 24 hour rainfall totals at zoom level 6. All parameters that you don't specify default to the settings in the <head> section. You probably want to change the default locations (lat and long) to your own. I have buttons on my radar overlay that set Variable driver fields to remember the zoom and layer settings and update the web widget url as appropriate.
I've also figured out how to remove the gray border from the radar screen like Dean's picture above and I'll post a modified version of the html that does that with a "border" parameter that can be set to true/false when I get a chance to code it up.
Enjoy.
Good stuff, thanks.
Only problem is that I am not very html literate, though I do see what you are doing. My question is how do I incorporate your script into CQC to control my weather display web widget?
If I can learn that, maybe I can learn how to strip the extra fluff from my IP camera viewer too. :-)
jkish
04-10-2008, 07:14 AM
Good stuff, thanks.
Only problem is that I am not very html literate, though I do see what you are doing. My question is how do I incorporate your script into CQC to control my weather display web widget?
If I can learn that, maybe I can learn how to strip the extra fluff from my IP camera viewer too. :-)
I'm not sure what you already have, but here are the steps if you were starting from scratch.
1) Copy the code from my post above and save in a file named radar.html. You may want to fix the latitude and longitude defaults in there.
2) Put that file in the HTMLRoot directory - that is probably something like C:/Program Files/CQC/CQCData/HTMLRoot/ on your machine.
3) Create a web widget and set the url to: file://C:/Program%20Files/CQC/CQCData/HTMLRoot/radar.html
4) Now you can customize the radar by adding parameters. For example, if you want to display temperatures, set the url to file://C:/Program%20Files/CQC/CQCData/HTMLRoot/radar.html?layer=temp. You can add multiple parameters by appending ¶meter=value to the first parameter which is separated from the first part of the url by a ? instead of an &.
5) You can build the parameters on the fly by appending the parameters based on some Variable driver fields if you want to have buttons to select the layers, zoom, etc
jkish
04-10-2008, 10:01 AM
I've also figured out how to remove the gray border from the radar screen like Dean's picture above and I'll post a modified version of the html that does that with a "border" parameter that can be set to true/false when I get a chance to code it up.
Ok, as promised, here's a version that allows you to remove the gray borders and also the gadgets (zoom control, key, page load progress, etc) from the page:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var parameters = new Array();
var width = 0;
var height = 0;
var viewportwidth = 0;
var viewportheight = 0;
var xoffset = 0;
var yoffset = 0;
var xmodify = 0;
var ymodify = 0;
function getParameters()
{
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++)
{
var pos = parms[i].indexOf('=');
if (pos > 0)
{
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
parameters[key] = val;
}
}
}
parameters['layer']='radar';
parameters['zoom']='8';
parameters['base']='h';
parameters['lat']='34.10744';
parameters['long']='-84.40876';
parameters['width']='720';
parameters['height']='540';
parameters['animate']='true';
parameters['border']='false';
parameters['gadgets']='false';
getParameters();
width = parseInt(parameters['width']);
height = parseInt(parameters['height']);
viewportwidth = width;
viewportheight = height;
if(parameters['border'] =='false')
{
xmodify = 13;
ymodify = 13;
}
if(parameters['gadgets'] == 'false')
{
xmodify = 43;
ymodify = 82;
}
width = width+xmodify;
height = height+ymodify
viewportwidth = width+xmodify;
viewportheight = height+ymodify;
xoffset = -xmodify;
yoffset = -ymodify;
</script>
</head>
<style type="text/css">
body
{
overflow: hidden;
padding: 0px;
margin: 0px;
}
</style>
<body>
<script>document.write('<div style="position:relative;left:'+xoffset+';top:'+yoffset+' ;"><object id ="radar" width="'+width+'" height="'+height+'" border="0" hspace="0"><embed src="http://image.weather.com/web/flash/FMMain.swf?lat='+parameters['lat']+'&long='+parameters['long']+'&initialWeatherLayerType='+parameters['layer']+'&viewPortWidth='+viewportwidth+'&viewPortHeight='+viewportheight+'&initialZoomLevel='+parameters['zoom']+'&wxAnimateOnStart='+parameters['animate']+'&baseMap='+parameters['base']+'" width="'+width+'" height="'+height+'"></embed></object></div>')</script>
</body>
</html>
There are two new parameters that can be set: border and gadgets. The possible values are:
border=false, gadgets=false - no borders or gadgets displayed (default)
border=false, gadgets=true - gadgets shown without borders
border=true, gadgets=true - both borders and gadgets shown
You can't have borders without gadgets, but that doesn't seem like a nice choice anyway.
Enjoy.
lpott6
04-10-2008, 10:39 AM
I'm not sure what you already have, but here are the steps if you were starting from scratch.
1) Copy the code from my post above and save in a file named radar.html. You may want to fix the latitude and longitude defaults in there.
2) Put that file in the HTMLRoot directory - that is probably something like C:/Program Files/CQC/CQCData/HTMLRoot/ on your machine.
3) Create a web widget and set the url to: file://C:/Program%20Files/CQC/CQCData/HTMLRoot/radar.html
4) Now you can customize the radar by adding parameters. For example, if you want to display temperatures, set the url to file://C:/Program%20Files/CQC/CQCData/HTMLRoot/radar.html?layer=temp. You can add multiple parameters by appending ¶meter=value to the first parameter which is separated from the first part of the url by a ? instead of an &.
5) You can build the parameters on the fly by appending the parameters based on some Variable driver fields if you want to have buttons to select the layers, zoom, etc
That's what I needed. I'll give that a try tonight.
Thanks for the info and your patience.
sic0048
04-10-2008, 03:50 PM
Great stuff. Thanks for putting this together.
gacevich
04-24-2008, 01:53 AM
jkish, this is awesome, thanks. it would have taken forever to write this html, if at all.
jkish
04-24-2008, 10:46 AM
jkish, this is awesome, thanks. it would have taken forever to write this html, if at all.
Glad to be able to contribute something.
stinggray
05-15-2011, 07:19 AM
Why would the radar work on my sever and some of my clients but not on others clients? This is where the html file is located and the URL I inserted in the widget \\MLSERVER\SharedDocs\radar.html. I also tried to put html file local and changed the URL to match.
jkish
05-15-2011, 07:28 AM
Why would the radar work on my sever and some of my clients but not on others clients? This is where the html file is located and the URL I inserted in the widget \\MLSERVER\SharedDocs\radar.html. I also tried to put html file local and changed the URL to match.
Is Flash installed everywhere?
stinggray
05-15-2011, 09:38 AM
It is installed on the one that's not working.
Dean Roddey
05-15-2011, 10:03 AM
When you say doesn't work, do you mean the page comes up but the contents is not right, or the page isn't working at all?
stinggray
05-15-2011, 10:14 AM
At first it comes up white then a second later it turns black and the radar never shows up.
jkish
05-15-2011, 10:55 AM
At first it comes up white then a second later it turns black and the radar never shows up.
I assume it does the same thing in the browser (IE) and on the template page?
What version of IE is running on each system?
jkish
05-15-2011, 10:56 AM
It is installed on the one that's not working.
You might try a flash reinstall if you have not already.
I once had a situation where Flash got installed in some funky way and things didn't work until I reinstalled.
stinggray
05-15-2011, 11:26 AM
I assume it does the same thing in the browser (IE) and on the template page?
What version of IE is running on each system?
I'm using Foxfire and it opens up fine with that. Dose CQC use IE? It has IE 6. I'm updating it to 8 now.
Dean Roddey
05-15-2011, 11:42 AM
I'm using Foxfire and it opens up fine with that. Dose CQC use IE? It has IE 6. I'm updating it to 8 now.
That may be the issue. The version of Flash you have may not work so well in that old a version of IE.
jkish
05-15-2011, 11:59 AM
I'm using Foxfire and it opens up fine with that. Dose CQC use IE? It has IE 6. I'm updating it to 8 now.
Yes, CQC uses IE.
stinggray
05-15-2011, 12:03 PM
I updated IE and Flash and that did it.
The PC is a all in one touch screen that I only use for CQC as a client so I never updated anything on it.
Thanks Guys
vBulletin v3.5.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.