heatmapメモ

# 参考
## ヒートマップ
http://qiita.com/key/items/4e669b146874b1074be7
http://qiita.com/papipupepujii/items/a8bba67cc575d8a75b6e#_reference-4500e7de91b198500f78

## google geocoder
http://so-zou.jp/web-app/tech/web-api/google/map/geocoding.htm
http://qiita.com/Arashi/items/33a605870d39aeac9a37
https://teratail.com/questions/16308
http://www.tree-tips.com/java/geocoding/

## APIキー
https://nendeb.com/276

# 分かっていないこと
住所から緯度、経度の取得
Maven

```jsp:heatMap.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GoogleMapにヒートマップ</title>
<style>
  #map {
    width: 800px;
    height: 600px;
  }
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCY0ieCAGyUTWhnjGYuCpPT29y_IRiy_us&libraries=geometry,visualization"></script>
    <script>	    
      function initialize() {
        var mapCanvas = document.getElementById('map');
        var mapOptions = {
          center: new google.maps.LatLng(36.83566824724438,138.372802734375),
          zoom: 5,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(mapCanvas, mapOptions)
        
        var heatmapData = [
         //ヒートマップの重みと座標指定
         { weight :  2 ,  location :  new google.maps.LatLng(32.7361422,129.8708733) },
         { weight :  4 ,  location :  new google.maps.LatLng(71.3868712,-129.9945562) }, 
         { weight :  3 ,  location :  new google.maps.LatLng(37.5933274,139.0009869) }
        ]
        var heatmap = new google.maps.visualization.HeatmapLayer({
          data: heatmapData,
          radius: 10,
          map: map
        });
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
</head>
<body>
	<div id="map"></div>
</body>
</html>
```
# リストから
```jsp:heatmap.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GoogleMapにヒートマップ</title>
<style>
  #map {
    width: 800px;
    height: 600px;
  }
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCY0ieCAGyUTWhnjGYuCpPT29y_IRiy_us&libraries=geometry,visualization"></script>
    <script>	    
      function initialize() {
        var mapCanvas = document.getElementById('map');
        var mapOptions = {
          center: new google.maps.LatLng(36.83566824724438,138.372802734375),
          zoom: 5,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(mapCanvas, mapOptions)
        
        var heatmapData = [
         //ヒートマップの重みと座標指定
         <c:forEach var="gps" items="${sessionScope.gpsList}">
				{ weight :  ${gps.num} ,  location :  new google.maps.LatLng( ${gps.latitude}, ${gps.longitude}) },
		</c:forEach>
        ]
        var heatmap = new google.maps.visualization.HeatmapLayer({
          data: heatmapData,
          radius: 10,
          map: map
        });
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
</head>
<body>
	<div id="map"></div>
</body>
</html>
```
```java:Geo.java


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class Geo
 */
@WebServlet("/Geo")
public class Geo extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Geo() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		Gps gps = new Gps();
		gps.setLatitude("32.7361422");
		gps.setLongitude("129.8708733");
		gps.setNum("2");
		
		List<Gps> gpsList = new ArrayList<Gps>();
		gpsList.add(gps);
		
		gps = new Gps();
		gps.setLatitude("28.7361422");
		gps.setLongitude("140.8708733");
		gps.setNum("12");
		gpsList.add(gps);
		
		gps = new Gps();
		gps.setLatitude("34.7361422");
		gps.setLongitude("128.8708733");
		gps.setNum("12");
		gpsList.add(gps);
		
		HttpSession session = request.getSession();
		session.setAttribute("gpsList", gpsList);
		
		request.getRequestDispatcher("/heatmap.jsp").forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}

```
```java:gps.java


public class Gps {

	private String latitude;
	private String longitude;
	private String num;
	
	public String getLatitude() {
		return latitude;
	}
	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}
	public String getLongitude() {
		return longitude;
	}
	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
	public String getNum() {
		return num;
	}
	public void setNum(String num) {
		this.num = num;
	}
}

```