I am completely new to openlayers and am kind of learning as I go along. I created a GML using QGIS and would like to call data from it. It isn't stylized (specific icons per attribute). I would like to stylize/symbolize the data using HTML for my openlayers map.
I've created two rules, where one rule pulls an image if satisfying the first rule, and another image if it satisfies the other rule.
I've looked online as whatever I use for some reason is not working.
var rule_lease = new OpenLayers.Rule({ filter: new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "asset_type", value: "lease", }), symbolizer: { externalGraphic: "location_of_file1.png", graphicWidth: 40, graphicHeight: 40, graphicYOffset: -25, //rotation: "${angle}", fillOpacity: 0.75 }); var rule_crown = new OpenLayers.Rule({ filter: new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "asset_type", value: "Crown-owned", }), symbolizer: { externalGraphic: "location_of_file2.png", graphicWidth: 40, graphicHeight: 40, graphicYOffset: -25, //rotation: "${angle}", fillOpacity: 0.75 }); style.addRules([rule_lease, rule_crown]); map.addLayer(vector);My question is, if my rule is as written above (note that I haven't included a default style), how do I call a GML file for it read the data from? I know I got to include it before the rules, but I am unsure of the correct syntax. Does it look like this:
var vector = new OpenLayers.Layer.Vector("", { protocol: new OpenLayers.Protocol.HTTP({ url: "location_of_gml.GML", format: new OpenLayers.Format.GML }), strategies: [new OpenLayers.Strategy.Fixed()], styleMap: new OpenLayers.StyleMap({OR THIS:
var layer = new OpenLayers.Layer.GML("Layer Name", "http://example.com/url/of/data.txt", { format: OpenLayers.Format.gml }); map.addLayer(layer); map.zoomToMaxExtent();I've tried both but I seem to be doing something wrong.
Thank you so much, this is a great community.
أكثر...
I've created two rules, where one rule pulls an image if satisfying the first rule, and another image if it satisfies the other rule.
I've looked online as whatever I use for some reason is not working.
var rule_lease = new OpenLayers.Rule({ filter: new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "asset_type", value: "lease", }), symbolizer: { externalGraphic: "location_of_file1.png", graphicWidth: 40, graphicHeight: 40, graphicYOffset: -25, //rotation: "${angle}", fillOpacity: 0.75 }); var rule_crown = new OpenLayers.Rule({ filter: new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "asset_type", value: "Crown-owned", }), symbolizer: { externalGraphic: "location_of_file2.png", graphicWidth: 40, graphicHeight: 40, graphicYOffset: -25, //rotation: "${angle}", fillOpacity: 0.75 }); style.addRules([rule_lease, rule_crown]); map.addLayer(vector);My question is, if my rule is as written above (note that I haven't included a default style), how do I call a GML file for it read the data from? I know I got to include it before the rules, but I am unsure of the correct syntax. Does it look like this:
var vector = new OpenLayers.Layer.Vector("", { protocol: new OpenLayers.Protocol.HTTP({ url: "location_of_gml.GML", format: new OpenLayers.Format.GML }), strategies: [new OpenLayers.Strategy.Fixed()], styleMap: new OpenLayers.StyleMap({OR THIS:
var layer = new OpenLayers.Layer.GML("Layer Name", "http://example.com/url/of/data.txt", { format: OpenLayers.Format.gml }); map.addLayer(layer); map.zoomToMaxExtent();I've tried both but I seem to be doing something wrong.
Thank you so much, this is a great community.
أكثر...