Dan Sewell
Dan Sewell

Reputation: 1290

Bing maps silverlight control in c#

Wondering if you could help me on this one.. Im trying to control my map with this c# code below. But for some reason its not doing anything when I call this method, and im not quite sure why?! Not sure if im using the .Equals properly?

C#

private void NW_zoom(object sender, ManipulationStartedEventArgs e)
    {
        GeoCoordinate abc = new GeoCoordinate(51.510, -0.1151);
        Map.CenterProperty.Equals(abc);

        var zoom = 12;
        Map.ZoomLevelProperty.Equals(zoom);
     }

XMAL map control:

 <maps:Map ZoomLevel="10" Mode="Road" Margin="0,0,0,54"   ZoomBarVisibility="Visible" ScaleVisibility="Visible" CredentialsProvider="xxxxxxx" Grid.Row="1">
       <maps:Map.Center>
            <device:GeoCoordinate Latitude="51.510669" Longitude="-0.11512800"/>
        </maps:Map.Center> 
        <maps:MapLayer  x:Name="QuakeLayer" Height="726" Width="477" /> 
    </maps:Map>

Upvotes: 2

Views: 1562

Answers (4)

T.Ho
T.Ho

Reputation: 1190

ZoomLevelProperty is a property, so if you want to set it in code behind, you need to use the method SetValue of the map object.

map.SetView(Map.ZoomLevelProperty, zoom);

Upvotes: 0

Blounty
Blounty

Reputation: 3358

I think what you are looking to accomplish is done by the following:

Map.SetView(new Location(51.510, -0.1151), 12);

Edit --

You were correct, the code above is not supported for the WP7 bing Map control

this should work for you:

map1.SetView(new System.Device.Location.GeoCoordinate(51.510, -0.1151), 12.00);

Upvotes: 1

BrokenGlass
BrokenGlass

Reputation: 160852

Not having worked with this control I can't answer your question for sure but

Map.CenterProperty.Equals(abc);

only performs a boolean comparison, I'm pretty sure you want to set some property instead as in

Map.CenterPropert= abc;

(same goes for the other property)

Upvotes: 1

Albin Sunnanbo
Albin Sunnanbo

Reputation: 47038

Equals compares values, it does not set them.

Try

Map.CenterProperty = abc;

and

Map.ZoomLevelProperty = zoom;

Upvotes: 1

Related Questions