为什么我的自定义标记不会显示在Google地图中?

时间:2009-06-17 20:13:14

标签: javascript google-maps

如果有人可以帮助我,地图显示正常,但标记会显示。

    <script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAIoLIQYVphLGoM1pKOrQx0RSlCk5zF9psbOtT7Cn7bdX8qwZsZBTDgtPCGxlAzv6RxAThsHj0CmmZVg"></script>
    <script type="text/javascript">
  var myIcon = new GIcon();
myIcon.image = 'markers/image.png';
myIcon.printImage = 'markers/printImage.gif';
myIcon.mozPrintImage = 'markers/mozPrintImage.gif';
myIcon.iconSize = new GSize(45,46);
myIcon.shadow = 'markers/shadow.png';
myIcon.transparent = 'markers/transparent.png';
myIcon.shadowSize = new GSize(68,46);
myIcon.printShadow = 'markers/printShadow.gif';
myIcon.iconAnchor = new GPoint(23,46);
myIcon.infoWindowAnchor = new GPoint(23,0);
myIcon.imageMap = [39,1,40,2,41,3,41,4,41,5,41,6,41,7,41,
                   8,41,9,41,10,41,11,41,12,41,13,41,14,
                   41,15,41,16,41,17,41,18,41,19,41,20,41,
                   21,41,22,41,23,41,24,41,25,41,26,41,27,
                   41,28,41,29,41,30,41,31,41,32,40,33,39,
                   34,27,35,26,36,26,37,25,38,25,39,24,40,
                   24,41,23,42,23,43,22,44,22,45,22,45,22,
                   44,21,43,21,42,20,41,20,40,19,39,19,38,
                   18,37,18,36,17,35,5,34,4,33,3,32,3,31,3,
                   30,3,29,3,28,3,27,3,26,3,25,3,24,3,23,3,
                   22,3,21,3,20,3,19,3,18,3,17,3,16,3,15,3,
                   14,3,13,3,12,3,11,3,10,3,9,3,8,3,7,3,6,3,
                   5,3,4,4,3,4,2,6,1];
  myIcon.iconSize = new GSize(10, 10);
  myIcon.iconAnchor = new GPoint(5, 34);
  Imycon.infoWindowAnchor = new GPoint(5, 2);
  var markers = [{'latitude': 169.132892, 'longitude': -44.698667, 'name': 'dsfsdfljsldk' }]; var map;
  var centerLatitude = 18.17;
  var centerLongitude = 127.57;
  var startZoom = 2;
</script>
<script language="javascript">
    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(51.83130, -0.21360), 15);
        map.setUIToDefault();
      }
    }
    </script>

1 个答案:

答案 0 :(得分:4)

您没有在地图上添加任何标记 - 除非您没有在此处发布所有代码。你需要做这样的事情:

var latlng = new GLatLng(169.132892,-44.698667);
var marker = new GMarker(latlng, {icon:myIcon, title:"dsfsdfljsldk"});
map.addOverlay(marker);