Facebook Twitter LinkedIn E-mail
magnify
Home Archive for category "Windows Phone"

Windows Mobile引路蜂地图开发包Ver2.1下载

Windows Mobile引路蜂地图开发包下载。

帮助文档 下载
Windows Mobile引路蜂地图开发库 下载
Windows Mobile引路蜂地图开发示例 下载
引路蜂地图开发指南 下载
  1. Windows Mobile引路蜂地图开发示例:概述
  2. Windows Mobile引路蜂地图开发示例:二维图形库
  3. Windows Mobile引路蜂地图开发示例:准备开始
  4. Windows Mobile引路蜂地图开发示例:第一个地图应用
  5. Windows Mobile引路蜂地图开发示例:设置地图类型
  6. Windows Mobile引路蜂地图开发示例:放大、缩小
  7. Windows Mobile引路蜂地图开发示例:地图平移
  8. Windows Mobile引路蜂地图开发示例:地址查询
  9. Windows Mobile引路蜂地图开发示例:路径查询
  10. Windows Mobile引路蜂地图开发示例:本地查询
  11. Windows Mobile引路蜂地图开发示例:IP地址查询
  12. Windows Mobile引路蜂地图开发示例:地址反编码
  13. Windows Mobile引路蜂地图开发示例:选择地图服务
  14. 离线地图下载方法解析
  15. 自定义地图示例:天地图(一)
  16. 自定义地图示例:天地图(二)
 

Silverlight 引路蜂二维图形库下载

Silverlight库及例子下载 http://www.guidebee.info/download/silverlight/SilverlightGraphics2DDemo.zip ,库同样可以用于WPF,Windows Phone 7

Install Microsoft Silverlight

  1. Silverlight 引路蜂二维图形库示例:概述
  2. Silverlight 引路蜂二维图形库示例:包定义
  3. Silverlight 引路蜂二维图形库示例:基本知识
  4. Silverlight 引路蜂二维图形库示例:绘制各种几何图形
  5. Silverlight 引路蜂二维图形库示例:颜色
  6. Silverlight 引路蜂二维图形库示例:虚线类型
  7. Silverlight 引路蜂二维图形库示例:线段末端形状(LineCap)
  8. Silverlight 引路蜂二维图形库示例:线段连接类型(LineJoin)
  9. Silverlight 引路蜂二维图形库示例:不同线宽
  10. Silverlight 引路蜂二维图形库示例:椭圆
  11. Silverlight 引路蜂二维图形库示例:多义线和多边形
  12. Silverlight 引路蜂二维图形库示例:路径
  13. Silverlight 引路蜂二维图形库示例:坐标变换
  14. Silverlight 引路蜂二维图形库示例:颜色渐变
  15. Silverlight 引路蜂二维图形库示例:材质画刷
  16. Silverlight 引路蜂二维图形库示例:显示位图
  17. Silverlight 引路蜂二维图形库示例:动画Beziers曲线
  18. Silverlight 引路蜂二维图形库示例:矢量字体
  19. Silverlight 引路蜂二维图形库示例:结束语
 

在Windows Mobile 显示透明 PNG的方法

同样在移植的过程中,发现 .Net compact Framework 不支持透明图像。原本具有透明属性的Png (含有 alpha通道),通过 Graphics.DrawImage 显示之后,不再具有透明特性。这对于地图分层显示带了麻烦。举例来说。带地名卫星地图一般是由两层图片叠加而成。

两个图片叠加形成最后的图片

当由于.Net Compact Framework缺省不支持透明图像,两幅图叠加是 道路图回彻底覆盖掉下面的卫星图。原来的透明色变成白色。 同样如果再有其它图层(比如路径),又覆盖掉道路图。
经过Google 搜索,有两种方法可以实现在Windows mobile 上透明图像的显示。

是通过IImagingFactory 接口

