2

我正在尝试使用带有 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,它会绘制多面体。

4

2 回答 2

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

于 2016-10-25T15:48:02.570 回答
0

现在有一个拉取请求: https ://github.com/mapgears/ol3-google-maps/pull/180

于 2017-11-03T20:19:18.833 回答