2013-03-08 127 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