我想为我的谷歌地图编号的地图标记,目前我正在使用Google Charts API方法动态创建编号标记。但是,我无法使用该方法使用我自己的图标。用动态生成的数字自定义地图标记图标
有没有办法使用我自己的自定义地图标记图标,然后覆盖/有一个数字的顶部?
另外,有没有一种快速的方法来创建从1
到1000
运行的1000个.PNG标记?像Photoshop中的批处理过程
我想为我的谷歌地图编号的地图标记,目前我正在使用Google Charts API方法动态创建编号标记。但是,我无法使用该方法使用我自己的图标。用动态生成的数字自定义地图标记图标
有没有办法使用我自己的自定义地图标记图标,然后覆盖/有一个数字的顶部?
另外,有没有一种快速的方法来创建从1
到1000
运行的1000个.PNG标记?像Photoshop中的批处理过程
我从我写的一篇文章中借用了这段代码,并稍微调整了它。您应该下载this image,在Photoshop中对其进行编辑并将其放在与PHP脚本相同的目录中。调整脚本中的数字,直到你得到一些体面的东西。我的系统上
<?php
define("FONT_SIZE", 6); // font size in points
define("FONT_PATH", "c:/windows/fonts/arial.ttf"); // path to a ttf font file
define("FONT_COLOR", 0x00000000); // 4 byte color
// alpha -- 0x00 thru 0x7F; solid thru transparent
// red -- 0x00 thru 0xFF
// greeen -- 0x00 thru 0xFF
// blue -- 0x00 thru 0xFF
$text = $_GET["text"];
$gdimage = imagecreatefrompng("marker.png");
imagesavealpha($gdimage, true);
list($x0, $y0, , , $x1, $y1) = imagettfbbox(FONT_SIZE, 0, FONT_PATH, $text);
$imwide = imagesx($gdimage);
$imtall = imagesy($gdimage) - 14; // adjusted to exclude the "tail" of the marker
$bbwide = abs($x1 - $x0);
$bbtall = abs($y1 - $y0);
$tlx = ($imwide - $bbwide) >> 1; $tlx -= 1; // top-left x of the box
$tly = ($imtall - $bbtall) >> 1; $tly -= 1; // top-left y of the box
$bbx = $tlx - $x0; // top-left x to bottom left x + adjust base point
$bby = $tly + $bbtall - $y0; // top-left y to bottom left y + adjust base point
imagettftext($gdimage, FONT_SIZE, 0, $bbx, $bby, FONT_COLOR, FONT_PATH, $text);
header("Content-Type: image/png");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 60 * 60 * 24 * 180) . " GMT");
imagepng($gdimage);
?>
输出示例:
现在,您可以与谷歌图表做到这一点。以下是一个示例语法:
(scale|rotation|color|fontsize|bold(b) or normal(_)|text[|line2]
https://chart.googleapis.com/chart?chst=d_map_spin&chld=1.0|0|FF8844|12|_|221B
不幸的是,这已被弃用,并建议使用服务器端代码 –
*另外,有没有一种快速的方法来创建1000.PNG标记... *是的,你可以在PHP + GD中做到这一点。事实上,你不需要预先创建标记。您可以像'marker-gen.php?text = 123'一样按需创建它们。这会工作吗? –
我没有太多的PHP + GD经验。假设我设法使用PHP + GD创建编号标记,可以使用'icon:“http://www.site.com/marker-gen.php?text=123”'将它们引入Google地图吗? – Nyxynyx
是的,理论上''http://www.site.com/marker-123.png“'和'”http://www.site.com/marker.php?text=123“'没有区别'只要PHP提供正确的标题和图像。 –