2013-07-26 371 views
0

我清楚地知道,谷歌提供的对谷歌的图表API动态标记图标部分映射在这里: https://developers.google.com/chart/image/docs/gallery/dynamic_icons谷歌地图动态标记图标

有仅仅只有一个小问题,整个API似乎被弃用。另外,我真的很想有更多的品种,因为不是所有的图标都具有相同的灵活性。

所以,我发现这个网页: http://mapicons.nicolasmollet.com/numbers-letters/numbers/?style=classic

的图标看起来不错,但他们是不是动态的,以及我的客户似乎并不喜欢他们。那么有没有一个不同的网页或其他类型的服务,提供整洁的动态图标?

不一定是谷歌地图。可以为任何目的只是适合地图以及:-)

先谢谢您!

+0

什么,你的 “动态图标” 意思?该术语可以用几种不同的方式来解释。 –

+0

我的意思是动态生成的图标,而不是静态的。例如,如果您希望使用带有数字的图标标记,而不是逐个创建它们,则只需使用以下内容:http://chart.apis.google.com/chart?chst = d_bubble_text_small_withshadow&chld = bbbr | 01 | F15524 | FFFFFF –

回答

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']); 
?> 

您与<img src="image.php?color=red&number=2" />

心连心显示

+0

非常感谢您,也许已经很晚了,我的项目已经交付给客户,但我可能会在稍后再次使用,所以再次非常感谢您 –