0

Google Maps APiスタイルの地図の実装に少し問題があります。varstylesとmap.setoptionsを削除することで、場所とカスタムマーカーを機能させることができますが、すぐにGoogleスタイルのコーディングを地図に追加しようとします。もはや機能しません、何かアイデアはありますか?

<script type="text/javascript">
      function initialize() {
        var styles = [ 
          { 
          featureType: "water", 
          elementType: "geometry.fill",
          stylers: [ 
            { color: "#73b6e6" }
            ] 
            },{
          featureType: "road.highway",
          elementType: "geometry.fill",
          stylers: [ 
            { color: "#ffffff" } 
            ] 
            },{
          featureType: "road.highway",
          elementType: "geometry.stroke",
          stylers: [
            { color: "#c8c8c8" }
            ] 
            },{
          featureType: "road.local",
          stylers: [ 
            { color: "#ffffff" } 
            ] 
            },{
          featureType: "road.arterial",
          elementType: "geometry.fill", 
          stylers: [ 
            { color: "#ffffff" } 
            ] 
            },{
          featureType: "road.arterial",
          elementType: "geometry.stroke",
          stylers: [ 
            { color: "#c8c8c8" } 
            ] 
            },{
          featureType: "road.highway",
          elementType: "labels.text.stroke",
          stylers: [ 
            { visibility: "off" } 
            ] 
            },{
          featureType: "road.arterial", 
          elementType: "labels.text.stroke",
          stylers: [ { visibility: "off" } 
            ] 
            },{
          featureType: "poi",
          elementType: "labels",
          stylers: [ { "visibility": "off" } 
            ] 
            },{
          featureType: "poi.park",
          stylers: [ { color: "#cae6a9" } 
            ] 
            },{
          featureType: "administrative.neighborhood",
          elementType: "labels.text.fill",
          stylers: [ { "visibility": "off" } 
            ] 
            }
        ];
        map.setOptions({styles: styles});
        var mapOptions = {
          center: new google.maps.LatLng(-34.94533,138.58934),
          zoom: 14,
          scrollwheel: false,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("location-map"),
            mapOptions);
        var image = 'images/main/location.png';
        var myLatLng = new google.maps.LatLng(-34.94533,138.58934);
        var beachMarker = new google.maps.Marker({
            position: myLatLng,
            map: map,
            icon: image
        });
      };
    </script>

HTMLコード

<div id="location-map" style="background-color: #E5E3DF; overflow: hidden;">
</div>
4

1 に答える 1

1

作成する前にマップ変数は存在しませんが、次の行の前にmap.setOptionsを呼び出しています。

var map = new google.maps.Map(document.getElementById("location-map"),
            mapOptions);

この行を移動するだけです:

map.setOptions({styles: styles});

この後:

var map = new google.maps.Map(document.getElementById("location-map"),
            mapOptions);
于 2013-01-28T00:24:58.690 に答える