2

を働いていない:ンマップマーカーアイコンは、この作品NGマップで

<marker ng-repeat="helper in helpers" position="{{helper.position}}" optimized="false" icon={{helper.facebook.freshURL}}"></marker> 

しかし、私は "アイコン" でのparamsに入れた場合:

<marker ng-repeat="helper in helpers" position="{{helper.position}}" optimized="false" icon="{url: '{{helper.facebook.freshURL}}', anchor: [0,0]}"></marker> 

をに思えますURLの前に、私はエラーを取得:

GET http://localhost:8100/%7Burl:%20https://graph.facebook.com/1716361775351742/picture?type=normal,%20anchor:%20[0,0]} 404 (Not Found) 

が、これはバグか、私の側にいくつかの構文エラーです:URLが「8000 localhost」が接頭辞を持っていますか?ありがとう。

答えて

2

この動作は、表現の解析中に発生するJSONエラーに関連している:有効式がicon属性のために提供されると{url: '{{helper.facebook.freshURL}}', anchor: [0,0]}

は、たとえばicon='{"url":"{{helper.facebook.freshURL}}","anchor":[0,0]}'のために、マーカーのアイコンが正しく初期化されます。

var app = angular.module('appMaps', ['ngMap']); 
 
app.controller('mapCtrl', function ($scope) { 
 
    
 
    $scope.cities = [ 
 
     { id: 1, name : "Brisbane", location: [-33.867396, 151.206854] } 
 
    ]; 
 

 

 
    $scope.iconProperties = { 
 
     url : "http://maps.google.com/mapfiles/marker.png", 
 
     anchor: [0,0] 
 
    }; 
 

 
    $scope.iconUrl = "http://maps.google.com/mapfiles/marker.png"; 
 

 
});
<script src="https://maps.googleapis.com/maps/api/js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> 
 
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script> 
 
<div ng-app="appMaps" ng-controller="mapCtrl"> 
 
     <map center="[-24.667856, 133.630694]" zoom="3"> 
 
      <!--marker id='ID{{city.id}}' ng-repeat="city in cities" position="{{city.location}}" icon="{{iconProperties}}" --> 
 
      <marker id='ID{{city.id}}' ng-repeat="city in cities" position="{{city.location}}" icon='{"url":"{{iconUrl}}","anchor":[0,0]}'> 
 
      </marker> 
 
      
 
     </map> 
 
</div>

+0

おかげヴァディム、新人のミス。しかし、今私はエラーが発生します: "InvalidValueError:setIcon:文字列ではなく、URLプロパティもパスプロパティもありません"。これを引き起こす原因は何ですか? – huahax

+0

また、「カスタムマーカー」を使用した場合、「TypeError:nullのプロパティ 'className'を読み取れません」というエラーが表示され、マーカーがレンダリングされません。何か案は? – huahax

0

はい、恐らくバグです。これまで文書を探していたが、できなかった。おそらくRegExの問題

まだ見ている場合は、プロトコルを削除してから試してみてください。あなたのURLはこのように見えます。

helper.facebook.freshURL = '//graph.facebook.com/1716361775351742/picture?type=normal'; 

ご連絡ください。

関連する問題