GMaps方向服务与Phonegap Watchposition

时间:2013-06-27 21:19:59

标签: android mobile google-maps-api-3 cordova

当我打电话给谷歌地图的指导服务时,我想用Phonegap Watchposition刷新位置。我尝试了一个解决方案但是我无法在刷新(pic)后删除每个标记。 任何人都可以解释如何避免这个问题吗?

谢谢 here's my problem

--- --- EDIT

这是一些代码

(calcRoute上的Phonegap watchposition)

function onSuccess(position) {

            pos = new google.maps.LatLng(position.coords.latitude,
                    position.coords.longitude);
            if (check == true) {
                   var end1 = getEnd();


                    dirMarker[0] = getMarker(0);
                  dirMarker[1] = getMarker(1);

                    directionsDisplay.setMap();

                   dirMarker[0].setMap(null);
                    dirMarker[1].setMap(null);
                //  dirMarker[0] = getMarker(0);
                    dirMarker[1] = getMarker(1);

                   dirMarker[0].setPosition(pos);
                    dirMarker[1].setPosition(end);

                    calcRoute(pos, end1);

            } else {

                    markerME.setPosition(pos);

           }
    }


   function calcRoute(start, end) {

            var visible = marker[1].getVisible();

            if (visible == true) {
                    markerME.setMap(null);

                    for (var i = 0; i < marker.length; i++) {

                            marker[i].setMap(null);

                    }
            }

            directionsDisplay.setMap(map);

            var request = {
                    origin: start,
                    destination: end,
                    travelMode: google.maps.DirectionsTravelMode.WALKING
            };
            directionsService.route(request, function (response, status) {

                    if (status == google.maps.DirectionsStatus.OK) {
                            check = true;
                            directionsDisplay.setDirections(response);
                            directionsDisplay.setOptions({
                                    preserveViewport: true
                            });
                            var leg = response.routes[0].legs[0];
                            setEnd(leg.end_location);
                            setMarker(leg.start_location, leg.end_location);
                    }
            });
    }

0 个答案:

没有答案