且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Google地图中为每个国家赋予不同的颜色

更新时间:2022-10-19 20:44:58

使用谷歌地图这真的不容易,因为@oezi说你需要为每个你想要着色的国家构建覆盖图,坦率地说听起来像是一团糟。

但是,如果您不需要Google地图的所有功能,也许可以使用地图图表来自精彩的 Google图表工具(又名 Chart API 强>)。您可以在交互式图表向导



2017 UPDATE :这个答案相当古老,图表API已被Google弃用。您可以使用 Google图表API 中的 Geocharts : p>

https://开发人员.google.com / chart / interactive / docs / gallery / geochart



希望这有助于您!


Does anyone know how to give a different color to each country in a google map?

e.g:

in the world map

Blue overlay to UK, then RED china...etc

I wonder if google provide API to give color to each country

Thanks

Using Google Maps this is really not easy, as @oezi said you would need to build overlays of every country you want to color, which frankly sounds like a mess.

But if you don't need all of the functionalities of Google Maps, perhaps you can use a Map Chart from the fantastic Google Chart Tools (aka Chart API). You can check and tinker with a working example of a Colored Map (among some others) in the interactive Chart Wizard

2017 UPDATE: This answer is quite old and as such the Map Charts API has been deprecated by Google. You can use the Geocharts from the Google Charts API instead:

https://developers.google.com/chart/interactive/docs/gallery/geochart

Hope this helps!