Да, похоже у точки нет метода split и ей нельзя разбивать другие геометрии. Но из точки же можно сделать линию

Если такой хак, а это хак в чистом виде, вас устроит, то пожалуйста:
Код: Выделить всё
<!DOCTYPE html>
<html>
<head>
<script src="http://openlayers.org/dev/OpenLayers.js"></script>
<style type="text/css">
#mapdiv {
width: 500px;
height: 500px;
border: 1px solid #dddddd;
}
</style>
<script>
function init() {
map = new OpenLayers.Map("mapdiv");
var epsg4326 = new OpenLayers.Projection("EPSG:4326");
var epsg900913 = new OpenLayers.Projection("EPSG:900913");
var center = new OpenLayers.LonLat(30,40).transform(epsg4326, epsg900913);
var epsilon = 0.0001;
var points = [
new OpenLayers.Geometry.Point(center.lon-500, center.lat),
new OpenLayers.Geometry.Point(center.lon+1000, center.lat)
];
var styles = new OpenLayers.StyleMap({
"default": new OpenLayers.Style(null, {
rules: [
new OpenLayers.Rule({
symbolizer: {
"Point": {
pointRadius: 5,
graphicName: "square",
fillColor: "white",
fillOpacity: 0.25,
strokeWidth: 1,
strokeOpacity: 1,
strokeColor: "#333333"
},
"Line": {
strokeWidth: 3,
strokeOpacity: 1,
strokeColor: "#666666"
}
}
})
]
}),
"select": new OpenLayers.Style({
strokeColor: "#00ccff",
strokeWidth: 4
}),
"temporary": new OpenLayers.Style(null, {
rules: [
new OpenLayers.Rule({
symbolizer: {
"Point": {
pointRadius: 5,
graphicName: "square",
fillColor: "white",
fillOpacity: 0.25,
strokeWidth: 1,
strokeOpacity: 1,
strokeColor: "#333333"
},
"Line": {
strokeWidth: 3,
strokeOpacity: 1,
strokeColor: "#00ccff"
}
}
})
]
})
});
//Создание слоёв
var base = new OpenLayers.Layer.OSM();
var vectors_pts = new OpenLayers.Layer.Vector("Vector Layer (points)", {styleMap: styles});
var vectors_lns = new OpenLayers.Layer.Vector("Vector Layer (lines)", {styleMap: styles});
var vectors_mystery = new OpenLayers.Layer.Vector("Vector Layer (dirty hack!)", {visibility: false});
map.addLayers([base, vectors_pts, vectors_lns, vectors_mystery]);
//Добавление объектов в линейный слой
vectors_lns.addFeatures([new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(points))]);
//Создание контролов
draw = new OpenLayers.Control.DrawFeature(vectors_pts, OpenLayers.Handler.Point,
{
autoActivate: true,
eventListeners: {
featureadded: function(e) {
var m_points = [
new OpenLayers.Geometry.Point(e.feature.geometry.x-epsilon, e.feature.geometry.y-epsilon),
new OpenLayers.Geometry.Point(e.feature.geometry.x+epsilon, e.feature.geometry.y+epsilon)
];
var line_f = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(m_points));
vectors_mystery.addFeatures([line_f]);
vectors_mystery.events.triggerEvent("sketchcomplete", {feature: line_f});
}
}
}
);
snap = new OpenLayers.Control.Snapping({layer: vectors_pts, targets: [{layer: vectors_lns, tolerance: 15}]});
snap.activate();
split = new OpenLayers.Control.Split({
layer: vectors_lns,
source: vectors_mystery,
tolerance: 50,
mutual: false,
eventListeners: {
aftersplit: function(event) {
flashFeatures(event.features);
}
}
});
split.activate();
map.addControls([draw, split, snap]);
map.setCenter(center, 15);
function flashFeatures(features, index) {
if(!index) {
index = 0;
}
var current = features[index];
if(current && current.layer === vectors_lns) {
vectors_lns.drawFeature(features[index], "select");
}
var prev = features[index-1];
if(prev && prev.layer === vectors_lns) {
vectors_lns.drawFeature(prev, "default");
}
++index;
if(index <= features.length) {
window.setTimeout(function() {flashFeatures(features, index)}, 75);
}
}
}
</script>
</head>
<body onload="init()">
<div id="mapdiv"></div>
</body>
</html>
Живой пример
тут.
Spatial is now, more than ever, just another column- The Geometry Column.