I'm using this classic example to getFeatureInfo from a WMS service. BUT.... it's on a different domain and we don't control the server, so that blunder of all blunders known as CORS is killing me. Here's the example:
map.on('click', function(evt) {// Hide existing popup and reset it's offsetpopup.hide();popup.setOffset([0, 0]);// Attempt to find a marker from the planningAppsLayervar feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) { return feature;});if (feature) { var coord = feature.getGeometry().getCoordinates(); var props = feature.getProperties(); var info = "" + props.casereference + "
"; info += "" + props.locationtext + "
"; info += "Status: " + props.status + " " + props.statusdesc + "
"; // Offset the popup so it points at the middle of the marker not the tip popup.setOffset([0, -22]); popup.show(coord, info);} else { var url = districtLayer .getSource() .getGetFeatureInfoUrl( evt.coordinate, map.getView().getResolution(), map.getView().getProjection(), { 'INFO_FORMAT': 'application/json', 'propertyName': 'NAME,AREA_CODE,DESCRIPTIO' } ); reqwest({ url: url, type: 'json', }).then(function (data) { var feature = data.features[0]; var props = feature.properties; var info = "" + props.NAME + "
" + props.DESCRIPTIO + "
"; popup.show(evt.coordinate, info); }); }});Now I trying using JSONP by replacing:
INFO_FORMAT': 'application/json',type: 'json',with
INFO_FORMAT': 'text/javascript',type: 'jsonp',Unfortunately, it doesn't work and neither does using Proxy.jsp.
Any suggestions??
أكثر...
map.on('click', function(evt) {// Hide existing popup and reset it's offsetpopup.hide();popup.setOffset([0, 0]);// Attempt to find a marker from the planningAppsLayervar feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) { return feature;});if (feature) { var coord = feature.getGeometry().getCoordinates(); var props = feature.getProperties(); var info = "" + props.casereference + "
"; info += "" + props.locationtext + "
"; info += "Status: " + props.status + " " + props.statusdesc + "
"; // Offset the popup so it points at the middle of the marker not the tip popup.setOffset([0, -22]); popup.show(coord, info);} else { var url = districtLayer .getSource() .getGetFeatureInfoUrl( evt.coordinate, map.getView().getResolution(), map.getView().getProjection(), { 'INFO_FORMAT': 'application/json', 'propertyName': 'NAME,AREA_CODE,DESCRIPTIO' } ); reqwest({ url: url, type: 'json', }).then(function (data) { var feature = data.features[0]; var props = feature.properties; var info = "" + props.NAME + "
" + props.DESCRIPTIO + "
"; popup.show(evt.coordinate, info); }); }});Now I trying using JSONP by replacing:
INFO_FORMAT': 'application/json',type: 'json',with
INFO_FORMAT': 'text/javascript',type: 'jsonp',Unfortunately, it doesn't work and neither does using Proxy.jsp.
Any suggestions??
أكثر...