none
TileLayer Weather Overlay Question RRS feed

  • Question

  • Hello,

    I am trying to add a weather overlay from WeatherBug. I am struggling to find sample code. Everyone seems to just reference: http://msdn.microsoft.com/en-us/library/bb259689.aspx.

    Here is my code at present. I have yet to tackle the situation of calculating the QuadKey. My theory was to try and start simple by hard-coding the first four tiles for the introductory zoomed-out view, which contains four tiles according to the site above.

    My code looks as follows:

                MapTileLayer myWeather = new MapTileLayer();
                myWeather.TileSource = "http://i.wxbug.net/GEO/Bing/Temperature/GetTile_v2.aspx?as=0&c=0&fq=0&qk=0&mw=1&ds=0&stl=0&api_key=XXXX";
                MapTileLayer myWeather1 = new MapTileLayer();
                myWeather1.TileSource = "http://i.wxbug.net/GEO/Bing/Temperature/GetTile_v2.aspx?as=0&c=0&fq=0&qk=1&mw=1&ds=0&stl=0&api_key=XXXX";
                MapTileLayer myWeather2 = new MapTileLayer();
                myWeather2.TileSource = "http://i.wxbug.net/GEO/Bing/Temperature/GetTile_v2.aspx?as=0&c=0&fq=0&qk=2&mw=1&ds=0&stl=0&api_key=XXXX";
                MapTileLayer myWeather3 = new MapTileLayer();
                myWeather3.TileSource = "http://i.wxbug.net/GEO/Bing/Temperature/GetTile_v2.aspx?as=0&c=0&fq=0&qk=3&mw=1&ds=0&stl=0&api_key=XXXX";

                myMap.TileLayers.Add(myWeather);
                myMap.TileLayers.Add(myWeather1);
                myMap.TileLayers.Add(myWeather2);
                myMap.TileLayers.Add(myWeather3);

    Rather than adding all four tiles, it just adds the North America tile and repeats it four times. That works great for North America, and not so great for Europe which as a North America-shaped overlay over it. Even though I use four separate QuadKeys (0,1,2,3), it only seems to add the first and ignore my additional TileLayers.Add statements.

    Any ideas?

    Thanks,
    Joseph Irvine

    Friday, October 26, 2012 11:36 PM

Answers

  • Once you've got your data tiled then adding a tile layer is easy:

    MapTileLayer myWeather = new MapTileLayer();
    myWeather.TileSource = "http://i.wxbug.net/GEO/Bing/Temperature/GetTile_v2.aspx?tileId={quadkey}";
    myMap.TileLayers.Add(myWeather);

    This will substitute the tile quadkey when making the request so each tile can get a unique image.
    Monday, October 29, 2012 5:05 PM

All replies

  • The above code will composite the 4 tiles in every tile on the planet which is not what you want. If your data does not use a quadkey for addressing you can use the GetTileUri callback to provide the url to fetch per x, y, and level of detail.

    You do however need to need to understand the tile system to be able to work with tile layers. I recommend spending a little more time reading and rereading the reference.

    Saturday, October 27, 2012 12:20 AM
  • Once I have the QuadKey system working, how do I uniquely add each tile such that there is no repetition? You indicate that the method I am using is going to composite the 4 tiles in every tile on the planet. I can see as much from my experimentation.

    How do I specify a one-to-one relationship for applying an image to a single tile, preventing any repeating? Even when I only specify one Map.Children.Add statement, the image is still repeated in each tile. What is the method used to lock the tile to the specific position it needs to reside in only?

    Thank you!

    Monday, October 29, 2012 2:53 PM
  • Once you've got your data tiled then adding a tile layer is easy:

    MapTileLayer myWeather = new MapTileLayer();
    myWeather.TileSource = "http://i.wxbug.net/GEO/Bing/Temperature/GetTile_v2.aspx?tileId={quadkey}";
    myMap.TileLayers.Add(myWeather);

    This will substitute the tile quadkey when making the request so each tile can get a unique image.
    Monday, October 29, 2012 5:05 PM
  • Fantastic, that worked very well; thank you!

    Joseph Irvine

    Monday, October 29, 2012 5:47 PM