using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace DotNetPocketStreet.Drawing
{
enum ImageLockMode
{
ImageLockModeRead = 0x0001,
ImageLockModeWrite = 0x0002,
ImageLockModeUserInputBuf = 0x0004
};
// Pulled from gdipluspixelformats.h in the Windows Mobile 5.0 Pocket PC SDK
public enum PixelFormatID : int
{
PixelFormatIndexed       = 0x00010000, // Indexes into a palette
PixelFormatGDI           = 0x00020000, // Is a GDI-supported format
PixelFormatAlpha         = 0x00040000, // Has an alpha component
PixelFormatPAlpha        = 0x00080000, // Pre-multiplied alpha
PixelFormatExtended      = 0x00100000, // Extended color 16 bits/channel
PixelFormatCanonical     = 0x00200000,
PixelFormatUndefined     = 0,
PixelFormatDontCare      = 0,
PixelFormat1bppIndexed   = (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI),
PixelFormat4bppIndexed   = (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI),
PixelFormat8bppIndexed   = (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI),
PixelFormat16bppRGB555   = (5 | (16 << 8) | PixelFormatGDI),
PixelFormat16bppRGB565   = (6 | (16 << 8) | PixelFormatGDI),
PixelFormat16bppARGB1555 = (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI),
PixelFormat24bppRGB      = (8 | (24 << 8) | PixelFormatGDI),
PixelFormat32bppRGB      = (9 | (32 << 8) | PixelFormatGDI),
PixelFormat32bppARGB     = (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical),
PixelFormat32bppPARGB    = (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI),
PixelFormat48bppRGB      = (12 | (48 << 8) | PixelFormatExtended),
PixelFormat64bppARGB     = (13 | (64 << 8) | PixelFormatAlpha  | PixelFormatCanonical | PixelFormatExtended),
PixelFormat64bppPARGB    = (14 | (64 << 8) | PixelFormatAlpha  | PixelFormatPAlpha | PixelFormatExtended),
PixelFormatMax           = 15
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
public enum BufferDisposalFlag : int
{
BufferDisposalFlagNone,
BufferDisposalFlagGlobalFree,
BufferDisposalFlagCoTaskMemFree,
BufferDisposalFlagUnmapView
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
public enum InterpolationHint : int
{
InterpolationHintDefault,
InterpolationHintNearestNeighbor,
InterpolationHintBilinear,
InterpolationHintAveraging,
InterpolationHintBicubic
}
// Pulled from gdiplusimaging.h in the Windows Mobile 5.0 Pocket PC SDK
public struct BitmapData
{
public uint Width;
public uint Height;
public int Stride;
public PixelFormatID PixelFormat;
public IntPtr Scan0;
public IntPtr Reserved;
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
public struct ImageInfo
{
public uint GuidPart1;  // I am being lazy here, I don't care at this point about the RawDataFormat GUID
public uint GuidPart2;  // I am being lazy here, I don't care at this point about the RawDataFormat GUID
public uint GuidPart3;  // I am being lazy here, I don't care at this point about the RawDataFormat GUID
public uint GuidPart4;  // I am being lazy here, I don't care at this point about the RawDataFormat GUID
public PixelFormatID pixelFormat;
public uint Width;
public uint Height;
public uint TileWidth;
public uint TileHeight;
public double Xdpi;
public double Ydpi;
public uint Flags;
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
[ComImport, Guid("327ABDA7-072B-11D3-9D7B-0000F81EF32E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComVisible(true)]
public interface IImagingFactory
{
uint CreateImageFromStream();       // This is a place holder, note the lack of arguments
uint CreateImageFromFile(string filename, out INativeImage image);
// We need the MarshalAs attribute here to keep COM interop from sending the buffer down as a Safe Array.
uint CreateImageFromBuffer([MarshalAs(UnmanagedType.LPArray)] byte[] buffer, uint size, BufferDisposalFlag disposalFlag, out INativeImage image);
uint CreateNewBitmap(uint width, uint height, PixelFormatID pixelFormat, out IBitmapImage bitmap);
uint CreateBitmapFromImage(INativeImage image, uint width, uint height, PixelFormatID pixelFormat, InterpolationHint hints, out IBitmapImage bitmap);
uint CreateBitmapFromBuffer();      // This is a place holder, note the lack of arguments
uint CreateImageDecoder();          // This is a place holder, note the lack of arguments
uint CreateImageEncoderToStream();  // This is a place holder, note the lack of arguments
uint CreateImageEncoderToFile();    // This is a place holder, note the lack of arguments
uint GetInstalledDecoders();        // This is a place holder, note the lack of arguments
uint GetInstalledEncoders();        // This is a place holder, note the lack of arguments
uint InstallImageCodec();           // This is a place holder, note the lack of arguments
uint UninstallImageCodec();         // This is a place holder, note the lack of arguments
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
[ComImport, Guid("327ABDA9-072B-11D3-9D7B-0000F81EF32E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComVisible(true)]
public interface INativeImage
{
uint GetPhysicalDimension(out Size size);
uint GetImageInfo(out ImageInfo info);
uint SetImageFlags(uint flags);
uint Draw(IntPtr hdc, ref Rectangle dstRect, IntPtr NULL); // "Correct" declaration: uint Draw(IntPtr hdc, ref Rectangle dstRect, ref Rectangle srcRect);
uint PushIntoSink();    // This is a place holder, note the lack of arguments
uint GetThumbnail(uint thumbWidth, uint thumbHeight, out INativeImage thumbImage);
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
[ComImport, Guid("327ABDAA-072B-11D3-9D7B-0000F81EF32E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComVisible(true)]
public interface IBitmapImage
{
uint GetSize(out Size size);
uint GetPixelFormatID(out PixelFormatID pixelFormat);
uint LockBits(ref Rectangle rect, uint flags, PixelFormatID pixelFormat, out BitmapData lockedBitmapData);
uint UnlockBits(ref BitmapData lockedBitmapData);
uint GetPalette();  // This is a place holder, note the lack of arguments
uint SetPalette();  // This is a place holder, note the lack of arguments
}
}

调用方法如下

using (Graphics gxBuffer = Graphics.FromImage(backBuffer))
{
// Since we nop'd OnPaintBackground, take care of it here
gxBuffer.Clear(this.BackColor);
// Ask the Image object from Imaging to draw itself.
IntPtr hdcDest = gxBuffer.GetHdc();
Rectangle dstRect = new Rectangle(100, 100, 148, 148);
imagingResource.Draw(hdcDest, ref dstRect, IntPtr.Zero);
gxBuffer.ReleaseHdc(hdcDest);
// Ask the Image object from Imaging to draw itself.
/*IntPtr*/ hdcDest = gxBuffer.GetHdc(); // This is redundant, but keeps the necessary code together
/*Rectangle*/ dstRect = new Rectangle(50, 70, 50+132, 70+132);
imagingImage.Draw(hdcDest, ref dstRect, IntPtr.Zero);
gxBuffer.ReleaseHdc(hdcDest);
}
// Put the final composed image on screen.
e.Graphics.DrawImage(backBuffer, 0, 0);

文档可参考 http://msdn.microsoft.com/en-us/library/aa452202.aspx

另外一种方法还是采用Manged code, 对于预先知道透明色值的图像,比如地图API中的路径,背景色总为0xFFE0E0E0
可以使用下面方法

ImageAttributes _imageAttributes = new ImageAttributes();
Color color = Color.FromArgb(0xE0E0E0);
_imageAttributes.SetColorKey(color, color);
Rectangle dstRect =
 new Rectangle(x, y, netImage.GetWidth(), netImage.GetHeight());
gxBuffer.DrawImage(netImage._bitmap, dstRect, 0, 0,
                           netImage.GetWidth(),
netImage.GetHeight(),
GraphicsUnit.Pixel, _imageAttributes);

最终结果如下图

 

离线地图下载方法解析

在使用Google Map, Microsoft Map 等在线地图时,常常想知道这些地图在服务器上是如何存放的,目前大部分地图服务器都是将地图以图片存储以提高响应速度。 一般大小为256X256个像素。
如果知道每个图片的URL,自己写个地图下载软件并不困难。从而做成离线地图。
下面程序片段给出了常用地图服务器上地图图片存取的URL计算方法。

using System.Collections.Generic;
using System.Text;
namespace MapTileURL
{
    class Program
    {
        private static Dictionary<string, string> MapTypeURLs = new Dictionary<string, string>
        {
            { "GoogleSatURL", "<a href="http://khm{GOOG_DIGIT}.google.com/kh/v=58&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://khm{GOOG_DIGIT}.google.com/kh/v=58&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "GoogleMapURL", "<a href="http://mt{GOOG_DIGIT}.google.com/vt/lyrs=m@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://mt{GOOG_DIGIT}.google.com/vt/lyrs=m@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "GoogleHybURL", "<a href="http://mt{GOOG_DIGIT}.google.com/vt/lyrs=h@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://mt{GOOG_DIGIT}.google.com/vt/lyrs=h@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "GoogleTerURL", "<a href="http://mt{GOOG_DIGIT}.google.com/vt/lyrs=t@108,r@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://mt{GOOG_DIGIT}.google.com/vt/lyrs=t@108,r@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "GoogleChinaURL", "<a href="http://mt{GOOG_DIGIT}.google.cn/vt/lyrs=m@121&hl=en&gl=cn&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://mt{GOOG_DIGIT}.google.cn/vt/lyrs=m@121&hl=en&gl=cn&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "YahooMapURL", "<a href="http://maps{Y_DIGIT}.yimg.com/hx/tl?v=4.3&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1">http://maps{Y_DIGIT}.yimg.com/hx/tl?v=4.3&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1</a>" },
            { "YahooSatURL", "<a href="http://maps{Y_DIGIT}.yimg.com/ae/ximg?v=1.9&t=a&s=256&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1">http://maps{Y_DIGIT}.yimg.com/ae/ximg?v=1.9&t=a&s=256&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1</a>" },
            { "YahooInMapURL", "<a href="http://maps.yimg.com/hw/tile?locale=en&imgtype=png&yimgv=1.2&v=4.1&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM_2">http://maps.yimg.com/hw/tile?locale=en&imgtype=png&yimgv=1.2&v=4.1&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM_2</a>}" },
            { "YahooInHybURL", "<a href="http://maps.yimg.com/hw/tile?imgtype=png&yimgv=0.95&t=h&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM_2">http://maps.yimg.com/hw/tile?imgtype=png&yimgv=0.95&t=h&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM_2</a>}" },
            { "YahooHybURL", "<a href="http://maps{Y_DIGIT}.yimg.com/hx/tl?v=4.3&t=h&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1">http://maps{Y_DIGIT}.yimg.com/hx/tl?v=4.3&t=h&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1</a>" },
            { "MicrosoftBrMapURL", "<a href="http://imakm{MS_DIGITBR}.maplink3.com.br/maps.ashx?v={QUAD}|t&call=2.2.4">http://imakm{MS_DIGITBR}.maplink3.com.br/maps.ashx?v={QUAD}|t&call=2.2.4</a>" },
            { "MicrosoftHybURL", "<a href="http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/h{QUAD}.png?g=441&mkt=en-us&n=z">http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/h{QUAD}.png?g=441&mkt=en-us&n=z</a>" },
            { "MicrosoftSatURL", "<a href="http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/a{QUAD}.png?g=441&mkt=en-us&n=z">http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/a{QUAD}.png?g=441&mkt=en-us&n=z</a>" },
            { "MicrosoftMapURL", "<a href="http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/r{QUAD}.png?g=441&mkt=en-us&n=z">http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/r{QUAD}.png?g=441&mkt=en-us&n=z</a>" },
            { "MicrosoftTerURL", "<a href="http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/r{QUAD}.png?g=441&mkt=en-us&shading=hill&n=z">http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/r{QUAD}.png?g=441&mkt=en-us&shading=hill&n=z</a>" },
            { "OpenStreetMapURL", "<a href="http://tile.openstreetmap.org/{ZOOM}/{X}/{Y}.png">http://tile.openstreetmap.org/{ZOOM}/{X}/{Y}.png</a>" },
            { "OSMARenderURL", "<a href="http://tah.openstreetmap.org/Tiles/tile/{ZOOM}/{X}/{Y}.png">http://tah.openstreetmap.org/Tiles/tile/{ZOOM}/{X}/{Y}.png</a>" },
            { "OpenAerialMapURL", "<a href="http://tile.openaerialmap.org/tiles/?v=mgm&layer=openaerialmap-900913&x={X}&y={Y}&zoom={OAM_ZOOM">http://tile.openaerialmap.org/tiles/?v=mgm&layer=openaerialmap-900913&x={X}&y={Y}&zoom={OAM_ZOOM</a>}" },
            { "OpenCycleMapURL", "<a href="http://andy.sandbox.cloudmade.com/tiles/cycle/{ZOOM}/{X}/{Y}.png">http://andy.sandbox.cloudmade.com/tiles/cycle/{ZOOM}/{X}/{Y}.png</a>" }
        };
        readonly static char[] Lookup = new[] { 'q', 't', 'r', 's' };
        public static string GetQuadtreeFromXYZoom(int x, int y, int zoom)
        {
            var quad = new StringBuilder();
            for (int i = 0; i < zoom; i++)
            {
                int rx = x % 2;
                int ry = y % 2;
                x /= 2;
                y /= 2;
                quad.Insert(0, Lookup[rx * 2 + ry]);
            }
            quad.Insert(0, 't');
            return quad.ToString();
        }
        public static string BuildUrl(string tileType, int x,int y,int zoom)
        {
    
            string url = "";
            // Edited by Shustrik - compacted the switch statement
            switch (tileType)
            {
                case "GoogleSat":
                case "GoogleSatH":
                    url = MapTypeURLs["GoogleSatURL"];
                    break;
                case "GoogleMap":
                    url = MapTypeURLs["GoogleMapURL"];
                    break;
                case "GoogleHyb":
                    url = MapTypeURLs["GoogleHybURL"];
                    break;
                case "GoogleTer":
                    url = MapTypeURLs["GoogleTerURL"];
                    break;
                case "GoogleChina":
                    url = MapTypeURLs["GoogleChinaURL"];
                    break;
                case "MicrosoftMap":
                    url = MapTypeURLs["MicrosoftMapURL"];
                    break;
                case "MicrosoftSat":
                    url = MapTypeURLs["MicrosoftSatURL"];
                    break;
                case "MicrosoftHyb":
                    url = MapTypeURLs["MicrosoftHybURL"];
                    break;
                case "MicrosoftTer":
                    url = MapTypeURLs["MicrosoftTerURL"];
                    break;
                case "MicrosoftBrMap":
                    if (zoom <= 10)
                        url =  MapTypeURLs["MicrosoftMapURL"];
                    else
                        url = MapTypeURLs["MicrosoftBrMapURL"];
                    break;
                case "YahooMap":
                    url = MapTypeURLs["YahooMapURL"];
                    break;
                case "YahooSat":
                case "YahooSatH":
                case "YahooSatH2":
                    url = MapTypeURLs["YahooSatURL"];
                    break;
                case "YahooHyb":
                    url = MapTypeURLs["YahooHybURL"];
                    break;
                case "YahooInMap":
                    url = MapTypeURLs["YahooInMapURL"];
                    break;
                case "YahooInHyb":
                    url = MapTypeURLs["YahooInHybURL"];
                    break;
                case "OpenStreetMap":
                    url = MapTypeURLs["OpenStreetMapURL"];
                    break;
                case "OSMARender":
                    url = MapTypeURLs["OSMARenderURL"];
                    break;
                case "OpenAerialMap":
                    url = MapTypeURLs["OpenAerialMapURL"];
                    break;
                case "OpenCycleMap":
                    url = MapTypeURLs["OpenCycleMapURL"];
                    break;
            }
          
            // Edited by Shustrik - added variables for configuration settings other than Google
            string quadcode = "";
            for (int i = (int)zoom - 1; i >= 0; i--)
                quadcode = quadcode + (((((y >> i) & 1) << 1) + ((x >> i) & 1)));
            url = url.Replace("{X}", x.ToString());
            url = url.Replace("{Y}", y.ToString());
            url = url.Replace("{Z}", ((int)zoom).ToString());
            url = url.Replace("{ZOOM}", ((int)zoom).ToString());
            url = url.Replace("{QUAD}", quadcode);
            url = url.Replace("{YAHOO_Y}", (((1 << ((int)zoom)) >> 1) - 1 - y).ToString());
            url = url.Replace("{YAHOO_ZOOM}", ((int)zoom + 1).ToString());
            url = url.Replace("{YAHOO_ZOOM_2}", (17 - (int)zoom + 1).ToString());
            url = url.Replace("{OAM_ZOOM}", (17 - (int)zoom).ToString());
            url = url.Replace("{GOOG_DIGIT}", ((x + y) & 3).ToString());
            url = url.Replace("{GOOG_QUAD}", GetQuadtreeFromXYZoom(x, y, zoom));
            url = url.Replace("{MS_DIGITBR}", ((((y & 1) << 1) + (x & 1)) + 1).ToString());
            url = url.Replace("{MS_DIGIT}", ((((y & 3) << 1) + (x & 1))).ToString());
            url = url.Replace("{Y_DIGIT}", ((x + y + zoom) % 3 +1).ToString());
            url = url.Replace("{GALILEO}", "Galileo".Substring(0, ((3 * x + y) & 7)));
            // support old style {} vars
            url = url.Replace("QQQQ", GetQuadtreeFromXYZoom(x,y,zoom));
            url = url.Replace("XXXX", x.ToString());
            url = url.Replace("YYYY", y.ToString());
            url = url.Replace("ZZZZ", (17 - (int)zoom).ToString());
            url = url.Replace("{OSM_ZOOM}", ((int)zoom).ToString());
            url = url.Replace("{MS_QUADCODE}", quadcode);
            url = url.Replace("*", ((x+y+zoom) %4).ToString());
            return url;
        }
        static void Main(string[] args)
        {
            string url = BuildUrl("GoogleMap", 1, 1, 1);
            //return <a href="http://mt2.google.com/vt/lyrs=m@121&hl=en&x=1&y=1&z=1&s=Gali">http://mt2.google.com/vt/lyrs=m@121&hl=en&x=1&y=1&z=1&s=Gali</a>
        }
    }
}

例子中取出 google map ,在 zoom=1 及 x=1,y=1是的图片。
http://mt2.google.com/vt/lyrs=m@121&hl=en&x=1&y=1&z=1&s=Gali

下载工具  http://www.mapdigit.com/forum/viewthread.php?tid=43&extra=page%3D1 中文说明参见离线地图生成工具结构图离线地图生成工具使用方法

 

Silverlight 引路蜂二维图形库示例:结束语

尽管前面引路蜂二维图形库的例子是以Silverlight为例,但引路蜂二维图形库可以用于Java ME,BlackBerry, LWUIT, Windows Mobile ,Windows Phone, Android, iPhone, Java SE ,Mono 等各个平台,以Silverlight为例是因为Silverlight可以实现在线演示。

Install Microsoft Silverlight

Silverlight库及例子下载 http://www.guidebee.info/download/silverlight/SilverlightGraphics2DDemo.zip

 

Silverlight 引路蜂二维图形库示例:矢量字体

引路蜂二维图形库支持矢量字体,包括中文和英文。对于Silverlight应用,由于访问权限的问题,字库一般需作为资源文件包含在应用中,对于英文字体不是个大问题,而对于中文字库,GB2312字库文件最小也要4M以上,所以尽量是用同一字体。引路蜂二维图形库绘制文字时是采用的矢量字库。也可以对文字内部进行填充。文字方向可以从左到右,从上到下,从右到左。 

字体下载链接如下表:

字体 大小 下载
Arial 34K Download
Courier New 50K Download
Elephant 52K Download
Impact 34K Download
Georgia 53K Download
Rockwell 35K Download
Times New Roman 44K Download
Microsoft Sans Serif 29K Download
Verdana 36K Download
幼圆 5128K Download
新魏 15874K Download
新宋体 5740K Download
行楷 13588K Download
宋体 5740K Download
隶书 7083K Download
仿宋 8104K Download
黑体 6108K Download

 

下例使用行楷显示“引路蜂软件”。 

private void FontDemo()
{
 TextureBrush brush1; 

 BitmapImage img = new BitmapImage();
 img.CreateOptions = BitmapCreateOptions.None;
 string path = "/SilverlightGraphics2DDemo;component/brick.png";
 Stream s = Application.GetResourceStream
      (new Uri(path, UriKind.Relative)).Stream;
 img.SetSource(s);
 WriteableBitmap writeableBitmap = new WriteableBitmap(img);
 brush1 = new TextureBrush(writeableBitmap.Pixels,
      img.PixelWidth, img.PixelHeight);
 Pen pen = new Pen(Color.Blue, 1); 

 path = "/SilverlightGraphics2DDemo;component/xingkai.fon";
 int fontSize = 100;
 s = Application.GetResourceStream
     (new Uri(path, UriKind.Relative)).Stream;
 s.Seek(0, SeekOrigin.Begin);
 //Clear the canvas with white color.
 graphics2D.Clear(Color.White);
 char[] longLine = null; 

 FontEx font = new FontEx(s);
 string guidebee = "引路蜂软件";
 longLine = guidebee.ToCharArray();
 graphics2D.SetPenAndBrush(pen,brush1);
 graphics2D.DrawChars(font, fontSize, longLine, 0, longLine.Length,
  (screenWidth - fontSize) / 2, 20, FontEx.TextDirTb);
 int offset = 20;
 for (int i = 1; i < 4;i++ )
 {
  fontSize=100-i*20;
  offset += fontSize+5;
  graphics2D.DrawChars(font, fontSize, longLine, 0,
   longLine.Length, (screenWidth - fontSize) / 2 - offset,
        20, FontEx.TextDirTb);
  graphics2D.DrawChars(font, fontSize, longLine, 0,
   longLine.Length, (screenWidth - fontSize) / 2 + offset,
   20, FontEx.TextDirTb);
   
 }
}

 

除了外挂字体外,引路蜂二维图形库自带了一个英文字库可以通过FontEx.GetSystemFont()取得。此外上述.fon 字体格式为引路蜂自定义,内部使用SVG来描述字体。和Windows中的字体格式不一致。