MapView中画图

通过Overlay的方式画图,不废话了,直接代码吧。需要完整代码的这里下载:猛击这里

参考链接: http://westyi.blogbus.com/logs/69324000.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.appspot.zaichunchen;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Point;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

/**
 * Map Overlay
 * 
 * @author ChenZaichun
 * 
 */
public class Marker extends Overlay {
	private GeoPoint point = null;
	private Bitmap bmp = null; 
	private Point deviation = null; 

	/**
	 * 
	 * @param point
	 *            GeoPoint of icon
	 * @param bmp
	 *            Icon Bitmap
	 * @param deviation
	 *            icon offset, use window coordinates (left --> right, up --> down)
	 */
	public Marker(GeoPoint point, Bitmap bmp, Point deviation) {
		this.point = point;
		this.bmp = bmp;
		this.deviation = deviation;
	}

	/**
	 * Draw the icon
	 */
	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		if (!shadow) {// not the shadow layer
			Projection projection = mapView.getProjection();
			if (point != null && bmp != null) {
				Point pos = projection.toPixels(point, null);
				//add offset
				canvas.drawBitmap(bmp, pos.x + deviation.x, pos.y + deviation.y, null);
			}	
		}
	}
}

使用的方法:

Android地图MapView

今天想在android使用Google地图,查了一下,难点就是要自己去申请一个api key,不然是不能够正确获取地图服务的。方法如下:

  1. 查看debug key的md5 finger,如果在windows下,自己去“打开Eclipse—>Windows—>Preferences—>Android—>Build,查看默认的debug keystore位置”
1
keytool -list -alias androiddebugkey -keystore ~/.android/debug.keystore" -storepass android -keypass android

得到

archlinux x86_64安装google-talkplugin

要想在gmail里面使用视频,音频或者打电话,需要安装google-talkplugin,官方网站提供了deb和rpm包,archlinux下安装可以通过aur安装

1
yaourt -S google-talkplugin

这个时候直接不能安装,因为安装过程会提示lib32-openssl-compatible找不到,修改PKGBUILD,改为lib32-openssl 然后安装之后,会发现启动不了

1
2
3
[226:202] Waiting for GoogleTalkPlugin to start...
[227:297] Warning(clientchannel.cc:583): Unreadable or no port file.  Could not initiate GoogleTalkPlugin connection
[227:298] Warning(clientchannel.cc:439): Could not initiate GoogleTalkPlugin connection

执行/opt/google/talkplugin/GoogleTalkPlugin会提示找不到libssl.so.0.9.8

1
./GoogleTalkPlugin: error while loading shared libraries: libssl.so.0.9.8: cannot open shared object file: No such file or directory

创建一个软链接

1
sudo ln -s /usr/lib32/libssl.so.1.0.0 /usr/lib32/libssl.so.0.9.8

还缺少一个东东

1
./GoogleTalkPlugin: error while loading shared libraries: libcrypto.so.0.9.8: cannot open shared object file: No such file or directory

再创建一个软链接

1
sudo ln -s /usr/lib32/libcrypto.so.1.0.0 /usr/lib32/libcrypto.so.0.9.8

(注意,file GoogleTalkPlugin竟然是一个32位的elf)

1
2
[chenzaichun@czc-laptop talkplugin]$ file GoogleTalkPlugin
GoogleTalkPlugin: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped

所以链接目录应该在/usr/lib32,而不是/usr/lib

完毕,可以正常使用了。

GTK+按钮

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* compile command:
   gcc -o button button.c `pkg-config --libs --cflags gtk+-2.0`
*/
#include <gtk/gtk.h>

static void destroy(GtkWidget*, gpointer);

int main(int argc,
		 char *argv[])
{
	GtkWidget *window, *button;

	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window), "Buttons");
	gtk_container_set_border_width(GTK_CONTAINER(window), 25);
	gtk_widget_set_size_request(window, 200, 100);

	g_signal_connect(G_OBJECT(window), "destroy",
					 G_CALLBACK(destroy), NULL);

	/* Create a new button that has a mnemonic key of Alt+c. */
	button = gtk_button_new_with_mnemonic("_Close");
	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);

	/* Connect the button to the clicked signal. The callback function
	 * recieves the window followed by the button because the arguments
	 * are swapped
	 */
	g_signal_connect_swapped(G_OBJECT(button), "clicked",
							 G_CALLBACK(gtk_widget_destroy),
							 (gpointer)window);

	gtk_container_add(GTK_CONTAINER(window), button);
	gtk_widget_show_all(window);

	gtk_main();

	return 0;
}

/* Stop the GTK+ main loop function */
static void
destroy(GtkWidget *window,
		gpointer data)
{
	gtk_main_quit();
}