地图怎么可以缺少指示图标呢?实现这个功能是通过override default Overlay来实现的。
基于上篇的CityMap,在MapView中获取一个OverlayController:
java 代码
- OverlayController?oc?=?myMapView.createOverlayController();??
然后加入你自己的Overlay实现
java 代码
- public?class?KusoIconOverlay?extends?Overlay?{??
基本上你要实现Overlay里面draw()method:
java 代码
- //既然是手机app,就不强调OO了。。。
- Bitmap?bitmap;??
- ????Point?p;??
- ??????
- ????@Override??
- ????public?void?draw(Canvas?canvas,?PixelCalculator?calculator,?boolean?shadow)?{??
- ????????super.draw(canvas,?calculator,?shadow);??
- ????????int[]?xyCoordinates?=?new?int[2];??
- ????????calculator.getPointXY(p,?xyCoordinates);??
- ????????canvas.drawBitmap(bitmap,?xyCoordinates[0],?xyCoordinates[1],?new?Paint());??
- ????}??
通过PixelCalculator把经度维度转换成地图上面的XY坐标。
通过canvas来画个bitmap,也就是偶华丽的kuso头像。。。
回到MapView中,创建kuso overlay:
java 代码
- KusoIconOverlay?overlay?=?new?KusoIconOverlay();??
- ????????overlay.bitmap?=?kuso;??
- ????????overlay.p?=?p;??
在先前得到的OverlayController中加入kuso overlay:
java 代码
- oc.add(overlay,?true);??
这样就大功告成了!
接下来的挑战是实现模拟GPS移动。。。让偶的头像真正的动起了。。。
1 楼 lordhong 2007-11-20
bitmap是通过读取resource来建立的。。。我是copy别人的。。。
2 楼 bookong 2007-11-20
楼主,请问如何让模拟器连到网上?我运行自带的Maps什么也看不到(除了一堆方格……)
3 楼 lordhong 2007-11-20
自动连接网络的啊, 你试着用MOUSE移动看看...有时MAP暂时出不来.
4 楼 bookong 2007-11-21
我在网上找到有人说怎么解决了,要给它设一个代理服务器。不过我还没有试。
Here is a potential work around. It uses the command line to add an
http proxy.
Note: you may need to update the escaping to use for windows.
cd to the location of adb
replace the pieces [host_or_IP] and [port] with the correct values for
the proxy. So if your proxy is corp_proxy, on port 8080, then in the
quotes should be corp_proxy:8080
----
./adb shell sqlite3 /data/data/com.google.android.providers.settings/
databases/settings.db "\"INSERT INTO system
VALUES(99,'http_proxy',' [host_or_IP]:[port]');\""
----
To see if it was added correctly you can run the following command
line. You should see 99|http_proxy| [host_or_IP]:[port]
----
./adb shell sqlite3 /data/data/com.google.android.providers.settings/
databases/settings.db "\"SELECT * FROM system\""
----
To remove the proxy, the following script can be run:
---
./adb shell sqlite3 /data/data/com.google.android.providers.settings/
databases/settings.db "\"DELETE FROM system WHERE _id=99\""
---
- Luisa
On Nov 16, 12:10 pm, footose <ha...@generationdub.com> wrote:
Here is a potential work around. It uses the command line to add an
http proxy.
Note: you may need to update the escaping to use for windows.
cd to the location of adb
replace the pieces [host_or_IP] and [port] with the correct values for
the proxy. So if your proxy is corp_proxy, on port 8080, then in the
quotes should be corp_proxy:8080
----
./adb shell sqlite3 /data/data/com.google.android.providers.settings/
databases/settings.db "\"INSERT INTO system
VALUES(99,'http_proxy',' [host_or_IP]:[port]');\""
----
To see if it was added correctly you can run the following command
line. You should see 99|http_proxy| [host_or_IP]:[port]
----
./adb shell sqlite3 /data/data/com.google.android.providers.settings/
databases/settings.db "\"SELECT * FROM system\""
----
To remove the proxy, the following script can be run:
---
./adb shell sqlite3 /data/data/com.google.android.providers.settings/
databases/settings.db "\"DELETE FROM system WHERE _id=99\""
---
- Luisa
On Nov 16, 12:10 pm, footose <ha...@generationdub.com> wrote:
5 楼 lordhong 2007-11-23
代理我不是很清楚。。。我的连接没有用到proxy。。。