2

こんにちは、ng-map のマークアップ テキストを変更したいと思います。それぞれ「A」と「B」の代わりに「開始」と「終了」を表示する必要があります。

私はこれを参照しましたが、運はありません。マークアップにテキスト「start」と「A」の両方が表示されます。

また、観察すると、出発地と目的地の間の距離は、実際の G​​oogle マップが示すものと同じではありません。

そこで、ここで 3 つの質問があります。

1) マークアップ テキストを "A" から "start" に変更

2) 出発地と目的地の間の距離

3) AngularJS を使用して、[Draw Map] ボタンをクリックすると、このマップを表示したいと考えています。

以下は私のコードです。

var mainModule = angular.module('mainApp',['ngRoute', 'ngMap']);
	mainModule.controller('mapCtrl', function($scope){
		$scope.sources = ["mumbai", "pune", "bangalore", "delhi", "netherlands"];
		$scope.destinations = ["pune", "bangalore", "mumbai", "delhi", "andorra"];
		$scope.origin = "mumbai";
		$scope.dest = "pune";
		$scope.drawMap = function(){
			var sourceVal = $('#sourceDdl').val();
			var destnVal = $("#destinationDdl").val();
			$scope.origin = sourceVal;
			$scope.dest = destnVal;
		}
		
	});
body {
    overflow: auto;
    background-color: #000000;
}

/* google map */
.ng-map-section{
	width: 800px;
    height: 600px;
    overflow: hidden;
    position: relative;
    background: #e6e6e6;
    border: 20px solid #FFF;
    margin-top: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> 
<script src="https://maps.google.com/maps/api/js?libraries=placeses,visualization,drawing,geometry,places"></script>
<script src="https://code.angularjs.org/1.3.15/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <title>ng-map</title>

    <link href="css/bootstrap.css" rel="stylesheet">
  
    
	
</head>
<body>
		
		<div class="container ng-map-section" ng-app="mainApp" ng-controller="mapCtrl">
			<div style="float:left;width:70%;">
				<ng-map zoom="14" center="" style="height:600px">
					<directions 
						draggable="true" 
						travel-mode="DRIVING" 
						origin="{{origin}}" 
						destination="{{dest}}"
						suppressMarkers='true'>
					</directions>
					<custom-marker id="start" position="{{origin}}">
						<div> Start </div>
					</custom-marker>
					<custom-marker id="end" position="{{dest}}">
						<div> End </div>
					</custom-marker>
				</ng-map>
				
			</div>
			<div style="float:right;width:28%">
				<label for="sourceDdl">Source: </label>
				<select id="sourceDdl">
					<option ng-repeat="source in sources" value="{{source}}">{{source}}</option>
				</select>
				<br><br>
				<label for="destinationDdl">Destination: </label>
				<select id="destinationDdl">
					<option ng-repeat="destination in destinations"  value="{{destination}}">{{destination}}</option>
				</select>
				<br><br>
				<label>Distance: {{map.directionsRenderers[0].directions.routes[0].overview_path.length}}</label><br>
				<input type="button" ng-click="drawMap()" value="Draw Map">
			</div>
			<!--
			<div id="directions-panel" style="width: 28%; float:left; height: 100%; overflow: auto; padding: 0px 5px">
			</div>-->
		</div>
	
</body>
</html>

ここに画像の説明を入力

4

2 に答える 2

1

name 属性は である必要がsuppress-markersあるため、に置き換えsuppressmarkers='true'ますsuppress-markers="true"

更新された例

angular.module('mainApp', ['ngRoute', 'ngMap'])
    .controller('mapCtrl', function($scope) {
        $scope.sources = ["mumbai", "pune", "bangalore", "delhi", "netherlands"];
        $scope.destinations = ["pune", "bangalore", "mumbai", "delhi", "andorra"];
        $scope.origin = "mumbai";
        $scope.dest = "pune";
        $scope.drawMap = function() {
            var sourceVal = $('#sourceDdl').val();
            var destnVal = $("#destinationDdl").val();
            $scope.origin = sourceVal;
            $scope.dest = destnVal;
        }

    });
body {
    overflow: auto;
    background-color: #000000;
}

/* google map */
.ng-map-section{
	width: 800px;
    height: 600px;
    overflow: hidden;
    position: relative;
    background: #e6e6e6;
    border: 20px solid #FFF;
    margin-top: 20px;
}
 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
    <script src="https://maps.google.com/maps/api/js?libraries=placeses,visualization,drawing,geometry,places"></script>
    <script src="https://code.angularjs.org/1.3.15/angular.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.js"></script>
    <script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>



    <div class="container ng-map-section" ng-app="mainApp" ng-controller="mapCtrl">
        <div style="float:left;width:70%;">
            <ng-map zoom="14" center="" style="height:600px">
                <directions 
                draggable="true" 
                travel-mode="DRIVING" 
                origin="{{origin}}" 
                destination="{{dest}}" 
                suppress-markers="true">
                </directions>
                <custom-marker id="start" position="{{origin}}">
                    <h3> Start </h3>
                </custom-marker>
                <custom-marker id="end" position="{{dest}}">
                    <h3> End </h3>
                </custom-marker>
            </ng-map>

        </div>
        <div style="float:right;width:28%">
            <label for="sourceDdl">Source: </label>
            <select id="sourceDdl">
                <option ng-repeat="source in sources" value="{{source}}">{{source}}</option>
            </select>
            <br>
            <br>
            <label for="destinationDdl">Destination: </label>
            <select id="destinationDdl">
                <option ng-repeat="destination in destinations" value="{{destination}}">{{destination}}</option>
            </select>
            <br>
            <br>
            <label>Distance: {{map.directionsRenderers[0].directions.routes[0].overview_path.length}}</label>
            <br>
            <input type="button" ng-click="drawMap()" value="Draw Map">
        </div>
        
    </div>

于 2016-05-11T20:07:52.637 に答える
0

for 1) label="X" を追加するだけです

于 2016-05-10T15:05:40.990 に答える