Java ME引路蜂地图开发示例:离线地图示例 (二)

2014-11-24 08:26:40 · 作者: · 浏览: 1
anvas);
}

public void destroyApp(boolean unconditional) {
localMapTileFileReader.close();
}
}
//------------------------------------------------------------------------------
// COPYRIGHT 2010 GUIDEBEE
// ALL RIGHTS RESERVED.
// GUIDEBEE CONFIDENTIAL PROPRIETARY
///////////////////////////////////// REVISIONS ////////////////////////////////
// Date Name Tracking # Description
// --------- ------------------- ---------- --------------------------
// 16SEP2010 James Shen Initial Creation
////////////////////////////////////////////////////////////////////////////////
//--------------------------------- PACKAGE ------------------------------------
package com.pstreets.gisengine.demo.midp;

//--------------------------------- IMPORTS ------------------------------------
import com.mapdigit.gis.geometry.GeoLatLng;
import com.mapdigit.gis.raster.MapTileStreamReader;
import com.mapdigit.gis.raster.MapTiledZone;
import com.mapdigit.gis.raster.MapType;
import com.pstreets.gisengine.demo.MapDemoMIDP;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.microedition.lcdui.Display;

//[------------------------------ MAIN CLASS ----------------------------------]
//--------------------------------- REVISIONS ----------------------------------
// Date Name Tracking # Description
// -------- ------------------- ------------- --------------------------
// 16SEP2010 James Shen Initial Creation
////////////////////////////////////////////////////////////////////////////////
/**
* stored map demo for Guidebee Map API on MIDP platform.
*
Copyright 2010 Guidebee, Inc. All Rights Reserved.
* @version 1.00, 16/09/10
* @author Guidebee Pty Ltd.
*/
public class StoredMapMIDP extends MapDemoMIDP {

MapTileStreamReader localMapTileFileReader;

public void startApp() {

init();

InputStream is = this.getClass().getResourceAsStream("/world03.map");
byte[] buffer = null;
try {
buffer = new byte[is.available()];
is.read(buffer);
is.close();
} catch (IOException ex) {
ex.printStackTrace();
}
ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
MapTiledZone mapTiledZone = new MapTiledZone(new DataInputStream(bais));

localMapTileFileReader
= mapTileDownloadManager.getInteralMapTileStreamReader();
localMapTileFileReader.addZone(mapTiledZone);
//you can add more store map package here use addZone

localMapTileFileReader.open();
GeoLatLng center = new GeoLatLng(-31.948275, 115.857562);
map.setCenter(center, 3, MapType.GOOGLEMAP);
Display.getDisplay(this).setCurrent(canvas);
}

public void destroyApp(boolean unconditional) {
localMapTileFileReader.close();
}
}

\

World03.map 存放了1-4级世界地图。MapTileManager 内部定义一个MapTileStreamReader ,如果设置了本地地图,MapTileManager会先从本地读取,如果本地没有需要图