OPEN API 맵클릭시 리턴값 받을때 에러가 발생합니다.
리턴값을 받을수 있나요
<!DOCTYPE html>
<html>
<head>
<title>WMS GetFeatureInfo (Tile x-layer)</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.11.1/ol.min.css">
<x-script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.11.1/ol.min.js"></x-script>
<x-script src="https://code.jquery.com/jquery-3.1.1.min.js"></x-script>
</head>
<style>
#map {
width: 100%;
height: 600px;
}
</style>
<body>
<div id="map" class="map"></div>
<div id="info"> </div>
<x-script>
var wmsSource = new ol.source.TileWMS({
url: 'http://egisapp.me.go.kr/geoserver/wms?',
params: { 'x-layerS': 'EGIS:lv1_1980yr', 'TILED': true },
// serverType: 'geoserver',
//crossOrigin: 'anonymous'
});
var wmsx-layer = new ol.x-layer.Tile({
source: wmsSource
});
var view = new ol.View({
center: ol.proj.transform([127, 36.5], 'EPSG:4326', 'EPSG:3857'),
zoom: 7,
enableRotation: false
});
var map = new ol.Map({
x-layers: [wmsx-layer],
target: 'map',
view: view
});
map.on('singleclick', function (evt) {
x-document.getElementById('info').innerHTML = '';
var viewResolution = /** @type {number} */ (view.getResolution());
var url = wmsSource.getGetFeatureInfoUrl(
evt.coordinate, viewResolution, 'EPSG:3857',
{ 'INFO_FORMAT': 'application/json', 'FEATURE_COUNT': 1 });
if (url) {
var parser = new ol.format.GeoJSON();
console.log(url);
$.ajax({
type: "get",
url: url,
crossOrigin: true,
dataType: 'json',
async: false,
success: function(data) {
console.log(url);
},
error: function(xhr, stat, err) {}
});
}
});
</x-script>
</body>
</html>