我试图从谷歌地图中清除以前的指示.但是当您进行另一次搜索时,仍会显示上一次搜索中的折线和标记.我尝试过使用directionsRenderer.setMap(null),但它没有任何区别.我有什么想法我做错了吗?
(function () {
Maps.Directions = function(googleMap, data, options) {
var directionsService = new google.maps.DirectionsService(),
directionsRenderer = new google.maps.DirectionsRenderer();
function getDirections() {
directionsService.route(data.request, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsRenderer.setDirections(response);
}
});
}
directionsRenderer.setMap(null);
directionsRenderer.setMap(googleMap);
getDirections();
};
})();
Run Code Online (Sandbox Code Playgroud) 我正在尝试对数组进行排序,以便所有零都在末尾。但是,我不希望列表按数字排序,零以上的所有数字都应保持相同的顺序。这是我到目前为止所得到的:
function placeZerosAtEnd(arr) {
return arr.sort(compareForSort);
}
function compareForSort(first, second) {
return first == 0 ? 1 : 0;
}
placeZerosAtEnd([9,0,9,1,0,2,0,1,1,0,3,0,1,9,9,0,0,0,0,0]);
Run Code Online (Sandbox Code Playgroud)
这应该返回 [9,9,1,2,1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0],但实际上返回 [3 ,9,9,1,9,2,9,1,1,1,0,0,0,0,0,0,0,0,0,0]。零是正确的,但其他数字的顺序很奇怪。这里发生了什么?
我试图删除<paragraph>我的XML 中的所有空节点.这就是我所拥有的:
<root>
<text>
<paragraph>This is some text</paragraph>
<paragraph></paragraph>
<paragraph>More text</paragraph>
</text>
<text>
<paragraph>Another paragraph</paragraph>
<paragraph></paragraph>
</text>
</root>
Run Code Online (Sandbox Code Playgroud)
这是我的XQuery:
let $root-ele as element() := doc("text.xml")/*
return
update delete $root-ele/text[paragraph = '']
Run Code Online (Sandbox Code Playgroud)
它似乎没有更新文件,但我不确定为什么?