Can I caching google maps in Windows Phone? I use GoogleTileSource:
<my:MapTileLayer Name="street" Margin="0,0,0,32" Height="800" Width="433">
<my:MapTileLayer.TileSources>
<GoogleTileSource:GoogleTile TileTypes="Street"/>
</my:MapTileLayer.TileSources>
</my:MapTileLayer>
It’s possible?
Thank in advance.
UPDATE
XAML code:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<my:Map Height="756" HorizontalAlignment="Left" Margin="12,6,0,0" Name="googlemap"
CredentialsProvider="AqayajnZU8FSfDGL8jpK5zMKAHmUL27Uqxv_OnpQzJQOI2PoQyxcG7dlR6_g4WWo"
CopyrightVisibility="Collapsed" LogoVisibility="Collapsed"
ScaleVisibility="Visible" VerticalAlignment="Top" Width="438" >
<my:Map.Mode>
<MSPCMCore:MercatorMode/>
</my:Map.Mode>
<my:MapTileLayer Name="street" Margin="0,0,0,32" Height="800" Width="433">
<my:MapTileLayer.TileSources>
<GoogleTileSource:GoogleTile TileTypes="Street"/>
</my:MapTileLayer.TileSources>
</my:MapTileLayer>
<my:MapLayer x:Name="PopupLayer">
<Canvas x:Name="ContentPopup" Visibility="Collapsed">
<Rectangle x:Name="ContentPopupRectangle" Fill="Black"
Opacity="0.6" Canvas.Left="0" Canvas.Top="0"
Height="100" Width="200"/>
<StackPanel Canvas.Left="20" Canvas.Top="10">
<TextBlock x:Name="ContentPopupNickname" FontSize="24" FontWeight="Bold" TextWrapping="Wrap" Width="200"/>
<TextBlock x:Name="ContentPopupLocation" FontSize="16" FontWeight="Bold" TextWrapping="Wrap" Width="200"/>
<TextBlock x:Name="ContentPopupAge" FontSize="16" FontWeight="Bold" TextWrapping="Wrap" Width="200"/>
</StackPanel>
</Canvas>
</my:MapLayer>
</my:Map>
</Grid>
So, cs code:
public enum GoogleTileTypes
{
Hybrid,
Physical,
Street,
Satellite,
WaterOverlay
}
public class GoogleTile : Microsoft.Phone.Controls.Maps.TileSource
{
private int _server;
private char _mapmode;
private GoogleTileTypes _tiletypes;
public GoogleTileTypes TileTypes
{
get { return _tiletypes; }
set
{
_tiletypes = value;
MapMode = MapModeConverter(value);
}
}
public char MapMode
{
get { return _mapmode; }
set { _mapmode = value; }
}
public int Server
{
get { return _server; }
set { _server = value; }
}
public GoogleTile()
{
UriFormat = @"http://mt{0}.google.com/vt/lyrs={1}&z={2}&x={3}&y={4}";
Server = 0;
}
public override Uri GetUri(int x, int y, int zoomLevel)
{
if (zoomLevel > 0)
{
var Url = string.Format(UriFormat, Server, MapMode, zoomLevel, x, y);
return new Uri(Url);
}
return null;
}
private char MapModeConverter(GoogleTileTypes tiletype)
{
switch (tiletype)
{
case GoogleTileTypes.Hybrid:
{
return 'y';
}
case GoogleTileTypes.Physical:
{
return 't';
}
case GoogleTileTypes.Satellite:
{
return 's';
}
case GoogleTileTypes.Street:
{
return 'm';
}
case GoogleTileTypes.WaterOverlay:
{
return 'r';
}
}
return ' ';
}
}
The standard TileSource doesn’t allow you any control over the downloading of the tile images.
If you want to add your own caching you’ll have to add another Layer to the map and then download the images and load them into the extra layer in the correct position yourself. It’s not fun but it can be done.