开发者

adjust location marker on Zoom in and zoom out in Mapfield

H I have written a co开发者_如何学Cde to draw two custom location markers on the MapField. But when i zoom in and zoom out, the location marker is of the same size, I want the location marker to adjust according the zoom level. Could someone please help me put on this??

BR, Suppi

edit:

So far am able to do this,

 mPointDest = new XYRect[mPoints.length];
            for (int i = 0; i < mPoints.length; i++) {
            XYPoint fieldOut = new XYPoint();
            convertWorldToField(mPoints[i], fieldOut);
            mIcon = Bitmap.getBitmapResource("location.png");
        int imgW = mIcon.getWidth();
        int imgH = mIcon.getHeight();
        mPointDest[i] = new XYRect(fieldOut.x - imgW / 2,
                    fieldOut.y - imgH, imgW, imgH);
            graphics.drawBitmap(mPointDest[i], mIcon, 0, 0);

and for zoom :

protected boolean keyChar(char character, int status, int time) 
    {
        // 'i' will zoom in.
        if (character == 'i') 
        {

                mMapField.setZoom(Math.max(mMapField.getZoom() - 1, mMapField.getMinZoom()));
                return true;

        }
        // 'o' will zoom out
        if (character == 'o') 
        {

            mMapField.setZoom(Math.min(mMapField.getZoom() + 1, mMapField.getMaxZoom()));
            return true;
        }

        return super.keyChar(character, status, time);
    }

After this am wondering how to go about adjusting the bitmap based on the zoom level. Can someone please give me some idea??


Zooming only impacts the map itself. If you want to change the size of your own graphics, you will need to manually scale them yourself. For example, you might either include multiple sizes of the "location.png" resource in your project and then choose the appropriate one based on the zoom level, or use the Bitmap.scaleInto() method to zoom your graphic on the fly.

Note that the on-the-fly method will yield a lower quality result than including multiple sizes of the original graphic (well, I am presuming that you have a high-res original that you are shrinking for inclusion in your project).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