var deflon = 139.745415; var deflat = 35.658625; var defzoom = 15; var mapDiv; var map; var oldPoly; var DistPoint = new Array(); var DistOL = null; function initMap() { map = new GMap2(mapDiv); map.addControl(new GScaleControl()); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl(true)); map.setCenter(new GLatLng(deflat, deflon), defzoom); drawCircle(0.0036, "#cc0000");//400m drawCircle(0.0072, "#ffcc00");//800m GEvent.addListener(map, "click", function(overlay, point) { if(overlay == null){ DistPoint.push(point); if(DistPoint.length > 1) { map.removeOverlay(DistOL); DistOL = new GPolyline(DistPoint, "#cc0066", 4, 0.5 ); map.addOverlay(DistOL); var dist = 0; var i = 0; while(i < DistPoint.length - 1){ dist += Gdistance(DistPoint[i], DistPoint[++i]); } document.getElementById("distance").innerHTML = "現在の積算距離 約 " + (dist/1000) + "km (徒歩約 " + Math.round(dist/80) + "分)"; } } }); var mark = new GMarker(new GLatLng(deflat, deflon), G_DEFAULT_ICON); map.addOverlay(mark); var html = '

東京タワー

東京都港区芝公園4-2-8
http://www.tokyotower.co.jp/

'; mark.openInfoWindowHtml(html); GEvent.addListener(mark, "click", function(marker, point) { mark.openInfoWindowHtml(html); }); var icon_metro = new GIcon(); icon_metro.image = "./map_icon_metro.png"; icon_metro.shadow = "./map_shadow_metro.png"; icon_metro.iconSize = new GSize(38, 37); icon_metro.shadowSize = new GSize(55, 37); icon_metro.iconAnchor = new GPoint(19, 37); icon_metro.infoWindowAnchor = new GPoint(19, 0); var mark01 = new GMarker(new GLatLng(35.654991, 139.743477), icon_metro); map.addOverlay(mark01); var html01 = '

東京メトロ 大江戸線 赤羽橋駅

赤羽橋口から徒歩5分

'; GEvent.addListener(mark01, "click", function(marker, point) { mark01.openInfoWindowHtml(html01); }); } function initPage() { mapDiv = document.getElementById("map"); initMap(); } function clearPoints() { DistPoint = new Array(); map.removeOverlay(DistOL); document.getElementById("distance").innerHTML = "現在の積算距離 約 0km (徒歩約 0分)"; DistOL = null; } function Gdistance(from , to) { var from_x = from.x * Math.PI / 180; var from_y = from.y * Math.PI / 180; var to_x = to.x * Math.PI / 180; var to_y = to.y * Math.PI / 180; var deg = Math.sin(from_y) * Math.sin(to_y) + Math.cos(from_y) * Math.cos(to_y) * Math.cos(to_x-from_x); var dist = 6378140 * (Math.atan( -deg / Math.sqrt(-deg * deg + 1)) + Math.PI / 2); return Math.round(dist); } function drawCircle(radius, col) { var center = map.getCenter(); var circleQuality = 5; var M = Math.PI / 180; var points = []; for(var i=0; i<360; i+=circleQuality){ var P = new GLatLng( center.lat() + (radius * Math.sin(i * M)), center.lng() + (radius * Math.cos(i * M)) * 1.230608913182963 ); points.push(P); } points.push(points[0]); oldPoly = new GPolyline(points, col, 2, 0.75) map.addOverlay(oldPoly); }