Map API

Nutiteq Maps Lib SDK enables developing advanced mobile mapping applications.
Platforms: Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »
Untitled Document

Products

» View demos
» Downloads

Latest news

Last at Tue, 3 Apr 2012 23:31:42
Topic: MapXT SDK evaluation
See more news »

DefaultZoomIndicator

3 replies [Last post]
Nole
User offline. Last seen 2 weeks 11 hours ago. Offline
Joined: 03/07/2011

Is it possible to control DefaultZoomIndicator? I use StoredMap. I write mapComponent.setZoomLevelIndicator(new DefaultZoomIndicator(13, 17)); but ZoomIndicator show all zoom(0-17). I only want to show zoom from 13 to 17.

jaak
User offline. Last seen 14 hours 27 min ago. Offline
Joined: 06/19/2008

The DefaultZoomIndicator assumes that you use same min/maxzoom values like for your map. Otherwise you would see broken indicator. Following is source of DefaultZoomIndicator.java, you can modify it in your own application.

import java.io.IOException;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import com.nutiteq.components.Rectangle;
import com.nutiteq.components.ZoomRange;
import com.nutiteq.log.Log;

/**
 * 

* Default zoom indicator used, when * {@link com.nutiteq.MapComponent#showZoomLevelIndicator(boolean)} is called. *

*

* If custom zoom indicator is used, then zoom images used for default indicator * (zoom1.png, zoom2.png, zoom3.png) can be removed from library jar. *

*/ public class DefaultZoomIndicator implements ZoomIndicator { private int maxZoom; private int zoomRange; private static final int SHOW_TIME = 2000; private static final int WIDTH = 17; private static final int SLIDER_HEIGHT = 9; private static final int PART_HEIGHT = 13; private static final int PART_OFFSET = 7; private Image verticalPart; private Image horisontalPart; private Image slider; private boolean visible; public DefaultZoomIndicator(final int minZoom, final int maxZoom) { setZoomRange(new ZoomRange(minZoom, maxZoom)); try { verticalPart = Image.createImage("/images/zoom2.png"); horisontalPart = Image.createImage("/images/zoom3.png"); slider = Image.createImage("/images/zoom1.png"); } catch (final IOException e) { Log.printStackTrace(e); } } public boolean isVisible() { return visible; } public void setVisible(final boolean visible) { this.visible = visible; } public void paint(final Graphics g, final int zoom, final int displayWidth, final int displayHeight) { final Rectangle clip = new Rectangle(g.getClipX(), g.getClipY(), g.getClipWidth(), g .getClipHeight()); for (int i = 0; i < zoomRange; i++) { g .setClip(displayWidth - 2 - WIDTH, 2 + PART_OFFSET * i + (i > 0 ? 1 : 0), WIDTH, PART_HEIGHT); g.drawImage(horisontalPart, displayWidth - 1 - 2, 2 + 5 + PART_OFFSET * i, Graphics.TOP | Graphics.RIGHT); g.drawImage(verticalPart, displayWidth - 6 - 2, 2 + PART_OFFSET * i, Graphics.TOP | Graphics.RIGHT); } g.setClip(displayWidth - 2 - WIDTH, 4 + PART_OFFSET * (maxZoom - zoom), WIDTH, SLIDER_HEIGHT); g.drawImage(slider, displayWidth - 2, 4 + PART_OFFSET * (maxZoom - zoom), Graphics.TOP | Graphics.RIGHT); g.setClip(clip.getX(), clip.getY(), clip.getX(), clip.getY()); } public void setZoomRange(final ZoomRange zRange) { maxZoom = zRange.getMaxZoom(); zoomRange = maxZoom - zRange.getMinZoom() + 1; } public long displayTime() { return SHOW_TIME; } }

/JaakL