Gwt-googlecharts-map-latitude

提供:Dev Guides
移動先:案内検索

緯度/経度を使用した地図

以下は、緯度/経度を使用した地図の例です。

link:/gwt_googlecharts/gwt_googlecharts_configuration_syntax [Googleグラフの構成構文]の章で、グラフを描画するために使用される構成を見てきました。 次に、緯度/経度を使用したマップの例を見てみましょう。

*_HelloWorld.java_*
package com.finddevguides.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

import com.googlecode.gwt.charts.client.ChartLoader;
import com.googlecode.gwt.charts.client.ChartPackage;
import com.googlecode.gwt.charts.client.ColumnType;
import com.googlecode.gwt.charts.client.DataTable;
import com.googlecode.gwt.charts.client.map.Map;
import com.googlecode.gwt.charts.client.map.MapOptions;

public class HelloWorld implements EntryPoint {
   private Map chart;

   private void initialize() {
      ChartLoader chartLoader = new ChartLoader(ChartPackage.MAP);
      chartLoader.loadApi(new Runnable() {
         public void run() {
           //Create and attach the chart
            chart = new Map();
            RootPanel.get().add(chart);
            draw();
         }
      });
   }
   private void draw() {
     //Prepare the data
      DataTable data = DataTable.create();
      data.addColumn(ColumnType.NUMBER , "Latitude");
      data.addColumn(ColumnType.NUMBER, "Longitude");
      data.addColumn(ColumnType.STRING, "Name");

      data.addRow(37.4232, -122.0853, "Work");
      data.addRow(37.4289, -122.1697, "University");
      data.addRow(37.6153, -122.3900, "Airport");
      data.addRow(37.4422, -122.1731, "Shopping");

     //Set options
      MapOptions options = MapOptions.create();
      options.setShowTip(true);

     //Draw the chart
      chart.draw(data,options);
      chart.setWidth("400px");
      chart.setHeight("400px");
   }
   public void onModuleLoad() {
      initialize();
   }
}

結果

結果を確認します。

緯度/経度を使用した地図グラフ