//初期設定 var zoomLevel = 15; //ズームレベル var markerOn = true; //true:マーカーを表示、false:マーカー非表示 var markerName = "KON"; var infoWindowOn = true; //true:吹き出しを表示、false:吹き出し非表示 var googlemap, marker, infowindow; function mapInit() { if ( $('#map').length <= 0 ) return false; var centerPosition = new google.maps.LatLng(lat, lng); var option = { zoom : zoomLevel, center : centerPosition, mapTypeId : google.maps.MapTypeId.ROADMAP, styles: [ { "featureType": "administrative.province", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "landscape", "elementType": "all", "stylers": [ { "saturation": -100 }, { "lightness": 65 }, { "visibility": "on" } ] }, { "featureType": "poi", "elementType": "all", "stylers": [ { "saturation": -100 }, { "lightness": 51 }, { "visibility": "simplified" } ] }, { "featureType": "road.highway", "elementType": "all", "stylers": [ { "saturation": -100 }, { "visibility": "simplified" } ] }, { "featureType": "road.arterial", "elementType": "all", "stylers": [ { "saturation": -100 }, { "lightness": 30 }, { "visibility": "on" } ] }, { "featureType": "road.local", "elementType": "all", "stylers": [ { "saturation": -100 }, { "lightness": 40 }, { "visibility": "on" } ] }, { "featureType": "transit", "elementType": "all", "stylers": [ { "saturation": -100 }, { "visibility": "simplified" } ] }, { "featureType": "transit", "elementType": "geometry.fill", "stylers": [ { "visibility": "on" } ] }, { "featureType": "water", "elementType": "geometry", "stylers": [ { "hue": "#ffff00" }, { "lightness": -25 }, { "saturation": -97 } ] }, { "featureType": "water", "elementType": "labels", "stylers": [ { "visibility": "on" }, { "lightness": -25 }, { "saturation": -100 } ] } ] }; //地図本体描画 googlemap = new google.maps.Map(document.getElementById("map"), option); //中心地を保存 google.maps.event.addListener(googlemap, "dragend", function() { var mapcenter = googlemap.getCenter(); lng = mapcenter.lng(); lat = mapcenter.lat(); }); if ( markerOn ) { //マーカーを表示 var markerOption = { position : centerPosition, map : googlemap, title : markerName }; //マーカー追加 marker = new google.maps.Marker(markerOption); } if ( markerOn && infoWindowOn ) { //情報ウィンドウ infowindow = new google.maps.InfoWindow({ content: infoWindowComment }); google.maps.event.addListener(marker, "click", function() { if(infowindow) infowindow.close(); infowindow.open(googlemap, marker); }); infowindow.open(googlemap, marker); } google.maps.event.trigger(googlemap, 'resize'); } function mapMove() { if ( $('#map').length <= 0 ) return false; googlemap.panTo(new google.maps.LatLng(lat,lng)); } $(window).resize( function() { mapMove(); }); $(window).load( function(){ mapInit(); });