admin管理员组文章数量:1026989
I created a plunkr which has a moving marker like a car.
var olview = new ol.View({
center: [-5484111.13, -1884437.22],
zoom: 18,
minZoom: 2,
maxZoom: 20
});
var osm = new ol.source.OSM();
var lineString = new ol.geom.LineString([]);
var map = new ol.Map({
target: 'map',
view: olview,
renderer: 'canvas',
layers: [
new ol.layer.Tile({
source: osm,
opacity: 0.6
})
]
});
var car = document.getElementById('geo1');
var marker = new ol.Overlay({
positioning: 'center-center',
offset: [0, 0],
element: car,
stopEvent: false
});
map.addOverlay(marker);
var path = [
[-5484101.57, -1884475.44],
[-5484114.71, -1884432.74],
[-5484117.70, -1884416.62],
[-5484106.95, -1884392.28]
];
lineString.setCoordinates(path);
map.once('postpose', function(event) {
console.info('postpose');
interval = setInterval(animation, 500);
});
var i = 0, interval;
var animation = function(){
if (i == path.length){
i = 0;
}
marker.setPosition(path[i]);
i++;
};
This is written in openlayers, I want it to look smooth when moving similar to this.
I'm a plete beginner in openlayers, can someone help me with this? Thanks!
I created a plunkr which has a moving marker like a car.
var olview = new ol.View({
center: [-5484111.13, -1884437.22],
zoom: 18,
minZoom: 2,
maxZoom: 20
});
var osm = new ol.source.OSM();
var lineString = new ol.geom.LineString([]);
var map = new ol.Map({
target: 'map',
view: olview,
renderer: 'canvas',
layers: [
new ol.layer.Tile({
source: osm,
opacity: 0.6
})
]
});
var car = document.getElementById('geo1');
var marker = new ol.Overlay({
positioning: 'center-center',
offset: [0, 0],
element: car,
stopEvent: false
});
map.addOverlay(marker);
var path = [
[-5484101.57, -1884475.44],
[-5484114.71, -1884432.74],
[-5484117.70, -1884416.62],
[-5484106.95, -1884392.28]
];
lineString.setCoordinates(path);
map.once('postpose', function(event) {
console.info('postpose');
interval = setInterval(animation, 500);
});
var i = 0, interval;
var animation = function(){
if (i == path.length){
i = 0;
}
marker.setPosition(path[i]);
i++;
};
This is written in openlayers, I want it to look smooth when moving similar to this.
https://github./terikon/marker-animate-unobtrusive
I'm a plete beginner in openlayers, can someone help me with this? Thanks!
Share Improve this question asked Jun 11, 2015 at 9:18 The BassmanThe Bassman 2,3615 gold badges30 silver badges41 bronze badges1 Answer
Reset to default 5I've made three tests. First and second are pure ol3 and last is with tween.js.
I'm using Arc.js to create a path.
The first example is using setInterval
.
The second example is using window.requestAnimationFrame
.
And the last with Tween.js
.
Your example doesn't run smoothly because it is just a few coordinates.
Note that the Tween.js
integration is not an integration at all. It is just a tricky CSS manipulation.
I created a plunkr which has a moving marker like a car.
var olview = new ol.View({
center: [-5484111.13, -1884437.22],
zoom: 18,
minZoom: 2,
maxZoom: 20
});
var osm = new ol.source.OSM();
var lineString = new ol.geom.LineString([]);
var map = new ol.Map({
target: 'map',
view: olview,
renderer: 'canvas',
layers: [
new ol.layer.Tile({
source: osm,
opacity: 0.6
})
]
});
var car = document.getElementById('geo1');
var marker = new ol.Overlay({
positioning: 'center-center',
offset: [0, 0],
element: car,
stopEvent: false
});
map.addOverlay(marker);
var path = [
[-5484101.57, -1884475.44],
[-5484114.71, -1884432.74],
[-5484117.70, -1884416.62],
[-5484106.95, -1884392.28]
];
lineString.setCoordinates(path);
map.once('postpose', function(event) {
console.info('postpose');
interval = setInterval(animation, 500);
});
var i = 0, interval;
var animation = function(){
if (i == path.length){
i = 0;
}
marker.setPosition(path[i]);
i++;
};
This is written in openlayers, I want it to look smooth when moving similar to this.
I'm a plete beginner in openlayers, can someone help me with this? Thanks!
I created a plunkr which has a moving marker like a car.
var olview = new ol.View({
center: [-5484111.13, -1884437.22],
zoom: 18,
minZoom: 2,
maxZoom: 20
});
var osm = new ol.source.OSM();
var lineString = new ol.geom.LineString([]);
var map = new ol.Map({
target: 'map',
view: olview,
renderer: 'canvas',
layers: [
new ol.layer.Tile({
source: osm,
opacity: 0.6
})
]
});
var car = document.getElementById('geo1');
var marker = new ol.Overlay({
positioning: 'center-center',
offset: [0, 0],
element: car,
stopEvent: false
});
map.addOverlay(marker);
var path = [
[-5484101.57, -1884475.44],
[-5484114.71, -1884432.74],
[-5484117.70, -1884416.62],
[-5484106.95, -1884392.28]
];
lineString.setCoordinates(path);
map.once('postpose', function(event) {
console.info('postpose');
interval = setInterval(animation, 500);
});
var i = 0, interval;
var animation = function(){
if (i == path.length){
i = 0;
}
marker.setPosition(path[i]);
i++;
};
This is written in openlayers, I want it to look smooth when moving similar to this.
https://github./terikon/marker-animate-unobtrusive
I'm a plete beginner in openlayers, can someone help me with this? Thanks!
Share Improve this question asked Jun 11, 2015 at 9:18 The BassmanThe Bassman 2,3615 gold badges30 silver badges41 bronze badges1 Answer
Reset to default 5I've made three tests. First and second are pure ol3 and last is with tween.js.
I'm using Arc.js to create a path.
The first example is using setInterval
.
The second example is using window.requestAnimationFrame
.
And the last with Tween.js
.
Your example doesn't run smoothly because it is just a few coordinates.
Note that the Tween.js
integration is not an integration at all. It is just a tricky CSS manipulation.
本文标签: javascriptMarker or overlay moving animation moving smoothly in openlayers 3Stack Overflow
版权声明:本文标题:javascript - Marker or overlay moving animation moving smoothly in openlayers 3 - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745670252a2162413.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论