2014-10-28 91 views
-2

我需要幫助添加兩件事。谷歌地圖JavaScript API v3更改標記並添加衛星視圖

var image ='1368298974442034922android-car-home-256-th.png'; 我想去掉紅默認標記,並添加這個項目

,我不知道如何將這種從地圖切換到衛星視圖

<!DOCTYPE html> 
<html> 
    <head> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 
    <meta charset="utf-8"> 
    <title>Info windows</title> 
    <style> 
     html, body, #map-canvas { 
     height: 100%; 
     margin: 0px; 
     padding: 0px 
     } 
     .content 
     { 
      width:75%; 
      height:45px; 
      overflow:scroll; 
     } 
    </style> 
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> 
    <script> 
// This example displays a marker at the center of Australia. 
// When the user clicks the marker, an info window opens. 

function initialize() { 
    var myLatlng = new google.maps.LatLng(36.3135749,-95.3050332); 
    var mapOptions = { 
    zoom: 20, 
    center: myLatlng 
    }; 

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

    var contentString = '<div id="content">'+ 
     '<div id="siteNotice">'+ 
     '</div>'+ 
     '<h1 id="firstHeading" class="firstHeading">Here It Is!</h1>'+ 
     '<div id="bodyContent">'+ 
     'Acording to our records it looks like your item is located with in a few feet of here.<br><br> Need more info check out this info. <br> <a href="http://www.example.com">http://www.example.com</a></div>'+ 
     '</div>'; 


    var infowindow = new google.maps.InfoWindow({ 
     content: contentString 
    }); 


    var marker = new google.maps.Marker({ 
     position: myLatlng, 
     map: map, 
     title: 'Here Is Where We Found It!' 
    }); 
    google.maps.event.addListener(marker, 'click', function() { 
    infowindow.open(map,marker); 
    }); 
} 

google.maps.event.addDomListener(window, 'load', initialize); 

    </script> 
    </head> 
    <body> 
    <div id="map-canvas"></div> 
    </body> 
</html> 

回答

1

標記:

var marker = new google.maps.Marker({ 
    position: myLatlng, 
    map: map, 
    title: 'Here Is Where We Found It!', 
    icon: "1368298974442034922android-car-home-256-th.png" 
}); 

衛星視圖:

var mapOptions = { 
    zoom: 20, 
    center: myLatlng, 
    mapTypeId: google.maps.MapTypeId.SATELLITE 
}; 
+0

謝謝你做了我所需要的幫助! – Kelly 2014-10-28 12:05:58