利用MapGuide Open Source的ToolTip做專題圖

來源:互聯網
上載者:User

 

能否利用MapGuide 製作專題圖進行商務分析一直是眾多開發人員關注的焦點之一。現在MapGuide自身的功能已經支援按地區建立色塊分析專題圖了,比如分析中國地圖以省為單位的人口密度情況,人口密度大的省份用深紅色表示,人口稀少的省份用明黃色表示,這樣就可以建立出人口分布專題圖,這個功能無論是在Map 3D還是在MapGuide OpenSource或Enterprise版中都是很簡單的,MapGuide的例子程式Theme即可完成。那麼MapGuide能否支援基於地塊的餅狀圖或者柱狀圖呢?比如要按照省份統計每個省的人口年齡層次狀況,那我需要在點每個省時,用餅狀圖或者柱狀圖表示未成年人、中青年人和老年人各佔多少比例,現在MapGuide還不能直接在地圖上產生這樣的專題圖。但現在也不是沒有辦法。

 

也許有人還記得我許久以前的一篇文章給MapGuide Open Source的ToolTip加點料, 這篇文章講述了如果在MapGuide ToolTip中加入圖片,後來無意中看到了Google的Chart API,覺得在這上面肯定可以做些文章。後來一忙就忘了。不過所幸,後來Jackie Ng做了這個工作了,貼出來給大家共用一下。原文在http://themapguyde.blogspot.com/2009/07/expressive-power-of-mapguide-tooltips.html,國內使用者可能訪問不了。我轉一下過來。

 

Google offers a free API that lets you generate dynamic charts and graphs all from a simple url. This graph below is one such example (right click and view the page source if you want)

This chart is basically a HTML img tag with the following url:
http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=HelloWorld
If you study the url carefully, you'll see that there is a parameter asking for the values to be charted, and another parameter asking for the labels for these charted values. Now consider the Parcels layer of the Sheboygan sample dataset:


Suppose we want to represent the values of RYEAR, GEOEXTRA and RBLDGVC in a pie chart (I know this probably makes no sense from a reporting perspective, it's just for the sake of argument)
The tooltip expression for the Parcels layer would be something like:

 

我簡單做了一下,你可以貼過去試試。

Concat ( Concat ( Concat ( Concat ( Concat ( Concat ( Concat ( '<img src = http://chart.apis.google.com/chart?chs=250x100&amp;chd=t:',  RYEAR  ), ',' ),  GEOEXTRA  ), ',' ),  RBLDGVC  ),  '&amp;cht=p3&amp;chl= '  ), ' RYEAR|GEOEXTRA |RBLDGV />' )

When we now put our mouse over a Parcel, this is what we get:


Pretty cool eh?

 

怎麼樣,效果還算可以吧,雖然需要滑鼠指上去才顯示,但總比沒有強些

這隻是個引子,注意到ToolTip中只是個HTML,其實只要你有想象力,可以放任何html代碼進去,呵呵。 有時間試試看吧。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.