×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    2

    Render a Map to an image

    Hello everyone,
    I need to get an image from a Map (Windows Phone 8), to use it for a live tile. This is what I have so far:
    Code:
    const int imgSize = 210;
    Map tempMap = new Map { Width = imgSize, Height = imgSize };
    // ... adding some layers, setting the view
    Size size = new Size(imgSize, imgSize);
    tempMap.Measure(size);
    tempMap.Arrange(new Rect(new Point(0, 0), size));
    tempMap.UpdateLayout();
    
    WriteableBitmap bmp = new WriteableBitmap(imgSize, imgSize);
    bmp.Render(tempMap, null);
    bmp.Invalidate();
    IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
    string filename = "/Shared/ShellContent/" + /* ... file name */ ".jpg";
    using (IsolatedStorageFileStream stream = store.OpenFile(filename, FileMode.OpenOrCreate))
        bmp.SaveJpeg(stream, imgSize, imgSize, 0, 100);
    
    tile.Update(new FlipTileData
    {
        // ... set other properties
        BackgroundImage = new Uri("isostore:" + filename, UriKind.Absolute)
    });
    As you can see, the map that I render is never part of the visual tree. I gather from several places (stackoverflow, msdn) that this should not be a problem; unfortuately, the image is simply black.
    Is something wrong with my code, or might this be a bug with the Nokia Map?

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Render a Map to an image

    I don't think that the WP8 API would be designed for the map to be saved into image. anyway, there is HERE API for the purpose, its called Map Image API: http://developer.here.com/rest_api

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    2

    Re: Render a Map to an image

    Will this work for not-Nokia phones as well? I don't want my app to be Nokia-exclusive...

    EDIT: I also asked on stackoverflow, link
    Last edited by lucas.werkmeister; 2013-04-12 at 13:35.

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Render a Map to an image

    it would work, it is basically HTTP query, thus not really even OS specific.

Similar Threads

  1. How to render an image in a xaml & direct 3d project
    By small2 in forum Windows Phone General
    Replies: 0
    Last Post: 2013-03-22, 02:56
  2. how to synchronize WinRT render and directX render
    By xlazom00 in forum Windows Phone General
    Replies: 3
    Last Post: 2013-03-08, 12:06
  3. Web page render
    By nupurpanwar in forum Qt
    Replies: 3
    Last Post: 2010-07-23, 12:58
  4. Render transforms
    By stuart_george in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2010-05-21, 11:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×