怎么在自己新建的图标上添加数字??

66 views
Skip to first unread message

Phevos

unread,
Dec 22, 2008, 4:10:44 AM12/22/08
to Google 地图 API 讨论组
急用,希望给予指点。谢谢

jm...@zingshanghai.com

unread,
Dec 22, 2008, 4:19:54 AM12/22/08
to Google 地图 API 讨论组
数字好像不行,我也没找到办法,只能用字母
On Dec 22, 5:10 pm, Phevos <zhangyang...@163.com> wrote:
> 急用,希望给予指点。谢谢

@@

unread,
Dec 22, 2008, 6:51:39 AM12/22/08
to Google-Map...@googlegroups.com

James Zhang

unread,
Dec 25, 2008, 9:25:11 PM12/25/08
to 谷歌地图 API 中文论坛
最简单最土的方式:为每一个要用数字的图标创建一个图片,完整的例子:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
<title>BOOK</title>
<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;key=ABQIAAAAmpZtkMqmn5tyEyqZWSz-
JBTztJ15sSDlOx5izzrd0kWPYQ-FqhTgLJG1MOm_xh4ael_VZERzVhJbzw"
type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(39.917,116.397), 14);
map.addControl(new GSmallMapControl());
map.addControl(new GOverviewMapControl());

// 为所有标记创建指定阴影、图标尺寸灯的基础图标
var baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.com/mapfiles/
shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

// 创建信息窗口显示对应给定索引的数字的标记
function createMarker(point, index) {
// Create a lettered icon for this point using our icon
class
var letter = String.fromCharCode("1".charCodeAt(0) + index);
var letteredIcon = new GIcon(baseIcon);
letteredIcon.image = "http://www.10piao.com/facebook/image/
marker/marker" + letter + ".png";

// 设置 GMarkerOptions 对象
markerOptions = { icon:letteredIcon};
var marker = new GMarker(point, markerOptions);

GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("标记 <b>" + letter + "</b>");
});
return marker;
}

// 随机向地图添加 3个标记
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
for (var i = 0; i < 3; i++) {
var latlng = new GLatLng(southWest.lat() + latSpan *
Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(createMarker(latlng, i));
}
}
}
</script>
</head>

<body onload="initialize()" onunload="GUnload()" style="margin:
0;padding:0;">
<div id="map_canvas" style="width: 495px; height: 300px"></div>
</body>
</html>


On 12月22日, 下午7时51分, "@@" <ask...@gmail.com> wrote:
> http://code.google.com/p/gmaps-utility-library-dev/wiki/Librarieshttp://gmaps-utility-library.googlecode.com/svn/trunk/labeledmarker/r...

junli.linux

unread,
Dec 26, 2008, 12:15:29 AM12/26/08
to Google-Maps-API-China
运行不了啊,说网页上有错误。。奇怪
 
 
2008-12-26

junli.linux

发件人: James Zhang
发送时间: 2008-12-26  10:25:26
收件人: 谷歌地图 API 中文论坛
抄送:
主题: Re: 怎么在自己新建的图标上添加数字??

James Zhang

unread,
Dec 26, 2008, 12:20:02 AM12/26/08
to Google-Map...@googlegroups.com

可运行的网址:

http://www.10piao.com/facebook/map/test.html



2008/12/26 junli.linux <junli...@gmail.com>

junli.linux

unread,
Dec 26, 2008, 12:44:06 AM12/26/08
to Google-Maps-API-China
谢谢。
原来你的每一个带数字的图片都是单独一个图片啊?呵呵。
如果用上GD自动做出带数字的图,会不会更好呢。
 
 
2008-12-26

junli.linux

发件人: James Zhang
发送时间: 2008-12-26  13:20:24
收件人: Google-Maps-API-China
抄送:
主题: Re: Re: 怎么在自己新建的图标上添加数字??
Reply all
Reply to author
Forward
0 new messages