0
Google Maps Javascript API V3をAndroid WebView に使用しました。私はAからBのようなDirectionを使用するとBへの経路Aは、経路Aが重なっているので、私は、AがC Google Maps Direction routesが次回出てきたら消えません
にBに
C.
に、Cの経路にBに消えないこと変更します直接操作する
direction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
button.setVisibility(View.INVISIBLE);
infowindow.setVisibility(View.INVISIBLE);
String centerUrl = "javascript:direction(" + Lat + "," + Lng + "," + LatNew + "," + LngNew + ")";
webView.loadUrl(centerUrl);
}
});
HTML
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple markers</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var myLatLng,endLatLng;
var map;
var marker,beachMarker,eatMarker,drinkMarker;
var location;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
center: myLatLng
});
marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'Hello World!'
});
beachMarker = new google.maps.Marker({
position: {lat: 25.078838,lng: 121.574204},
map: map,
icon: 'file:///android_asset/Marker.png'
});
beachMarker.addListener('click',function(){
Android.responseResult("beach");
});
eatMarker = new google.maps.Marker({
position: {lat: 25.080643,lng: 121.569551},
map: map,
icon: 'file:///android_asset/Marker.png'
});
eatMarker.addListener('click',function(){
Android.responseResult("eat");
});
drinkMarker = new google.maps.Marker({
position: {lat: 25.079734,lng: 121.569519},
map: map,
icon: 'file:///android_asset/Marker.png'
});
drinkMarker.addListener('click',function(){
Android.responseResult("drink");
});
}
function centerAt(latitude,longitude){
myLatLng = new google.maps.LatLng(latitude,longitude);
marker.setMap(null);
map.panTo(myLatLng);
marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: 'file:///android_asset/location.png'
});
}
function direction(latitude,longitude,latitudeNew,longitudeNew){
var directionsService = new google.maps.DirectionsService;
var directionsDisplay = new google.maps.DirectionsRenderer;
myLatLng = new google.maps.LatLng(latitude,longitude);
endLatLng = new google.maps.LatLng(latitudeNew,longitudeNew);
directionsService.route({
origin: myLatLng,
destination: endLatLng,
travelMode: google.maps.TravelMode.DRIVING
}, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
directionsDisplay.setMap(map);
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBMqm4dbVtq1OiUpyDxzRcU5196guci_jg&callback=initMap"></script>
私は最後のルートを削除するには何ができますか?
ありがとうございます!!!!!それは私に働く –