2013-07-26 109 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

非常感謝您,也許已經很晚了,我的項目已經交付給客戶,但我可能會在稍後再次使用,所以再次非常感謝您 –