이 문제를 해결하려고했지만 며칠 동안 올바른 대답을 얻지 못했습니다. 여기서 문제는 나도 몰라''Uncaught SyntaxError : JSON에서 예상치 못한 토큰 < "openlayers를 사용하여 위치" '에 js
<HTML>
<head>
<link rel="stylesheet" href="https://openlayers.org/en/v4.1.1/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://openlayers.org/en/v4.1.1/build/ol.js"></script>
</head>
<center>
<div id="mapid" style="width: 600px; height: 500px;"></div>
</center>
<script>
var vectorSource = new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: function(extent) {
return 'http://localhost:8080/geoserver/opengeo/ows?service=WFS&' +
'version=1.0.0&request=GetFeature&typeName=opengeo:comgeo&' +
'maxFeatures=50'+
'outputFormat=application%2Fjson' ;
},
strategy: ol.loadingstrategy.bbox
});
var map = new ol.Map({
layers: [
new ol.layer.Vector({
source: vectorSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgba(0, 0, 255, 1.0)',
width: 2
})
})
})
],
target: document.getElementById('mapid'),
view: new ol.View({
center: [-9, 30],
maxZoom: 19,
zoom: 5
})
});
</script>
</HTML>
: 나는 WFS가 openlayers 도구 geoserver에서 요청과지도를 삽입하려고하지만 난이 오류를 얻을 :
Uncaught SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at Jl (ol.js:342)
at wm.k.Pa (ol.js:342)
at T.<anonymous> (ol.js:340)
을이 내 코드입니다 json 문제 및 openlayers가있는 anythig를 찾지 못했기 때문에 ... 감사합니다.
이 URL에 도달하면 애플리케이션이받는 응답을 업로드 할 수 있습니까? http : // localhost : 8080/geoserver/opengeo/ows? service = WFS & version = 1.0.0 & request = GetFeature & typeName = opengeo : comgeo & axFeatures = 50outputFormat = application/json –
@OliverBarnwell 내지도 파일의 geojson farmat을 제공합니다. –
{ "type": "FeatureCollection"..... –