2013-03-08 93 views
1

如何更改嵌入式Google地圖中的引腳標籤?更改google地圖中的pin標籤?

香港專業教育學院想出如何標記改變我的圖標,但我需要再整的A,B,C等類似如何Travelodge酒店做有地圖http://www.travelodge.co.uk/hotels/book/edinburgh-hotels

UPDATE這是成功使用的代碼自定義標記:

function addMarker(latlng, myTitle) { 
     markers.push(new google.maps.Marker({ 
      position: latlng, 
      map: map, 
      title: myTitle, 
      icon: "www.linkto/myPin.png" 
      })); 
    } 

伊夫包括markerwithlabel.js然而,這並不在所有創建任何標記:

function addMarker(latlng, myTitle) { 
     markers.push(new MarkerWithLabel({ 
      position: latlng, 
      map: map, 
      title: myTitle, 
      icon: "www.linkto/myPin.png", 

      labelContent: "$425K", 
      labelAnchor: new google.maps.Point(22, 0), 
      labelClass: "labels", 
      labelStyle: {opacity: 0.75} 

      })); 
    } 

這是我的代碼被捆綁適應: http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.8/examples/basic.html

回答

4

如果你設法改變標記圖標,那麼你做了所有的工作

標記沒有標籤。 Travelodge的功能是爲每個字母設置標記,然後根據搜索結果設置它們。

編輯:

似乎有一種特殊的庫做你想要什麼(去「病急亂投醫標記」):

http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries#MarkerWithLabel

要查看「開發版本的代碼,請點擊「,然後是」Examples「,然後查看頁面的源代碼。下面是簡單的示例代碼:

function initialize() { 
    var myLatLng = new google.maps.LatLng(37.313477473067, -121.880502070713); 
    var myOptions = { 
    zoom: 11, 
    center: myLatLng, 
    mapTypeId: google.maps.MapTypeId.SATELLITE 
    }; 

    var map = new google.maps.Map(document.getElementById("map_canvas"), 
    myOptions); 

    var styleMaker2 = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.BUBBLE,{color:"ff0000",text:"I'm a marker!"}),position:new google.maps.LatLng(37.383477473067, -121.880502070713),map:map}); 
    var styleMaker1 = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.MARKER,{color:"00ff00",text:"A"}),position:myLatLng,map:map}); 
    var styleMaker3 = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.MARKER,{color:"0000ff"}),position:new google.maps.LatLng(37.263477473067, -121.880502070713),map:map}); 
} 

你可以閱讀更多關於標記上this link

+0

你確定嗎?從看他們的網站,我可以看到針和標籤是分開的圖像。 – Evans 2013-03-08 10:00:13

+0

@jdln我很抱歉,您是對的,我會發布回答 – alestanis 2013-03-08 10:02:16

+0

感謝您的回覆。我試着使用示例中的代碼並按問題更新,但它不起作用。謝謝 – Evans 2013-03-08 11:35:49