Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var wms = new OpenLayers.Layer.WMS(
- "OpenLayers WMS",
- "http://vmap0.tiles.osgeo.org/wms/vmap0",
- { layers: 'basic' }
- );
- var kml_string = '<?xml version="1.0" encoding="utf-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <Style id="boundaryLineColor1"> <LineStyle> <color>ff000000</color> <width>3</width> </LineStyle> <PolyStyle> <fill>false</fill> </PolyStyle> </Style> <Folder> <name>Soybean Yield</name> <Placemark> <name>Soybean Yield (1)</name> <styleUrl>#boundaryLineColor1</styleUrl> <Polygon> <outerBoundaryIs> <LinearRing> <coordinates>-91.3342663759154,32.5034766500927 -91.3342667084831,32.5034586155548 -91.3342986325171,32.5028817921232 -91.3347528643046,32.5013364566058 -91.3353490833926,32.5013263087953 -91.3371799720313,32.501314445573 -91.338116698321,32.5013087851122 -91.3386487408102,32.501315812754 -91.3386663742212,32.5015144742388 -91.3387262951512,32.5028862267216 -91.3387406121766,32.5032652339614 -91.3387805784262,32.5045645667511 -91.3389131380096,32.5089317435004 -91.3389218164796,32.5096173380048 -91.3389859320576,32.5153906443518 -91.3389832778257,32.5155349207259 -91.3388110064899,32.5156408789761 -91.337874131254,32.5156465397406 -91.3359365262234,32.5156569954422 -91.334957081528,32.5156620711925 -91.3346590909512,32.515658125708 -91.3345962338078,32.5156031766372 -91.3345799386691,32.5153323771848 -91.3345104393058,32.5133291373803 -91.3344968056745,32.5129140617432 -91.3342663759154,32.5034766500927</coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> </Folder> </Document> </kml>'
- var kmlParser = new OpenLayers.Format.KML({
- extractStyles: true,
- extractAttributes: true
- }); // Initialize with options if necessary
- var feature_list = kmlParser.read(kml_string);
- var sundialsTest = new OpenLayers.Layer.Vector("Test");
- sundialsTest.addFeatures(feature_list);
- this.application.map.map.addLayers([wms, sundialsTest]);
- map.addLayer(sundialsTest);
- map.addLayers([sundialsTest]);
- console.log(this.application.map.map);
- var map = null;
- var apiKey = "(...)"; // your Bing API key
- function init() {
- map = new OpenLayers.Map("map");
- map.addControl(new OpenLayers.Control.LayerSwitcher());
- var road = new OpenLayers.Layer.Bing({
- name: "Road",
- key: apiKey,
- type: "Road"
- });
- map.addLayers([road]);
- var kml_string = '<?xml version="1.0" encoding="utf-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <Style id="boundaryLineColor1"> <LineStyle> <color>ff000000</color> <width>3</width> </LineStyle> <PolyStyle> <fill>false</fill> </PolyStyle> </Style> <Folder> <name>Soybean Yield</name> <Placemark> <name>Soybean Yield (1)</name> <styleUrl>#boundaryLineColor1</styleUrl> <Polygon> <outerBoundaryIs> <LinearRing> <coordinates>-91.3342663759154,32.5034766500927 -91.3342667084831,32.5034586155548 -91.3342986325171,32.5028817921232 -91.3347528643046,32.5013364566058 -91.3353490833926,32.5013263087953 -91.3371799720313,32.501314445573 -91.338116698321,32.5013087851122 -91.3386487408102,32.501315812754 -91.3386663742212,32.5015144742388 -91.3387262951512,32.5028862267216 -91.3387406121766,32.5032652339614 -91.3387805784262,32.5045645667511 -91.3389131380096,32.5089317435004 -91.3389218164796,32.5096173380048 -91.3389859320576,32.5153906443518 -91.3389832778257,32.5155349207259 -91.3388110064899,32.5156408789761 -91.337874131254,32.5156465397406 -91.3359365262234,32.5156569954422 -91.334957081528,32.5156620711925 -91.3346590909512,32.515658125708 -91.3345962338078,32.5156031766372 -91.3345799386691,32.5153323771848 -91.3345104393058,32.5133291373803 -91.3344968056745,32.5129140617432 -91.3342663759154,32.5034766500927</coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> </Folder> </Document> </kml>'
- var kmlParser = new OpenLayers.Format.KML({
- extractStyles: true,
- extractAttributes: true,
- internalProjection: new OpenLayers.Projection("EPSG:3857"),
- externalProjection: new OpenLayers.Projection("EPSG:4326")
- });
- var feature_list = kmlParser.read(kml_string);
- var sundialsTest = new OpenLayers.Layer.Vector("Test");
- sundialsTest.addFeatures(feature_list);
- map.addLayer(sundialsTest);
- map.zoomToExtent(sundialsTest.getDataExtent());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement