WM load tiles optimaze suggestion

May 7, 2010 at 8:53 AM
Edited May 7, 2010 at 8:56 AM

Hi All,

When i run this great project on DOPOD D600, i found it was very slowly by GPRS.

I studied the core.FindTilesAround(ref List<Point> list) , it will load 9 tiles from server for mobile side.

And acturlly we can only load 4 tiles when we load the map, some suggestions from me.

But i got some problems with the map move, which need to optimize the GMapControl.OnMouseMove(MouseEventArgs e).

Could Radioman gives some comment on this? Thanks in advance!

 

 

      void FindTilesAround(ref List<Point> list)
      {
         list.Clear();
         //1.first add the current tile;Sterning
         list.Add(centerTileXYLocation);

#if PocketPC
         //2.get the TopLeft Pixel Point of current Tile.         
         Point centerTileXYPixel = Projection.FromTileXYToPixel(centerTileXYLocation);
         Point centerTileXY = centerTileXYLocation; 

         //3.Center Pixex of Control.Compare it with CenterTileXYPixel to get just 4 Tiles for mobile. 
         Point centerPixel = new Point(Width / 2 - renderOffset.X, Height / 2 - renderOffset.Y);
         if ((centerPixel.X - centerTileXYPixel.X) > projection.TileSize.Width/2)
          {
            centerTileXY.X +=1;

          }

         if ((centerPixel.Y - centerTileXYPixel.Y) > projection.TileSize.Height/2)
          {
              centerTileXY.Y += 1;

          }

          if (!list.Contains(centerTileXY))
          {
              list.Add(centerTileXY);
          }

          Point p = centerTileXY;
          p.Y -= 1;

          if (!list.Contains(p))
          {
              list.Add(p);
          }

          p = centerTileXY;
          p.X -= 1;

          if (!list.Contains(p))
          {
              list.Add(p);
          }


          p = centerTileXY;
          p.X -= 1;
          p.Y -= 1;

          if (!list.Contains(p))
          {
              list.Add(p);
          }

#else
         //start - old method, which will load 16 tiles for PC and 9 tiles for Mobile
          for (int i = -sizeOfMapArea.Width; i <= sizeOfMapArea.Width; i++)
          {
              for (int j = -sizeOfMapArea.Height; j <= sizeOfMapArea.Height; j++)
              {
                  Point p = centerTileXYLocation;

                  p.X += i;
                  p.Y += j;


                  if (p.X >= minOfTiles.Width && p.Y >= minOfTiles.Height && p.X <= maxOfTiles.Width && p.Y <= maxOfTiles.Height)
                  {
                      if (!list.Contains(p))
                      {
                          list.Add(p);

                      }
                  }
              }
          }
          //end - old method, which will load 16 tiles for PC and 9 tiles for Mobile

#endif
         if(GMaps.Instance.ShuffleTilesOnLoad)
         {
            Stuff.Shuffle<Point>(list);
         }
      }

 

May 7, 2010 at 9:10 AM

well, use cache, gprs is the last option, and on mobile it runs quite fast, check videos