Guest User

Untitled

a guest
Aug 8th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. LAYER
  2. DEBUG 5
  3. TYPE point
  4. METADATA
  5. "WMS_TITLE" "N5000 Stasjon"
  6. "GML_INCLUDE_ITEMS" ""
  7. "WMS_INCLUDE_ITEMS" ""
  8. END
  9. CONNECTION "user=postgres password=postgres dbname=n5000 host=localhost port=5432"
  10. CONNECTIONTYPE postgis
  11. DATA "posisjon FROM (SELECT * FROM n5000kartdata_3abc657467024482a6b5ba9ddff592b7.stasjon) AS MYTABLE USING UNIQUE objid USING SRID=25833"
  12. NAME "Stasjon"
  13. PROCESSING "CLOSE_CONNECTION=DEFER"
  14. PROJECTION "init=epsg:25833" END
  15. CLASS
  16. STYLE
  17. ANGLE auto
  18. COLOR 244 17 17
  19. LINECAP round
  20. LINEJOIN round
  21. OUTLINECOLOR 204 8 8
  22. SIZE 12
  23. SYMBOL "ellipse"
  24. END
  25. END
  26. END
  27. LAYER
  28. TYPE POLYGON
  29. METADATA
  30. "WMS_TITLE" "N5000 - Skog"
  31. "GML_INCLUDE_ITEMS" ""
  32. "WMS_INCLUDE_ITEMS" ""
  33. END
  34. CONNECTION "user=postgres password=postgres dbname=n5000 host=localhost port=5432"
  35. CONNECTIONTYPE postgis
  36. DATA "omrade FROM (SELECT * FROM n5000kartdata_3abc657467024482a6b5ba9ddff592b7.skog) AS MYTABLE USING UNIQUE objid USING SRID=25833"
  37.  
  38. NAME "Skog"
  39. PROCESSING "CLOSE_CONNECTION=DEFER"
  40. PROJECTION "init=epsg:25833" END
  41. CLASS
  42. STYLE
  43. ANGLE auto
  44. LINECAP round
  45. LINEJOIN round
  46. END
  47. END
  48. END
  49.  
  50. <div className="content">
  51. <h1>
  52. Welcome to <code>react-openlayers</code> Demo
  53. </h1>
  54. <button onClick={() => this.setState({ unmounted: true })}>
  55. Unmount map
  56. </button>
  57. <CenterRenderer />
  58. { <VectorTileLayer
  59. id="vectorTileLayer"
  60. key="vectorTileKey"
  61. name="vector tile layer"
  62. url={
  63. 'http://localhost/mapserver?map=c:/a3/data/mapengine/mapfiles/n5000Test.map&mode=tile&tilemode=gmap&tile={x}+{y}+{z}&layers=All&map.imagetype=mvt'
  64. }
  65. />}
  66.  
  67. var fill = new Fill({ color: '' });
  68. var stroke= new Stroke({ color: '', width: 1 });
  69. var radius = 5;
  70. var textSize = 12;
  71. var text = new Text({font: textSize + 'px serif', fill: fill, stroke:
  72. stroke});
  73.  
  74. var styleFunc = {
  75. Polygon: new Style({ fill: fill }),
  76. StrokedPolygon: new Style({ fill: fill, stroke: stroke }),
  77. Point: new Style ({
  78. image: new Circle({fill: fill, stroke: stroke, radius: radius})
  79. }),
  80. Line: new Style({ stroke: stroke }),
  81. Text: new Style({
  82. text: text
  83. })
  84. };
  85.  
  86. var temp = JsonData;
  87. var styles = [];
  88.  
  89. return function(feature) {
  90. var length = 0;
  91. var layer = feature.get('layer');
  92.  
  93. var layerStyle = temp.layers[layer.toLowerCase()];
  94. fill.setColor(layerStyle.fillColor|| undefined);
  95. stroke.setColor(layerStyle.strokeColor || undefined);
  96. stroke.setWidth(layerStyle.strokeWidth || undefined);
  97. text.setText(feature.getProperties().fulltekst || undefined);
  98.  
  99. radius = layerStyle.radius || undefined;
  100. styles[length++] = styleFunc[layerStyle.type];
  101.  
  102. class VectorTile extends React.Component {
  103. get id() {
  104. return this.props.id;
  105. }
  106. // const med attr
  107. componentDidMount() {
  108. this.addLayer(this.props);
  109. }
  110.  
  111. addLayer(props) {
  112. const { map, style, tileUrlFunction, url, opacity } = props;
  113.  
  114. if (!map) return;
  115.  
  116. if (map._layers && map._layers[this.id]) {
  117. map._layers[this.id].setVisible(true);
  118. return;
  119. }
  120.  
  121. map._layers = map._layers || {};
  122. map._layers[this.id] = new VectorTileLayer({
  123. declutter: true,
  124. minResolution: 0,
  125. maxResolution: 20000,
  126. source: new VectorTileSource({
  127. attributions: 'testtT!',
  128. format: new MVT(),
  129. projection: "EPSG:3857",
  130. url: url,
  131. tileUrlFunction: tileUrlFunction
  132. }),
  133. renderMode: "image",
  134.  
  135. opacity: opacity,
  136. style:
  137. style || MapStyle(Style, Fill, Stroke, Icon, Text),
  138. zIndex: -10
  139. });
  140. this.mountLayer();
  141. }
Add Comment
Please, Sign In to add comment