【问题标题】:Google Maps Dynamic Marker Icons谷歌地图动态标记图标
【发布时间】:2013-07-26 18:01:55
【问题描述】:

我很清楚,谷歌在此处为谷歌地图提供了图表 api 动态标记图标的一部分: https://developers.google.com/chart/image/docs/gallery/dynamic_icons

只有一个小问题,整个 API 似乎已被弃用。另外,我真的希望有更多种类,因为并非所有图标都提供相同的灵活性。

所以我找到了这个网页: http://mapicons.nicolasmollet.com/numbers-letters/numbers/?style=classic

图标看起来不错,但它们不是动态的,而且我的客户似乎不喜欢它们。那么是否有不同的网页或其他类型的服务提供简洁的动态图标?

不一定适用于谷歌地图。可以用于任何目的,也适用于地图:-)

提前谢谢你!

【问题讨论】:

  • “动态图标”是什么意思?这个词可以用几种不同的方式来解释。
  • 我的意思是动态生成的图标,而不是静态的。例如,如果您想使用带有数字的图标标记,而不是一个一个地创建它们,您只需使用类似:chart.apis.google.com/…

标签: dynamic google-maps-api-3 google-visualization


【解决方案1】:

好的,我前段时间做了一个项目,它确实做到了这一点,但它独立于谷歌地图,即使我用它来创建动态地图标记。这是整个php函数:

<?php
    function createImage($number, $color) {

        $blank = "/var/www/rbc/dashboard/images/".$color."-0.png";

        //$image = @imagecreatefrompng($blank);
        $image = LoadPNG($blank);

        // pick color for the text
        $fontcolor = imagecolorallocate($image, 255, 255, 255);

        $font = 2;
        $fontsize = 8;

        $width = imagefontwidth($font) * strlen($number) ;
        $height = imagefontheight($font) ;

        $x = (imagesx($image) - $width) / 2;
        $y = 5;

        //white background
        $backgroundColor = imagecolorallocate ($image, 255, 255, 255);

        //white text
        $textColor = imagecolorallocate($image, 255, 255, 255);

        //  preserves the transparency
        imagesavealpha($image, true);
        imagealphablending($image, false);

        imagestring($image, $font, $x, $y, $number, $textColor);

        // tell the browser that the content is an image
        header('Content-type: image/png');

        // output image to the browser
        imagepng($image);

        // delete the image resource
        imagedestroy($image);
    }

    function LoadPNG($imgname) {
            /* Attempt to open */
            $im = imagecreatefrompng($imgname);

            /* See if it failed */
            if(!$im) {
                    /* Create a blank image */
                    $im  = imagecreatetruecolor(150, 30);
                    $bgc = imagecolorallocate($im, 255, 255, 255);
                    $tc  = imagecolorallocate($im, 0, 0, 0);

                    imagefilledrectangle($im, 0, 0, 150, 30, $bgc);

                    /* Output an error message */
                    imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
            }
            return $im;
    }

    if(!isset($_GET['color'])) {
        $_GET['color'] = "blue";
    }
    if(!isset($_GET['number'])) {
        $_GET['number'] = "99";
    }

    createImage($_GET['number'], $_GET['color']);
?>

你用&lt;img src="image.php?color=red&amp;number=2" /&gt;显示的

HTH

【讨论】:

  • 非常感谢,可能晚了,我的项目已经交付给客户,但我以后可能会有用,所以再次非常感谢你
猜你喜欢
  • 2023-04-11
  • 2016-04-20
  • 1970-01-01
  • 1970-01-01
  • 2011-10-09
  • 2015-08-05
  • 1970-01-01
  • 1970-01-01
  • 2017-09-21
相关资源
最近更新 更多