如何使用一個SVG圖像作爲層(所以不作爲地圖標記)與的OpenLayers-3我怎樣才能上的OpenLayers-3
我無法得到的任何輸出使用SVG圖像作爲層當使用ol.source.Vector
和ol.format.Feature
實例中的任何一個時,顯示我的SVG圖像。
小例子:(?)
var mapLayer = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'image.svg',
format: new ol.format.Feature() // http://openlayers.org/en/v3.12.1/apidoc/ol.format.Feature.html
}),
});
我能夠使用ImageStatic層時得到輸出,但這種使用/生成靜態圖像,從而SVG的優點消失了。
例子:
// Not sure if I need this for SVG, but is is required for an image
var extent = [0, 0, 1000, 1000]; // random image size
var projection = new ol.proj.Projection({
code: 'test',
units: 'pixels',
extent: extent
});
var mapLayer = new ol.layer.Image({
source: new ol.source.ImageStatic({
url: 'image.svg',
projection: projection,
imageExtent: extent
})
});
我已經嘗試過的伎倆與設置Content-type:
到image/svg+xml
但這並沒有幫助我。
所以,再次: 我如何(如果可能)使用OpenLayers-3的SVG圖像?
我很好奇,你怎麼會想使用SVG的不是靜態圖像等優點,? – PSorey
嗯,對我的想法(如果我錯了,請糾正我)我應該可以添加一個「可縮放」的SVG圖層,所以即使放大圖像也不會變得像素化並保持清晰。我們傾向於將它用於平面佈局圖,所以SVG(或者其他矢量格式)會很好。當然靜態圖像仍然可以使用,但是放大後總是會變得模糊不清。 – Matthijs
我自己也在跟OL3進行速度攀升,並一直在想SVG。我還需要在基礎圖層上繪製類似於CAD的矢量圖,並且從我讀過的評論中可能還不支持SVG?但是你可以使用Point,LineString和Polygon類型來製作一個可縮放的圖層。我將嘗試[ogr2ogr將DXF轉換爲GeoJSON。](http://ogre.adc4gis.com/) – PSorey