
| 기능 | 기능 설명 |
|---|---|
| 지도 생성 | 일반지도, 항공영상, 하이브리드 지도를 웹상에 생성하고 표출합니다. |
| 지도 이동 및 컨트롤 제공 | 마우스에 의한 지도 이동을 지원하고 지도 이동을 위한 UI 컨트롤을 제공합니다. |
| 지도 줌 및 컨트롤 제공 | 마우스에 의한 지도 줌을 지원하고 레벨별 지도 줌을 위한 UI 컨트롤을 제공합니다. |
| 축척 컨트롤 | 현재 지도의 축척 표출을 위한 UI를 제공합니다. |
| 마커 및 정보창 | 지도위의 특정지점을 표출하기 위한 마커와 연관정보를 표출하기 위한 정보창을 제공합니다. |
| 원 및 선 그리기 | 지도위에 원과 선을 그릴 수 있습니다. 선과 면에 대한 색상 및 투명도 설정을 제공합니다. |
| 다각형 그리기 | 지도위에 다각형을 그릴 수 있습니다. 선과 면에 대한 색상 및 투명도 설정을 제공합니다. |
<!DOCTYPE html>
<html lang="ko">
<head>
<title>SOP JavaScript : Map Simple</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="https://sgisapi.kostat.go.kr/OpenAPI3/auth/javascriptAuth?consumer_key=[발급받은 서비스키]"></script>
</head>
<body>
<div id="map" style="width:500px; height:500px;"></div>
<script type="text/javascript">
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
</script>
</body>
</html>
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
var map = sop.map('map');
map.mapMove = function (center, zoom, animate) {
if (animate == null) {
animate = true; //false로 설정할경우 애니메이트 효과 끔
}
if (center != null) {
this.center = map.center;
if (zoom != null) {
this.zoom = zoom;
this.setView(sop.utmk(center[0], center[1]), zoom, {
animate : animate
});
}
else {
this.setView(sop.utmk(center[0], center[1]), {
animate : animate
});
}
}
}
map.setView(sop.utmk(953820, 1953437), 9);
map.mapMove([953810,1953437],7);
function mapMove(direction){
var center = map.getCenter();
var x = center.x;
var y = center.y;
switch(direction){
case "top" :
y = y+2000;
break;
case "bottom" :
y = y-2000;
break;
case "right" :
x = x+2000;
break;
case "left" :
x = x-2000;
break;
}
map.mapMove([x,y],7,true);
}
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 1);
map.zoomIn();
map.zoomOut();
function zoomIn(){
map.zoomIn(); // 줌 레벨 한단계 확대
}
function zoomOut(){
map.zoomOut(); // 줌 레벨 한단계 축소
}
function setZoom(val){
map.setZoom(val);
}
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
var center = map.getCenter();
var level = map.getZoom();
var bounds = map.getBounds();
var swLatLng = bounds.getSouthWest();
var neLatLng = bounds.getNorthEast();
var html = "센터 : "+center.x+","+center.y+"
";
html +="줌 레벨 : "+level+"
";
html +="swLatLng : "+swLatLng+"
";
html +="neLatLng : "+neLatLng+"
";
$("#divCon").html(html);
var map = sop.map('map');
var mapMode = "normal";
var zoomMargin, crs ,baseTileLayer, targetTileLayer;
function changeMode(type){
if (type == "settlite") {
mapMode = "settlite";
crs = createSatelliteCRS();
baseTileLayer = createSatelliteTileLayer();
targetTileLayer = map.statisticTileLayer;
zoomMargin = baseTileLayer.options.minZoom - targetTileLayer.options.minZoom;
createTileLayer(map, crs, baseTileLayer, targetTileLayer, zoomMargin);
}else {
mapMode = "normal";
targetTileLayer = baseTileLayer;
baseTileLayer = map.statisticTileLayer;
zoomMargin = baseTileLayer.options.minZoom - targetTileLayer.options.minZoom;
createTileLayer(map, sop.CRS.UTMK, baseTileLayer, targetTileLayer, zoomMargin);
}
}
function changeMap(){
if(mapMode == "settlite"){
changeMode("normal");
}else{
changeMode("settlite");
}
}
/**
*
* @name : createSatelliteCRS
* @description : 위성지도에 사용하는 좌표체계 생성
*/
function createSatelliteCRS(){
var code = 'EPSG:900913';
var def = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs';
var options = {
resolutions: [
156543.0339,
78271.51695,
39135.758475,
19567.8792375,
9783.93961875,
4891.969809375,
2445.9849046875,
1222.99245234375,
611.496226171875,
305.7481130859375,
152.87405654296876,
76.43702827148438,
38.21851413574219,
19.109257067871095,
9.554628533935547,
4.777314266967774,
2.388657133483887,
1.1943285667419434,
0.5971642833709717,
0.29858214168548586,
0.14929107084274293
],
origin: [-20037508.34, 20037508.34]
};
// 새로 정의한 CRS 객체 생성.
var crs = new sop.CRS.Proj(code, def, options);
// projection 영역 설정.
crs.projection.bounds = sop.bounds(
[13232210.28055642, 3584827.864295762],
[15238748.249933105, 5575460.5658249445]
);
return crs;
}
/**
*
* @name : createTileLayer
* @description : 타일레이어 토글버튼 생성
*/
function createTileLayer(map, crs, baseLayer, targetLayer, zoomMargin) {
if(arguments.length < 5) {
throw new Error('Fail check arguments length. current = ' + arguments.length);
}
if(map.hasLayer(baseLayer)){
return;
}
var center = map.getCenter();
var zoom = map.zoom;
map.removeLayer(targetLayer);
map.options.crs = crs;
baseLayer.addTo(map);
//좌표 초기화
map.setView(sop.utmk(953820, 1953437), 9);
}
/**
*
* @name : createSatelliteTileLayer
* @description : 위성 타일레이어 생성
*/
function createSatelliteTileLayer(){
var satTileURL = "https://xdworld.vworld.kr/2d/Satellite/service/{z}/{x}/{y}.jpeg";
var satTileOptions = {
maxZoom: 18,
minZoom: 6
};
var satTileLayer = new sop.TileLayer(satTileURL, satTileOptions);
return satTileLayer;
}
map.setView(sop.utmk(953820, 1953437), 9);
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
map.on("movestart",function(e) {
setTimeout(function() {
var html = ""+ getTime() + " 이동 시작
";
$("#divCon").append(html);
}, 200);
});
map.on("moveend",function(e) {
setTimeout(function() {
var html = ""+ getTime() + " 이동 끝
";
$("#divCon").append(html);
}, 200);
});
function getTime(){
var date = new Date();
var m = date.getMonth()+1;
var d = date.getDate();
var h = date.getHours();
var i = date.getMinutes();
var s = date.getSeconds();
return date.getFullYear()+'-'+(m>9?m:'0'+m)+'-'+(d>9?d:'0'+d)+' '+(h>9?h:'0'+h)+':'+(i>9?i:'0'+i)+':'+(s>9?s:'0'+s);
}
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
map.on("zoomstart",function(e) {
setTimeout(function() {
var html = ""+ getTime() + " 줌 시작
";
$("#divCon").append(html);
}, 200);
});
map.on("zoomend",function(e) {
setTimeout(function() {
var html = ""+ getTime() + " 줌 종료
";
$("#divCon").append(html);
}, 200);
});
function getTime(){
var date = new Date();
var m = date.getMonth()+1;
var d = date.getDate();
var h = date.getHours();
var i = date.getMinutes();
var s = date.getSeconds();
return date.getFullYear()+'-'+(m>9?m:'0'+m)+'-'+(d>9?d:'0'+d)+' '+(h>9?h:'0'+h)+':'+(i>9?i:'0'+i)+':'+(s>9?s:'0'+s);
}
var map = sop.map('map');
map.whenReady(function(e) {
$("#divCon").append(""+getTime()+"생성완료
");
});
function getTime(){
var date = new Date();
var m = date.getMonth()+1;
var d = date.getDate();
var h = date.getHours();
var i = date.getMinutes();
var s = date.getSeconds();
return date.getFullYear()+'-'+(m>9?m:'0'+m)+'-'+(d>9?d:'0'+d)+' '+(h>9?h:'0'+h)+':'+(i>9?i:'0'+i)+':'+(s>9?s:'0'+s);
}
map.setView(sop.utmk(953820, 1953437), 9);
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
map.on("click",function(e) {
setTimeout(function() {
var x_coor = e.utmk.x;
var y_coor = e.utmk.y;
var html = ""+ getTime() + " 지도클릭 좌표 x :"+x_coor+" , y :"+y_coor+"
";
$("#divCon").append(html);
}, 200);
});
function getTime(){
var date = new Date();
var m = date.getMonth()+1;
var d = date.getDate();
var h = date.getHours();
var i = date.getMinutes();
var s = date.getSeconds();
return date.getFullYear()+'-'+(m>9?m:'0'+m)+'-'+(d>9?d:'0'+d)+' '+(h>9?h:'0'+h)+':'+(i>9?i:'0'+i)+':'+(s>9?s:'0'+s);
}
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
map.dragging.disable();
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
map.scrollWheelZoom.disable(); //zoomin zoomout 불가
var map = sop.map('map');
map.setView(sop.utmk(989674, 1818313), 9);
function getLocationCoords(){
var center = [989674, 1818313];
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var utmkXY = new sop.LatLng (position.coords.latitude, position.coords.longitude);
center = [utmkXY.x, utmkXY.y];
console.log(position.coords.latitude);
console.log(position.coords.longitude);
var html = "latitude = " + position.coords.latitude +" , longitude " + position.coords.longitude+"
";
html += "x = "+utmkXY.x+", y="+utmkXY.y+"
";
$("#divCon").append(html);
});
}
/* return center; */
}
getLocationCoords();
var map = sop.map('map');
var utmkXY = new sop.LatLng (36.3504119,127.3845475); //wgs84 좌표를 UTMK로 변환
map.setView(sop.utmk(utmkXY.x, utmkXY.y), 9);
var html = "wgs84 : 36.3504119,127.3845475
";
html += "x = "+utmkXY.x+" , y = "+utmkXY.y+"
";
$("#divCon").append(html);
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
map.on("click",function(e) {
setTimeout(function() {
var x_coor = e.utmk.x;
var y_coor = e.utmk.y;
var html = " 지도클릭 좌표 x :"+x_coor+" , y :"+y_coor+"
";
$("#divCon").append(html);
}, 200);
});
//맵에 왼쪽 마우스 버튼 클릭시 좌표 반환
map.on("contextmenu",function(e) {
setTimeout(function() {
var x_coor = e.utmk.x;
var y_coor = e.utmk.y;
var html = " 지도클릭 좌표 x :"+x_coor+" , y :"+y_coor+"
";
$("#divCon").append(html);
}, 200);
});
var map = sop.map('map');
map.setView(sop.utmk(953820, 1953437), 9);
var bounds = map.getBounds();
var swLatLng = bounds.getSouthWest();
var neLatLng = bounds.getNorthEast();
var html = "southWest = " + swLatLng + " , northEast = " + neLatLng+"
";
$("#divCon").append(html);
var map = sop.map('map',{
scale: false // 축척 컨트롤
});
map.setView(sop.utmk(953820, 1953437), 9);
var map = sop.map('map',{
panControl: true // 지도 이동 컨트롤
});
map.setView(sop.utmk(953820, 1953437), 9);
var map = sop.map('map',{
zoomSliderControl: true //줌 컨트롤
});
map.setView(sop.utmk(953820, 1953437), 9);
var map = sop.map('map',{
measureControl: true, // 측정 컨트롤 (면적, 길이)
});
map.setView(sop.utmk(953820, 1953437), 9);
var map = sop.map('map',{
ollehTileLayer: false,
scale: false, // 축척 컨트롤
panControl: false, // 지도 이동 컨트롤
zoomSliderControl: false, //줌 컨트롤
measureControl: false, // 측정 컨트롤 (면적, 길이)
attributionControl: false // 지도속성 컨트롤
});
var setUI = sop.control({position :'topright'});
setUI.onAdd = function(map){
this._div = sop.DomUtil.create('div', 'info');
sop.DomEvent.disableClickPropagation(this._div);
this.update();
$(this._div).attr("id", 'set_map');
return this._div;
}
setUI.update = function(props){
var html = "";
html += "";
html += "맵기능설정";
html += "";
html += "
";
html += "";
this._div.innerHTML = html;
}
setUI.addTo(map);
map.setView(sop.utmk(953820, 1953437), 9);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var marker = sop.marker([953427, 1950827]);
marker.addTo(map);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var marker = sop.marker([953427, 1950827]);
marker.addTo(map).bindInfoWindow("경복궁 ").openInfoWindow();
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 1);
var infoWindow = sop.infoWindow();
var contents = "";
contents += "<div style='font-family: dotum, arial, sans-serif;font-size: 18px; font-weight: bold;margin-bottom: 5px;'>경복궁"</div>";
contents += "<table style='border-spacing:2px;border:0px;'>";
contents += "<tbody>";
contents += "<tr>";
contents += "<td style='width:40px;color:#767676;padding-right:12px'>사이트";
contents += "<td>홈페이지";
contents += "</tr>";
contents += "<tr>";
contents += "<td style='color:#767676;padding-right:12px'>주소";
contents += "<td>서울특별시 종로구 사직로9길 22 (필운동)";
contents += "</tr>";
contents += "<tr>";
contents += "<td style='color:#767676;padding-right:12px'>소개";
contents += "<td>경복궁은 1395년 태조 이성계에 의해서 새로운 조선왕조의 법궁으로 지어졌다. 경복궁은 동궐(창덕궁)이나 서궐(경희궁)에 비해 위치가 ...";
contents += "</tr>";
contents += "<tr>";
contents += "<td style='color:#767676;padding-right:12px'>출처";
contents += "<td>visitkorea.or.kr";
contents += "</tr>";
contents += "</tbody>";
contents += "</table>";
infoWindow.setUTMK([953820, 1953437]);
infoWindow.setContent(contents);
infoWindow.openOn(map);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var marker = sop.marker([953427, 1950827]);
marker.on("click",function(e){
alert("마커 클릭");
});
marker.addTo(map);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var marker1 = sop.marker([953427, 1950827]);
var marker2 = sop.marker([953427, 1950727]);
var marker3 = sop.marker([953427, 1950627]);
var markerList = sop.markerClusterGroup({
animateAddingMarkers: true
});
map.addLayer(markerList);
markerList.addLayer(marker1);
markerList.addLayer(marker2);
markerList.addLayer(marker3);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var myIcon = sop.icon({
iconUrl: '/img/idm/bus.png',
shadowUrl: '/img/idm/bus-shadow.png',
iconSize: [32, 32],
shadowSize: [32, 32],
iconAnchor: [22, 0],
shadowAnchor: [5, 0],
popupAnchor: [-3, -76]
});
var marker = sop.marker([953427, 1950827], {icon: myIcon}); //마커 생성시 myIcon 옵션값이용 마커 생성
marker.addTo(map); //마커를 map 추가
var map = sop.map('map');
var html = "";
html += "
버스정류장";
html += "";
var icon = new sop.DivIcon({html:html, className: "div_icon", iconSize: new sop.Point(7, 7), iconAnchor: new sop.Point(6,6), infoWindowAnchor: new sop.Point(1,-5)});
map.setView(sop.utmk(953427, 1950827), 5);
var marker = sop.marker([953427, 1950827], {
icon : icon
});
marker.addTo(map);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var marker = sop.circleMarker([953427, 1950827], {
radius : 17,
fillColor : "#03f",
weight : 2,
});
marker.addTo(map);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var marker1 = sop.marker([953427, 1950827],{zIndexOffset : 3});
var marker2 = sop.marker([953427, 1950827],{zIndexOffset : 2});
var marker3 = sop.marker([953427, 1950827],{zIndexOffset : 1});
marker1.addTo(map);
marker2.addTo(map);
marker3.addTo(map);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var polylines = [
[949279, 1951131],
[950631, 1950331],
[951063, 1949091]
];
var polyline = sop.polyline(polylines, {
stroke: true,
color: 'blue',
weight : 3,
opacity: 1,
fill: false,
fillColor:'blue',
fillOpacity: 0.2,
});
polyline.bindInfoWindow("폴리라인 입니다.");
polyline.addTo(map);
map.fitBounds(polyline);
var map = sop.map("map"); //map 생성
map.setView(sop.utmk(953427, 1950827), 5); // 지도 중심좌표로 뷰 설정
//지도에 표시되는 폴리곤 데이터
var polygons = [
[
[949279, 1951131],
[950631, 1950331],
[951063, 1949091]
]
];
//폴리곤 생성
var polygon = sop.polygon(polygons,
{
stroke: true,
color: "red",
weight : 3,
opacity: 1,
fill: true,
fillColor:"red",
fillOpacity: 0.2
});
polygon.bindInfoWindow("폴리곤 입니다."); //인포 윈도우 바인드
polygon.addTo(map); //지도에 폴리곤 추가
map.fitBounds(polygon); ////fitBounds 최대 줌 레벨로 polygon데이터를 보여 줍니다
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var circle = sop.circle([953335, 1950717]);
circle.setRadius(2000);
circle.bindInfoWindow("써클 입니다.");
circle.addTo(map);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var rectangles = [
[953335, 1950717],
[993935, 1958917]
];
var rectangle = sop.rectangle(rectangles, {
color: "#ff7800",
weight: 1
});
rectangle.bindInfoWindow("사각형 입니다.");
rectangle.addTo(map);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var geoData = {"type": "FeatureCollection", "features": [
{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [
[
[957648, 1966942],[959082, 1965955],[960333, 1965738],[961709, 1965784],[962036, 1966176],
[963128, 1966394],[964064, 1965652],[964428, 1962455],[965312, 1960690],[965702, 1960388],
[966315, 1956506],[966029, 1954964],[964926, 1953671],[964773, 1951259],[966144, 1951253],
[966649, 1951724],[967634, 1952167],[970119, 1953213],[971362, 1953481],[971875, 1951424],
[971981, 1949739],[970247, 1949573],[968323, 1946314],[968281, 1945191],[968675, 1944965],
[969636, 1944792],[969737, 1944923],[970068, 1944607],[969921, 1943869],[968999, 1942191],
[966170, 1940397],[964345, 1940121],[962383, 1938222],[961997, 1936853],[960517, 1936761],
[958928, 1938129],[959077, 1938697],[958928, 1939913],[958779, 1940422],[958424, 1940575],
[955537, 1940643],[953478, 1938848],[952074, 1937952],[950607, 1937646],[949824, 1938556],
[947877, 1937655],[946815, 1937968],[945715, 1939863],[944616, 1942967],[944828, 1943270],
[944089, 1943965],[942163, 1942199],[942112, 1941820],[940060, 1942052],[939850, 1942301],
[939583, 1944502],[940035, 1944970],[940290, 1945653],[940542, 1947533],[940116, 1949254],
[938413, 1949533],[938101, 1949120],[937604, 1949135],[935619, 1950179],[935318, 1950789],
[935796, 1951149],[936659, 1952928],[937634, 1953813],[938095, 1954545],[937944, 1955684],
[938376, 1956365],[938697, 1956256],[940307, 1954643],[942686, 1953113],[943281, 1952998],
[944891, 1953539],[947014, 1954664],[948177, 1960790],[951230, 1962308],[952080, 1961600],
[953135, 1960044],[953393, 1959333],[953653, 1959260],[954495, 1959778],[955367, 1963192],
[955367, 1964647],[956974, 1966631],[957326, 1966942],[957648, 1966942]
]
]}, "properties": {"Name": "11", "Description": "서울특별시"}}
]};
sop.geoJson(geoData, {
style: function () {
return {
weight: 2,
opacity: 1,
color: '#565656',
dashArray: '3',
fillOpacity: 0.7
};
},
onEachFeature: function (feature, layer) {
layer.bindInfoWindow(feature.properties.Description);
}
}).addTo(map);
var map = sop.map("map"); //map 생성
map.setView(sop.utmk(953427, 1950827), 5); // 지도 중심좌표로 뷰 설정
//지도에 표시되는 폴리곤 데이터
var polygons = [
[
[949279, 1951131],
[950631, 1950331],
[951063, 1949091]
]
];
//폴리곤 생성
var polygon = sop.polygon(polygons, {
stroke: true,
color: "red",
weight : 3,
opacity: 1,
fill: true,
fillColor:"red",
fillOpacity: 0.2
});
polygon.addTo(map); //지도에 폴리곤 추가
polygon.setCaption({title:"폴리곤 캡션 생성", color:"black"});
map.fitBounds(polygon); ////fitBounds 최대 줌 레벨로 polygon데이터를 보여 줍니다
var map = sop.map("map"); //map 생성
map.setView(sop.utmk(953427, 1950827), 5); // 지도 중심좌표로 뷰 설정
//지도에 표시되는 폴리곤 데이터
var polygons = [
[
[949279, 1951131],
[950631, 1950331],
[951063, 1949091]
]
];
//폴리곤 생성
var polygon = sop.polygon(polygons, {
stroke: true,
color: "red",
weight : 3,
opacity: 1,
fill: true,
fillColor:"red",
fillOpacity: 0.2
});
polygon.on("click",function(e){alert("폴리곤 클릭");}); //polygon에 대한 이벤트 등록
polygon.addTo(map); //지도에 폴리곤 추가
map.fitBounds(polygon); ////fitBounds 최대 줌 레벨로 polygon데이터를 보여 줍니다
var mapOptions = {
statisticTileLayer: true
};
var map = sop.map('map',mapOptions);
map.setView([953427, 1950827], 5);
var runLayer = sop.kml('/upload/myData/sample.kml')
.on('ready', function(e) {
map.fitBounds(runLayer.getBounds());
}).addTo(map);
var map, totalCnt, heatDatas;
heatDatas = [
[ 953424, 1950945.5],
[ 953427, 1950919],
[ 953429.5, 1950884],
[ 953429, 1950842.5],
[ 953429.5, 1950812],
[ 953426.5, 1950765],
[ 953426.5, 1950717],
[ 953428, 1950678.5],
[ 953424.5, 1950898.5],
[ 953426, 1950868],
[ 953428.5, 1950835],
[ 953425.5, 1950795.5],
[ 953427.5, 1950738.5],
[ 953423.5, 1950716],
[ 953419, 1950692],
[ 953372, 1950766],
[ 953355, 1950710],
[ 953370, 1950673],
[ 953395, 1950650],
[ 953408, 1950630],
[ 953397, 1950703],
[ 953382, 1950707],
[ 953374, 1950673],
[ 953453, 1950659],
[ 953503, 1950672],
[ 953517, 1950740],
[ 953533, 1950762],
[ 953490, 1950778],
[ 953511, 1950798],
[ 953532, 1950779],
[ 953548, 1950778],
[ 953567, 1950771],
[ 953471, 1950644],
[ 953438, 1950621],
[ 953342, 1950644],
[ 953363, 1950689],
[ 953340, 1950690],
[ 953348, 1950744],
[ 953347, 1950784]
];
map = sop.map('map');
map.setView([ 953427, 1950827 ], 13);
var heat = sop.heatLayer(heatDatas).addTo(map);
heat.setOptions({
minOpacity : 0.01,
radius : 5,
blur : 5,
max : 1
});
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 8);
var marker1 = sop.marker([953425, 1950124],{opacity : 0});
var marker2 = sop.marker([953422, 1950423],{opacity : 0.5});
var marker3 = sop.marker([953427, 1950827],{opacity : 1});
marker1.addTo(map);
marker2.addTo(map);
marker3.addTo(map);
marker1.setOpacity(0.7);
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var marker = sop.marker([953427, 1950127]);
marker.addTo(map);
marker._icon.src = "/img/tech/ico_supply_marker01.png";
var map, totalCnt, heatDatas;
heatDatas = [
[ 953424, 1950945.5],
[ 953427, 1950919],
[ 953429.5, 1950884],
[ 953429, 1950842.5],
[ 953429.5, 1950812],
[ 953426.5, 1950765],
[ 953426.5, 1950717],
[ 953428, 1950678.5],
[ 953424.5, 1950898.5],
[ 953426, 1950868],
[ 953428.5, 1950835],
[ 953425.5, 1950795.5],
[ 953427.5, 1950738.5],
[ 953423.5, 1950716],
[ 953419, 1950692],
[ 953372, 1950766],
[ 953355, 1950710],
[ 953370, 1950673],
[ 953395, 1950650],
[ 953408, 1950630],
[ 953397, 1950703],
[ 953382, 1950707],
[ 953374, 1950673],
[ 953453, 1950659],
[ 953503, 1950672],
[ 953517, 1950740],
[ 953533, 1950762],
[ 953490, 1950778],
[ 953511, 1950798],
[ 953532, 1950779],
[ 953548, 1950778],
[ 953567, 1950771],
[ 953471, 1950644],
[ 953438, 1950621],
[ 953342, 1950644],
[ 953363, 1950689],
[ 953340, 1950690],
[ 953348, 1950744],
[ 953347, 1950784]
];
map = sop.map('map');
map.setView([ 953427, 1950827 ], 13);
var heat = sop.heatLayer(heatDatas).addTo(map);
heat.setOptions({
minOpacity : 0.01,
radius : 1,
blur : 5,
max : 1
});
function radiusChange(val){
console.log(val);
heat.setOptions({
minOpacity : 0.01,
radius : val,
blur : 5,
max : 1
});
}
var map = sop.map("map"); //map 생성
map.setView(sop.utmk(953427, 1950827), 5); // 지도 중심좌표로 뷰 설정
//지도에 표시되는 폴리곤 데이터
var polygons = [
[
[949290,1951077],
[950746,1951149],
[950898,1949325],
[949402,1949253]
]
];
//폴리곤 생성
var polygon = sop.polygon(polygons, {
stroke: true,
color: "red",
weight : 3,
opacity: 1,
fill: true,
fillColor:"red",
fillOpacity: 0.2
});
polygon.addTo(map); //지도에 폴리곤 추가
map.fitBounds(polygon); ////fitBounds 최대 줌 레벨로 polygon데이터를 보여 줍니
map.on("contextmenu",function(e) {
setTimeout(function() {
var x_coor = e.utmk.x;
var y_coor = e.utmk.y;
console.log(x_coor);
console.log(y_coor);
}, 200);
});
var markerList = new Array();
var markerXY = [
[951054,1949891],
[950500,1950219],
[950748,1949727],
[949930,1950567],
[950526,1950317],
[949882,1950053],
[950260,1949803],
[947794,1950377]
];
for(var i = 0; i < markerXY.length; i ++){
var marker = sop.marker([ markerXY[i][0], markerXY[i][1]]);
markerList.push(marker);
marker.addTo(map);
}
for(var i = 0; i < markerList.length; i++){
if(polygon.getBounds().contains([ markerXY[i][0], markerXY[i][1]])){
markerList[i]._icon.src = "/img/tech/ico_supply_marker01.png";
}
}
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var markerList = new Array();
var markerClusterList = null;
var markerDataList = [
[ 953424, 1950945.5],
[ 953427, 1950919],
[ 953429.5, 1950884],
[ 953429, 1950842.5],
[ 953429.5, 1950812],
[ 953426.5, 1950765],
[ 953426.5, 1950717],
[ 953428, 1950678.5],
[ 953424.5, 1950898.5],
[ 953426, 1950868],
[ 953428.5, 1950835],
[ 953425.5, 1950795.5],
[ 953427.5, 1950738.5],
[ 953423.5, 1950716],
[ 953419, 1950692],
[ 953372, 1950766],
[ 953355, 1950710],
[ 953370, 1950673],
[ 953395, 1950650],
[ 953408, 1950630],
[ 953397, 1950703],
[ 953382, 1950707],
[ 953374, 1950673],
[ 953453, 1950659],
[ 953503, 1950672],
[ 953517, 1950740],
[ 953533, 1950762],
[ 953490, 1950778],
[ 953511, 1950798],
[ 953532, 1950779],
[ 953548, 1950778],
[ 953567, 1950771],
[ 953471, 1950644],
[ 953438, 1950621],
[ 953342, 1950644],
[ 953363, 1950689],
[ 953340, 1950690],
[ 953348, 1950744],
[ 953347, 1950784]
];
function addLayer(val){
markerClusterList = sop.markerClusterGroup({
animateAddingMarkers: true,
maxClusterRadius : val
});
map.addLayer(markerClusterList);
for(var i = 0; i < markerDataList.length; i++ ){
var marker = sop.marker([markerDataList[i][0], markerDataList[i][1]]);
markerList.push(marker);
markerClusterList.addLayer(marker);
}
}
function removeLayer(){
map.removeLayer(markerClusterList);
}
function refreashMap(val){
removeLayer();
addLayer(val);
}
addLayer(10)
var map = sop.map("map"); //map 생성
map.setView(sop.utmk(953427, 1950827), 5); // 지도 중심좌표로 뷰 설정
var markerList = new Array();
var markerXY = [
[951054,1949891],
[950500,1950219],
[950748,1949727],
[949930,1950567],
[950526,1950317],
[949882,1950053],
[950260,1949803],
[947794,1950377]
];
var markerObjectList = new Array();
for(var i = 0; i < markerXY.length; i ++){
var marker = sop.marker([ markerXY[i][0], markerXY[i][1]]);
markerList.push(marker);
marker.addTo(map);
markerObjectList.push({x:markerXY[i][0], y:markerXY[i][1] });
}
var point = sop.QuickHull.getConvexHull(markerObjectList);
var polygon = sop.polygon(point, {
stroke: true,
color: "red",
weight : 3,
opacity: 1,
fill: true,
fillColor:"red",
fillOpacity: 0.2
});
polygon.addTo(map); //지도에 폴리곤 추가
map.fitBounds(polygon); ////fitBounds 최대 줌 레벨로 polygon데이터를 보여 줍니다.
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
var marker = sop.circleMarker([953427, 1950827], {
radius : 17,
fillColor : "#03f",
fillOpacity : 1,
weight : 2,
});
marker.addTo(map);
function markerColorChange(){
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
marker.setStyle({
fillColor : color,
color : color
});
}
function markerOpacityChange(val){
console.log(val);
marker.setStyle({
fillOpacity : val
});
}
var legendColor = ["#ccc", "#c2b5b9", "#b99ea6", "#b08893", "#a77180", "#9e5a6d", "#95445a", "#8c2d47", "#831634", "#7a0021"];
var legendCircleRadius = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55];
var circleMarkerList = null;
var heat = null;
var map, mapOptions, oriArea, sopArea, logger, divConsole;
logger = divLogger();
mapOptions = {
ollehTileLayer: true,
measureControl: false,
zoomSliderControl: false,
panControl: false,
attributionControl: false
};
map = sop.map("map", mapOptions);
map.setView([953427, 1950827], 0);
function tokenKeySetting(){
accessToken = $("#tokenKey").val();
}
function createServiceRequest(reqFunc, reqParam) {
return function () {
// 인증 API
$.ajax({
url : 'https://sgisapi.kostat.go.kr/OpenAPI3/auth/authentication.json' +
'?consumer_key='+consumer_key+'&consumer_secret='+consumer_secret,
type : 'get',
success: function (res, status) {
reqParam.accessToken = res.result.accessToken;
reqFunc(reqParam);
}
});
}
}
sop.DomUtil.get("clear").onclick = clear;
divConsole = sop.DomUtil.get("divCon");
function addArea(type) {
if($("#tokenKey").val() == ""){
alert("키를 입력해주세요");
return;
}
clear();
var year = "2010";
var adm_cd = "11";
$.ajax({
url : 'https://sgisapi.kostat.go.kr/OpenAPI3/boundary/hadmarea.geojson' +
'?accessToken='+ accessToken +'&year='+year+'&adm_cd='+adm_cd,
type : 'get',
datatype : "geojson",
success: function( res,status) {
oriArea = res;
if(type=="color"){
sopArea = sop.geoJson(res).addTo(map);
map.fitBounds(sopArea.getBounds());
}else if(type=="bubble" || type=="dot" || type=="heat"){
circleMarkerList = makeCircleList(res);
}
logger("경계조회 결과");
logger("" + JSON.stringify(res, null, 2) + "
");
},
complete : function(){
addStatistic(type);
},
});
}
function addStatistic(type) {
if (!oriArea) {
alert("경계조회를 먼저 하세요");
return;
}
var year = "2010";
var adm_cd = "11";
var low_search = "1";
$.ajax({
url : 'https://sgisapi.kostat.go.kr/OpenAPI3/stats/population.json' +
'?accessToken='+accessToken+'&year='+year+'&adm_cd='+adm_cd+
'&low_search=' +low_search,
type : 'get',
success: function (res,status) {
// 맵형태로 변환 한다.
var idx, len, target, conComplite = {}, key, value, strToolTip;
target = res.result;
for (idx = 0, len = target.length; idx < len; idx ++) {
conComplite[target[idx].adm_cd] = target[idx];
}
var objectList = new Array();
logger("----------- [ 가구통계 조회 성공 ] -----------");
logger("" + JSON.stringify(res, null, 2) + "
");
if(type=="color"){
sopArea.eachLayer(function (layer) {
key = layer.feature.properties.adm_cd;
value = conComplite[key];
if (!value) { return; }
strToolTip = "지역(구)명 : " + value.adm_nm + "
";
strToolTip += "총인구 : " + value.tot_ppltn + "
";
strToolTip += "ADM : " + key + "
";
layer.bindToolTip(strToolTip);
var object = new Object();
object.value = value.tot_ppltn;
object.admCd = key;
objectList.push(object);
});
}else if(type == "bubble" || type == "dot" || type == "heat"){
for(var i = 0; i < circleMarkerList.length; i++){
var infos = circleMarkerList[i].options.infos;
key = infos.adm_cd;
value = conComplite[key];
if (!value) { return; }
strToolTip = "지역(구)명 : " + value.adm_nm + "
";
strToolTip += "총인구 : " + value.tot_ppltn + "
";
strToolTip += "ADM : " + key + "
";
circleMarkerList[i].options.tooltipMsg = strToolTip;
circleMarkerList[i].bindInfoWindow(circleMarkerList[i].options.tooltipMsg);
var object = new Object();
object.value = value.tot_ppltn;
object.admCd = key;
objectList.push(object);
}
}
var legend = calculateLegend(objectList);
if(type=="color"){
areaFillColor(objectList,legend);
}else if(type == "bubble"){
circleMarkerList = areaSizeCircle(objectList,legend,circleMarkerList);
gridCirCle(circleMarkerList);
}else if(type == "dot"){
gridCirCle(circleMarkerList);
}else if(type == "heat"){
circleMarkerList = areaSizeCircle(objectList,legend,circleMarkerList);
addHeatMap(circleMarkerList);
}
}
});
}
function clear() {
if (sopArea) {
sopArea.remove();
}
if(heat !=null){
map.removeLayer(heat);
}
if(circleMarkerList !=null){
for(var i =0; i < circleMarkerList.length; i ++){
circleMarkerList[i].remove();
}
}
sopArea = undefined;
oriArea = undefined;
divConsole.innerHTML = "";
logger("------------- 지도초기화 완료 -------------");
}
function divLogger() {
var lineNum = 0;
var prefix = "";
return function (str) {
prefix = lineNum++ + " : ";
str = prefix + str;
if (divConsole.innerHTML.length < 300000) {
divConsole.innerHTML += str;
} else {
divConsole.innerHTML = str;
}
divConsole.innerHTML += "
";
divConsole.scrollTop = divConsole.scrollHeight;
};
}
function areaFillColor(objectList,legend){
sopArea.eachLayer(function (layer) {
var admCd = layer.feature.properties.adm_cd;
for(var i =0; i < objectList.length; i++){
if(objectList[i].admCd == admCd){
if(legend[legend.length-1] <= objectList[i].value){
layer.setStyle({
weight : 3,
color : legendColor[legend.length-1],
fillColor :legendColor[legend.length-1]
});
}else{
for(var j=0; j < legend.length; j ++){
if(legend[j] >= objectList[i].value){
layer.setStyle({
weight : 3,
color : legendColor[j],
fillColor :legendColor[j]
});
break;
}
}
}
}
}
});
}
function areaSizeCircle(objectList,legend,circleMarkerList){
//options.radius
for(var i = 0; i < circleMarkerList.length; i++){
if(legend[legend.length-1] <= objectList[i].value){
circleMarkerList[i].setStyle({
color : legendColor[legend.length-1],
fillColor : legendColor[legend.length-1],
radius : legendCircleRadius[legend.length-1]
});
}else{
for(var j = 0; j < legend.length; j++){
if(legend[j] >= objectList[i].value){
circleMarkerList[i].setStyle({
color : legendColor[j],
fillColor : legendColor[j],
radius : legendCircleRadius[j]
});
break;
}
}
}
}
return circleMarkerList;
}
function gridCirCle(circleList){
for(var i =0; i < circleList.length; i++){
circleList[i].addTo(map);
}
}
function makeCircleList(geoData){
var features = geoData.features;
var markerList = new Array();
for(var i =0; i < features.length; i ++){
var marker = sop.circleMarker([features[i].properties.x, features[i].properties.y], {
radius : legendCircleRadius[0],
fillColor : "red",
color : "red",
weight : 1,
tooltipMsg : "",
infos : {
idx : i,
adm_cd : features[i].properties.adm_cd,
adm_nm : features[i].properties.adm_nm,
data : "",
}
});
markerList.push(marker);
}
return markerList;
}
function addHeatMap(circleList){
heat = sop.heatLayer();
heat.addTo(map);
heat.setOptions({
minOpacity : 0.01,
radius : 5,
blur : 5,
max : 1
});
var xyList = new Array();
for(var i =0; i < circleList.length;i++){
xyList[i] = [circleList[i]._utmk.x,circleList[i]._utmk.y];
console.log(circleList[i]._radius);
heat.addUTMK([circleList[i]._utmk.x,circleList[i]._utmk.y,(circleList[i]._radius * 100000)]);
}
}
function calculateLegend(list){
if(list == null || list.length == 0){
return;
}
var arData = new Array();
arData[0] = new Array();
for(var i = 0; i < list.length; i++){
arData[0].push(list[i].value);
}
var legendValue = new Object();
legendValue.equal = [];
legendValue.auto = [];
var tmpData = [];
for (var i=0; i < arData.length; i++) {
var tmpData = arData[i];
for (var x=0; x < tmpData.length; x++) {
tmpData[x] = parseFloat(parseFloat(tmpData[x]).toFixed(2));
}
}
return calEqualLegend(arData);
}
function calEqualLegend(arData){
var equalMin, equalMax;
var tmpValPerSlice = [];
for ( var k = 0; k < arData.length; k++) {
if (arData[k].length == 1) {
var data = arData[k][0];
var tmpResult = new Array();
for ( var x = 0; x < 10; x++) {
var value = data+(data*x);
tmpResult.push(parseFloat(parseFloat(value).toFixed(2)));
}
tmpValPerSlice[k] = tmpResult;
}else {
var min = Math.min.apply(null, arData[k]);
var max = Math.max.apply(null, arData[k]);
equalMin = min;
equalMax = max;
var result = (max - min) / (10);
if (result == 0 && min != max) {
result = 1;
}
var tmpResult = new Array();
for ( var y=0; y <10; y++) {
if (result == 1 && min != max) {
tmpResult.push(result);
}else {
tmpResult.push(parseFloat(parseFloat((min+result * y)).toFixed(2))); //그래서 303 + 57*
}
}
tmpValPerSlice[k] = tmpResult;
}
}
return tmpValPerSlice[0];
}


var map = sop.map("map"); //map 생성
map.setView(sop.utmk(953427, 1950827), 5); // 지도 중심좌표로 뷰 설정
//지도에 표시되는 폴리곤 데이터
var polygons = [
[
[949279, 1951131],
[950631, 1950331],
[951063, 1949091]
]
];
//폴리곤 생성
var polygon = sop.polygon(polygons, {
stroke: true,
color: "red",
weight : 3,
opacity: 1,
fill: true,
fillColor:"red",
fillOpacity: 0.2
});
polygon.addTo(map); //지도에 폴리곤 추가
polygon.setCaption({title:"폴리곤 캡션 생성", color:"black"});
map.fitBounds(polygon); ////fitBounds 최대 줌 레벨로 polygon데이터를 보여 줍니다
function saveCaption(){
polygon.removeCaption();
polygon.setCaption({title:$("#captionText").val(), color:"black"});
$(".popupWrapper").remove();
}
var map = sop.map('map');
map.setView(sop.utmk(953427, 1950827), 5);
//맵에 왼쪽 마우스 버튼 클릭시 마커 생성
map.on("contextmenu",function(e) {
setTimeout(function() {
var x_coor = e.utmk.x;
var y_coor = e.utmk.y;
var marker = sop.marker([ x_coor, y_coor]);
marker.addTo(map);
}, 200);
});