我目前正在开发一款可以跟踪位置的Android应用。 我的应用程序分为两部分:
我的第一部分完成了,在第二部分我从服务器获取了一个值。但是当我function httpGetMovies(response) {
var fullRequestQueryMovie = partialQueryMovie + apiKeyMovie + '&' + queryTermMovie + '&page_limit=2'+'&_prettyprint=true';
console.log('Calling -> ' + fullRequestQueryMovie);
var headersMovie = {
'Content-Type': 'application/json'
};
var optionsMovie = {
host: hostMovie,
path: fullRequestQueryMovie,
method: 'GET',
headers: headersMovie
};
var jsonStringResponseMovie = '';
var req = http.request(optionsMovie, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(piece) {
jsonStringResponseMovie += piece;
//console.log("-----------------\n"+jsonStringResponseMovie);
});
res.on('end', function () {
var jsonObj = JSON.parse(jsonStringResponseMovie);
var moviesBag = [];
for(i = 0; i<sonObj.movies.length-1; i++){
console.log("film n°: "+i+" of "+jsonObj.movies.length+" "+jsonObj.movies[i].title);
// /-----begin nested http.request--------
var singleMovieDirectors = [];
var fullRequestSingleMovie = jsonObj.movies[i].links.self + '?apikey=' + apiKeyMovie ;
var headersSingleMovie = {
'Content-Type': 'application/json'
};
var optionsSingleMovie = {
host: hostMovie,
path: fullRequestSingleMovie,
method: 'GET',
headers: headersSingleMovie
};
var jsonStringResponseSingleMovie = '';
var req2 = http.request(optionsSingleMovie, function(res2) {
console.log("request for "+optionsSingleMovie.path);
// console.log("statusCode: ", res.statusCode);
// console.log("headers: ", res.headers);
res2.on('data', function(piece2) {
jsonStringResponseSingleMovie += piece2;
});
res2.on('end', function() {
var jsonObjSingleMovie = JSON.parse(jsonStringResponseSingleMovie);
console.log("directors > "+JSON.stringify(jsonObjSingleMovie.abridged_directors));
// response.send(blabla);
});
});
req2.end();
req2.on('error', function(e) {
console.error(e);
});
// -------end of nested http.request-----------------
} // end of for loop
});
});
req.end();
req.on('error', function(e) {
console.error(e);
});
};
我的地图上有新值时,每次刷新整个地图时都会出现问题。
如果有人对如何实现能够运行Android应用程序并看到标记动态更改的效果有任何见解,那将非常感激!
sync
答案 0 :(得分:1)
尝试使用
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), 13));
当你收到新的lat和lng时。这应该从当前位置平稳地动画到新位置