Map without nav control?

Nov 30, 2008 at 7:09 PM
It would be nice to be able to use this control for small maps -- small enough that the default navigation control takes too much space.

Is it possible to create a map without a navigation control? Or set the visibility to collapsed?
Can the initial state of the navigation control be in its retracted state?
Developer
Dec 1, 2008 at 8:11 AM
I made a small demo for you

it just has a plain map, nothing else

the map control is Templated, so you can tune-up the look in Blend, if you know how to edit control templates in Blend

this sample does not use the Virtual Earth maps, you would need to look and see how the "Token" is passed into the Silverlight application from the DeepEarth.Prototype project, if you need a hand with this make a post and I will make another little demo for the Virtual Earth maps with not controls...

in this demo you will see in the Page.cs file of the Silverlight application how I add the "TileLayer" to the map control, it is just a single line of code, and I have placed a couple other examples in there and commented them out so you can just swap them aroud to see the different maps display.

http://deepearth.dotnetnoobie.com/PlainMapDeepEarth.zip
Developer
Dec 1, 2008 at 8:38 AM
DeepEarth Logo

I also noticed that when I tried to make the control a set size the map did not display, it only seemed to display a map if the control was taking the complete screen, I will try to look and see if I can find why this happens, else I will ask the other guys to see if they know why it may be happening
Coordinator
Dec 1, 2008 at 10:18 AM

What happens if you try adding some element for layout that contains the map (e.g. Canvas or Grid)?

For example:

<Grid>

<de:Map Width=”400” Height=”400” />

</Grid>

Developer
Dec 1, 2008 at 11:20 AM
I tried setting the size in the template/style in severial locations, some work, but zooming etc does not work correctly

this is the best way I found so far

<Grid x:Name="LayoutRoot">
    
<Canvas Width="400" Height="400"> 
        <DeepEarth:Map x:Name="map" Style="{StaticResource MapStyle}"/> 
    </Canvas>
</Grid

But this also does not zoom correctly

you seem to have to use a Canvas or the map does not show... e.g. if you use a grid 

Developer
Dec 1, 2008 at 11:34 AM
Just uploaded the sample plain map again, I forgot to link the Silvelight project to the website

it seems the zoom etc is all based on the size of the screen, not the control containing it, thus you make the canvas smaller holding the map control zooms incorrectly
Dec 2, 2008 at 2:03 AM
Thank you for the sample code -- the templating code is an eye-opener.  I placed the map control in a canvas and I got it to display, but the zooming is off as you already noticed.  When using ctrl-drag to draw a zoom rectangle, the rect appears but is offset from the top-left of the canvas by the distance the canvas is from the top-left of the screen. 

Another thing you might be interested to know, I am displaying the map on a tab in a "dialog box".  The map is on the second tab, so it is not immediately visible.  When I switch to the tab with the map, it does not display, probably as you would expect. I worked around that by calling SetViewCenter once when the tab is displayed and then again one second later using a timer. It's kinda cludgy, so if you know of another way to do it, let me know.

Thanks!
John
Coordinator
Dec 2, 2008 at 3:08 AM
The zooming issue should be fixed with the latest check-in.  Mouse position was off by in a couple of spots due to using args.GetPostion(null) vs. args.GetPosition(map).  Note the former works correctly only in full screen mode, the latter should work in all cases.