WFS图层不显示(WFS Layer Not Display)
我从GeoServer创建了WFS GeoJson图层,我得到了这个URL'http:// localhost:8080 / geoserver / trail /ows?service = WFS&version = 1.0.0&request = GetFeature&typeName = trail:sbi_branch_data&maxFeatures = 50&outputFormat = application%2Fjson ',来自OL3示例的示例从该代码中,我尝试了OpenLayer3中的一些代码,但给出了一些错误。请帮助我。谢谢。
<!DOCTYPE html> <html> <head> <title>WFS</title> <!-- <link rel="stylesheet" href="https://openlayers.org/en/v4.1.0/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.0/build/ol.js"></script>--> <link rel="stylesheet" href="css/ol.css" type="text/css" /> <link rel="stylesheet" href="css/sample.css" type="text/css" /> </head> <body> <div id="map" class="map"></div> <script src="js/ol.js"></script> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> var vectorSource = new ol.source.Vector({ format: new ol.format.GeoJSON(), url: function(extent) { return 'http://localhost:8080/geoserver/trail/ows?service=WFS&'+ 'version=1.0.0&request=GetFeature&typeName=trail:sbi_branch_data&'+ 'maxFeatures=50&outputFormat=application/json&srsname=EPSG:4326&' + 'bbox=' + extent.join(',') + ',EPSG:4326'; }, strategy: ol.loadingstrategy.bbox }); var vector = 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 }) }) }); var raster = new ol.layer.Tile({ // source: new ol.source.BingMaps({ // imagerySet: 'Aerial', // key: 'Your Bing Maps Key from http://www.bingmapsportal.com/ here' // }) }); var map = new ol.Map({ layers: [raster, vector], target: document.getElementById('map'), view: new ol.View({ center: [20.5937, 78.9629], maxZoom: 19, zoom: 12 }) }); </script> </body> </html>
错误:“XMLHttpRequest无法加载http:// localhost:8080 / geoserver / trail /ows?service = WFS&version = 1.0.0&request ... 644126996,-13297.517049905844,22569.517044127,13455.442849905845,EPSG:4326。”Access-Control-Allow-Origin '标题出现在请求的资源上,因此不允许Origin'null'访问。“
I created WFS GeoJson layer from GeoServer ,I got this url'http://localhost:8080/geoserver/trail/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=trail:sbi_branch_data&maxFeatures=50&outputFormat=application%2Fjson' ,I got example from OL3 examples From that code ,I tried some code in OpenLayer3 ,but giving some error.please help me .Thanks.
<!DOCTYPE html> <html> <head> <title>WFS</title> <!-- <link rel="stylesheet" href="https://openlayers.org/en/v4.1.0/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.0/build/ol.js"></script>--> <link rel="stylesheet" href="css/ol.css" type="text/css" /> <link rel="stylesheet" href="css/sample.css" type="text/css" /> </head> <body> <div id="map" class="map"></div> <script src="js/ol.js"></script> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> var vectorSource = new ol.source.Vector({ format: new ol.format.GeoJSON(), url: function(extent) { return 'http://localhost:8080/geoserver/trail/ows?service=WFS&'+ 'version=1.0.0&request=GetFeature&typeName=trail:sbi_branch_data&'+ 'maxFeatures=50&outputFormat=application/json&srsname=EPSG:4326&' + 'bbox=' + extent.join(',') + ',EPSG:4326'; }, strategy: ol.loadingstrategy.bbox }); var vector = 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 }) }) }); var raster = new ol.layer.Tile({ // source: new ol.source.BingMaps({ // imagerySet: 'Aerial', // key: 'Your Bing Maps Key from http://www.bingmapsportal.com/ here' // }) }); var map = new ol.Map({ layers: [raster, vector], target: document.getElementById('map'), view: new ol.View({ center: [20.5937, 78.9629], maxZoom: 19, zoom: 12 }) }); </script> </body> </html>
Error: "XMLHttpRequest cannot load http://localhost:8080/geoserver/trail/ows?service=WFS&version=1.0.0&request…644126996,-13297.517049905844,22569.517044127,13455.442849905845,EPSG:4326. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."
原文:https://stackoverflow.com/questions/43650246
最满意答案
我认为你可以默认做到这一点,但你可以做一些关闭:1.你去图书馆,选择“新字体”。 2.选择你的字体,例如“Myriad Pro”,检查“导出脚本”复选框。 您会收到关于不存在的类的消息,并在运行时生成 - 您按“确定”,不用担心。 3.当您定义动态文本字段时,请执行以下操作:
var textFormat:TextFormat = new TextFormat(); textFormat.font = 'Myriad Pro'; textBox.setTextFormat(textFormat); textBox.defaultTextFormat = textFormat;
当然,如果不存在大小或其他属性的差异,则只需定义一次textFormat。
setTextFormat(textFormat)
适用于文本框中的文本,而defaultTextFormat
适用于将从该点添加到文本框的文本。这应该够了吧。 在Flash CS4中测试。
I don't think you can do that by default, but you can do something close: 1. You go to the library, select "new font". 2. You pick your font, for example "Myriad Pro", check the "export for Actionscript" checkbox. You get a message about a class not existing and being generated at runtime - you press "OK" and don't worry. 3. When you define your dynamic textfields, you do the following:
var textFormat:TextFormat = new TextFormat(); textFormat.font = 'Myriad Pro'; textBox.setTextFormat(textFormat); textBox.defaultTextFormat = textFormat;
Of course, you only need to define the textFormat once, if no differences in size or other attributes exist. The
setTextFormat(textFormat)
applies for the text already in the textbox, whereas thedefaultTextFormat
applies for the text that's going to be added from that point on to the textbox.That should do the trick. Tested in Flash CS4.
相关问答
更多-
与键kCFUserNotificationTextFieldTitlesKey或kCFUserNotificationTextFieldValuesKey关联的值将是一个字符串数组: CFTypeRef values[2] = { CFSTR("one"), CFSTR("two") }; CFArrayRef valArray = CFArrayCreate( NULL, values, 2, &kCFTypeArrayCallBacks ); 顺便说一下,你使用的是Core Foundation,而不 ...
-
在第一个文本框中,我会提出一个很大的限制。 在'文字改变'上,检查长度。 如果变化大于4(最大值)。 删除额外的东西,并将其传播到您的文本框。 如果您复制粘贴,它将32的文本更改,它会起作用。 你也可以改变光标(我认为它的.Focus(),但我可能是错的),所以它会自动在这两个盒子之间“跳跃”。 In the first textbox, I would put a large limit. On the 'text changed', check the length. If the change is ...
-
您不应该使用文本字段的描述 ,而是使用其文本 NSString *str = [NSString stringWithFormat:@"%@", textfield]; //OR NSLog(@"%@", textField); ==>这很糟糕,因为它调用textfield.description(文本字段的描述不是文本本身 请改用text属性 NSString *str = [NSString stringWithFormat:@"%@", textfield.text]; //OR NSLog(@"% ...
-
要在动态TextField中使用任何字符,您应该通过单击属性面板中的“嵌入...”并选择将在此文本字段中使用的所有字符来嵌入这些字符。 例如,对于日语,您应该至少选中一个复选框: 此外,您应该选择字体系列和样式。 To use any characters in dynamic TextField you should embed these characters by clicking "Embed..." in properties panel and choosing all characters y ...
-
textfields应该只更改第一个正在执行的范围内的字符(textfields should change characters in range only first one is executing)[2023-09-23]
请参阅您正在使用两个if语句。 但是在第一个if语句结束时你正在使用return ,所以控件将从那个循环中出来。 即使这两种情况都是正确的。 简单的解释。 - (void)viewDidLoad { [super viewDidLoad]; if (1) { NSLog(@"true"); return; } if (true) { NSLog(@"true1"); return; } // D ... -
我认为你可以默认做到这一点,但你可以做一些关闭:1.你去图书馆,选择“新字体”。 2.选择你的字体,例如“Myriad Pro”,检查“导出脚本”复选框。 您会收到关于不存在的类的消息,并在运行时生成 - 您按“确定”,不用担心。 3.当您定义动态文本字段时,请执行以下操作: var textFormat:TextFormat = new TextFormat(); textFormat.font = 'Myriad Pro'; textBox.setTextFormat(textFormat); text ...
-
if (rs.next()) { String option = rs.getString("options"); jAnswerA.setText(option); }; if (rs.next()) { String optionB = rs.getString("options"); jAnswerB.setText(optionB); }; if (rs.next()) { String option = rs.getString("option ...
-
我认为你错过了委托方法的要点。 此方法为您提供正在编辑的textField,以便您可以使用对您的textField的引用而不使用ivar - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSUInteger length = [textField.text length] + [string len ...
-
我发现我必须从列表的下方添加Basic Latin和扩展的拉丁语集,以确保法语的标准重音字符正确显示。 通过在字符映射(窗口)中打开它,确保所选字体确实支持所需的全部字符。 I've found that I have to add Basic Latin and the extended Latin sets from further down the list, to ensure the standard accented characters from French appear correctly ...
-
非常愚蠢的“解决方法”,我确信它会被投票,但是由于flash.text.TextField继承了flash.display.DisplayObject,你可以使用内置的过滤器,如flash.filters.Blur来模糊文本水平和垂直半个像素。 这将消耗更多的CPU。 编辑:在与CS4一起工作之后,我找到了完美的方法来做到这一点,而没有额外的CPU开销! 结果将看起来像1:1,就像'静态文本'渲染一样。 我相信同样适用于CS3,因为我记得有类似的选择。 选择文本后,在属性下选择“消除别名”并选择“自定义消除 ...