我尝试使用带有openlayer 3的OL3-Google-Maps在SATELLITE地图中加载多面体形状,但没有工作。当我使用简单的多边形时,它起作用。我真的不知道这里有什么问题。
查看代码:
var glSat = new olgm.layer.Google({
mapTypeId: google.maps.MapTypeId.SATELLITE
});
var wkt = 'MULTIPOLYGON(((-74.9929726416642 5.18492112724286,-75.0191266345606 5.1848828549929,-75.0191867110875 5.2253515246231,-75.0183316375994 5.22651138628054,-75.0163671630514 5.23378374934167,-75.0142357420755 5.23793700993367,-75.0100693670497 5.23831391909755,-75.0091148838295 5.24549449588018,-75.0106031060614 5.24549228311571,-75.0106009630105 5.24405463549549,-75.0126461088479 5.24251448511432,-75.0116677711593 5.23964974161631,-75.0157986254176 5.23964357493722,-75.0187890089636 5.23691755404967,-75.0192019473326 5.23572481925641,-75.0192261006484 5.25179140082412,-74.9930693552343 5.25183206753317,-74.9929726416642 5.18492112724286)))';
var format = new ol.format.WKT();
var feature = format.readFeature(wkt, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
});
var vectorPolygons = new ol.layer.Vector({
source: new ol.source.Vector({
features: [feature]
})
});
// Create a regular OL3 map, containing our Google layer
var map = new ol.Map({
target: 'map',
// use OL3-Google-Maps recommended default interactions
interactions: olgm.interaction.defaults(),
layers: [
vectorPolygons, glSat
],
view: new ol.View({
center: ol.proj.fromLonLat([-74.5981636036184, 6.25468647083332]),
zoom: 7
})
});
// Activate the library
var olGM = new olgm.OLGoogleMaps({
map: map
});
olGM.activate();

如果我改变wkt(下面),它可以工作:
var wkt = 'POLYGON((-74.9929726416642 5.18492112724286,-75.0191266345606 5.1848828549929,-75.0191867110875 5.2253515246231,-75.0183316375994 5.22651138628054,-75.0163671630514 5.23378374934167,-75.0142357420755 5.23793700993367,-75.0100693670497 5.23831391909755,-75.0091148838295 5.24549449588018,-75.0106031060614 5.24549228311571,-75.0106009630105 5.24405463549549,-75.0126461088479 5.24251448511432,-75.0116677711593 5.23964974161631,-75.0157986254176 5.23964357493722,-75.0187890089636 5.23691755404967,-75.0192019473326 5.23572481925641,-75.0192261006484 5.25179140082412,-74.9930693552343 5.25183206753317,-74.9929726416642 5.18492112724286))';

此外,如果我没有激活olgm MAP,它会绘制多边形。
答案 0 :(得分:0)
OL3-Google-Maps目前不支持多种几何。请参阅ol3gm中用于处理从ol3到Google Maps JS API的几何转换的代码:https://github.com/mapgears/ol3-google-maps/blob/v0.11.2/src/gm/gm.js#L29-L52
这应添加到ol3gm的当前限制列表中:https://github.com/mapgears/ol3-google-maps/blob/master/LIMITATIONS.md
我邀请您在ol3gm GitHub项目上创建一个问题来记录这个问题:https://github.com/mapgears/ol3-google-maps/issues/new
答案 1 :(得分:0)