我想限制KML文件中所有图标的可点击区域,我对如何做到这一点有点困惑。图标都是相同的典型样式指针,我想把可点击的区域限制在指针顶部所包含的圆圈上。图标是19x32,所以我想要一个圆心的9px从顶部,9px从左边,半径为9px。如果geoxml3会这样做,我想这将在解析器对象中指定,尽管它可能在KML文件的IconStyle中。实际上,如果是在解析器对象中,我还没有找到正确的语法。显然不是:
var blues = new geoXML3.parser({map: map, singleInfoWindow: true, zoom: false, markerOptions: {shape: {type:circle, coords: [9px,9px,9px]}}});
blues.parse('allbluesdance.kml');发布于 2014-08-12 06:25:31
markerOptions选项GeoXml3正是v3 markerOptions对象。
您的图标是49x32像素,圆心从左上角定义。,所以您可能需要24,9作为中心,半径为9:
var blues = new geoXML3.parser({
map: map,
singleInfoWindow: true,
suppressDirections: true,
markerOptions: {
shape: {
type: 'circle',
coords: [24,9,9]
}
},
zoom: false
});// Shapes define the clickable region of the icon.
// The type defines an HTML <area> element 'poly' which
// traces out a polygon as a series of X,Y points. The final
// coordinate closes the poly by connecting to the first
// coordinate.
var shape = {
coords: [1, 1, 1, 20, 18, 20, 18 , 1],
type: 'poly'
};如果您删除了"px“(文档中显示了一个数字数组),那么HTML区域圆形状看起来应该工作,只是它位于图标的左边。
工作实例
https://stackoverflow.com/questions/25232744
复制相似问题