Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 在Windows Phone中缓存谷歌地图?_Windows Phone 7_Google Maps_Caching - Fatal编程技术网

Windows phone 7 在Windows Phone中缓存谷歌地图?

Windows phone 7 在Windows Phone中缓存谷歌地图?,windows-phone-7,google-maps,caching,Windows Phone 7,Google Maps,Caching,我可以在Windows Phone中缓存谷歌地图吗?我使用的是谷歌资源: <my:MapTileLayer Name="street" Margin="0,0,0,32" Height="800" Width="433"> <my:MapTileLayer.TileSources> <GoogleTileSource:GoogleTile TileTypes="Street"/> </my:MapTileLaye

我可以在Windows Phone中缓存谷歌地图吗?我使用的是谷歌资源:

<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>

所以,
cs
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>
    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 ' ';
        }
    }

标准TileSource不允许您对tile图像的下载进行任何控制


如果您想添加自己的缓存,您必须向地图添加另一层,然后下载图像并将其加载到位于正确位置的额外层中。这并不有趣,但可以做到。

我没有尝试过,直到我不知道如何缓存地图,使用什么技术。你是说我在哪里使用谷歌资源?在更新中,我显示完整的代码。顺便说一下,如果你知道如何缓存Bing图,你可以考虑这个情况。