OneDrive Developer Center (redirect)

Looking for the Live SDK?

OneDrive logo

The Live SDK 5.6 is now available

Find it on the OneDrive Dev Center, the new place to find samples, documentation, and other resources for integrating OneDrive into your app.
Choose your download

If you're using previous versions of the Live SDK, the Live SDK 5.5 reference is still available.

 none
Get appropriate zoom level of the map from the pins that are going to be shown on the map

    Question

  • Hi -

    Here's my issue:  I have a page that contains map and from there the user can choose some pins and then run some sort of report on it.  The report contains an image of the map along with the pins being shown.  The issue that I am running into is that, if I set a zoom level to a fixed number (i.e. 9) than if the pins were selected pretty close to each other, than all the pins look like clustered together and it gets hard to distinguish between pins.  And if the selected pins were far apart from each other than some of the pins don't get shown in the map.  So, my question is, how to set the zoom level based on the pins that are going to be on the image?

    Here's my code:

    ProdImageryService.MapUriRequest mapUriRequest = new ProdImageryService.MapUriRequest();
    
    // Set credentials using a valid Virtual Earth Token
    mapUriRequest.Credentials = new ProdImageryService.Credentials();
    mapUriRequest.Credentials.Token = "Bing Maps Key";
    
    // Set the location of the requested image
    //This will set the center of the map
    mapUriRequest.Center = new ProdImageryService.Location();
    mapUriRequest.Center.Latitude = Convert.ToDouble(dtPropertyList.Rows[0]["Latitude"].ToString());
    mapUriRequest.Center.Longitude = Convert.ToDouble(dtPropertyList.Rows[0]["Longitude"].ToString());
    
    int pinCount = dtPropertyList.Rows.Count;
    
    ProdImageryService.Pushpin[] myPins = new ProdImageryService.Pushpin[pinCount];
    //This will populate the list of pushpins based on their location from the Datatable, the location can be close to each other or they can be far apart
    for (int i = 0; i <= pinCount - 1; i++)
    {
       myPins[i] = new Pushpin();
       myPins[i].IconStyle = "13";
       myPins[i].Label = dtPropertyList.Rows[i]   ["NumberedProperties"].ToString();
       myPins[i].Location = new Location();
       myPins[i].Location.Latitude = Convert.ToDouble   (dtPropertyList.Rows[i]["Latitude"]);
       myPins[i].Location.Longitude = Convert.ToDouble(dtPropertyList.Rows[i]["Longitude"]);
    }
    mapUriRequest.Pushpins = myPins;
    
    ProdImageryService.MapUriOptions mapUriOptions = new ProdImageryService.MapUriOptions();
    mapUriOptions.Style = ProdImageryService.MapStyle.Road;
    
    //I want this to be set based on the pins that are going to be on the map
    mapUriOptions.ZoomLevel = 9;
    
    mapUriOptions.PreventIconCollision = true;
    
    mapUriOptions.ImageSize = new ProdImageryService.SizeOfint();
    mapUriOptions.ImageSize.Height = 400;
    mapUriOptions.ImageSize.Width = 900;
    mapUriRequest.Options = mapUriOptions;
    
    ProdImageryService.ImageryServiceClient imageryService = new ProdImageryService.ImageryServiceClient();
    ProdImageryService.MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest);
    mapUri = mapUriResponse.Uri;

    Thanks

    Monday, February 27, 2012 7:52 PM

Answers

  • So, I was able to resolve the issue by just commenting out the "mapUriOptions.ZoomLevel = 9;" line.  Duh.....
    • Marked as answer by Desi Gunda Monday, February 27, 2012 8:39 PM
    Monday, February 27, 2012 8:39 PM
OneDrive Developer Center (redirect)

Looking for the Live SDK?

OneDrive logo

The Live SDK 5.6 is now available

Find it on the OneDrive Dev Center, the new place to find samples, documentation, and other resources for integrating OneDrive into your app.
Choose your download

If you're using previous versions of the Live SDK, the Live SDK 5.5 reference is still available.