未捕获的ReferenceError:未定义initialize

时间:2012-03-07 07:54:12

标签: javascript cdata

我正在尝试使用web2py在页面上呈现多个自定义标记 框架和我的地图不会呈现。我看到使用chrome的调试器 两个错误,一个说“Uncaught SyntaxError:Unexpected token<”和 第二个说“未捕获的ReferenceError:初始化不是 定义“。我很感激帮助确定我在做什么 错。

以下是我的网站http://roamweb.sanren.ac.za/的链接。

我的代码副本粘贴在下面。

    <!DOCTYPE HTML> 
    <html>
    <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
    <!--  <style type="text/css">
    html { height: 100% }
    body { height: 100%; margin: 0px; padding: 0px }
    #map_canvas { height: 100% }
    </style> -->

    <script type="text/javascript"
    src="http://maps.google.com/maps/api/js?v=3key={{=GOOGLEMAP_KEY}}&sensor=false">
    </script>
    <script type="text/javascript"> <![CDATA[
       function initialize() {
       var myOptions = {
       center: new google.maps.LatLng(-28.401065, 25.312500),
       zoom: 6,
       mapTypeId: google.maps.MapTypeId.ROADMAP
   };

       var map = new google.maps.Map(document.getElementById('map_canvas'),options);

       function createMarker(point, i, message) {
         if(i==0) google.maps.MarkerOptions = {
           {{for row in rows:}}{{if row.latitude and row.longitude:}}
           var point = new google.maps.LatLng({{=row.latitude}},{{=row.longitude}});
           var message = '{{=str(row.plugin_gmap_popup).replace("'","\\'")}}'
           var myicon = new google.maps.MarkerImage('http://roamweb.sanren.ac.za/db/static/Icon-wifi.png', null, null, new google.maps.Point(9,34), new google.maps.Size(37,34));
           var marker = new google.maps.Marker({
           position: point;
           icon: myicon;
           title: 'click me for info';
           )};
       };
       else google.maps.MarkerOptions = {};
       var infoWindow = new google.maps.InfoWindow({
         content:message
       )};
       google.maps.event.addListener(marker, 'click', function() {
           infoWindow.open(map, marker)
       });

       marker.setMap(map);
   };

       createMarker(point, 0, message);

       {{pass}}{{pass}}
 }
]]>

    </script>
    </head>
    <body onload="initialize()">
       <div id="map_canvas" style="width: {{=width}}px; height:{{=height}}px"></div>
    </body>
    </html>

1 个答案:

答案 0 :(得分:3)

尝试使用

更正CDATA
<script type="text/javascript">
//<![CDATA[
...
//]]>
</script>