function Store( lat, l...">

Javascript / Google Maps causing PIE.htc errors

Everything, I have the following code:

<script type="text/javascript">
function Store( lat, long, text )
{
    this.latitude = lat;
    this.longitude = long;
    this.html = text;
}

var myStores = [<?php echo $jsData;?>, null];
addLoadEvent(loadMap);

This is populated with the following code:

$lat = $post->latitude;
$long = $post->longitude;
$post_id = $post->ID;
$get_post_info = get_post($post_id); 
$name = $get_post_info->post_title;
$jsData = $jsData . "new Store( $lat, $long, '$name' ),\n";

My page loads fine without a javascript part. However, when I add javascript, I get the following error:

User Agent: Mozilla / 4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident / 4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath. 3; .NET4.0C; .NET4.0E; MS-RTC LM 8; AskTbAD2 / 5.14.1.20007)
Timestamp: Wed, 22 Feb 2012 16:45:35 UTC

Message: Arg: Illegal input string in Vector2D
Line: 68
Char: 63
Code: 0
URI: http: //localhost/wordpress/wp-content/themes/parallelus-mingle/assets/css/PIE.htc

I even narrowed it even further, and this line throws an error:

addLoadEvent(loadMap);

Here is the complete code for addLoadEvent (loadMap):

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script  type="text/javascript">
function addLoadEvent(func) { 
var oldonload = window.onload; 
if (typeof window.onload != 'function'){ 
    window.onload = func
} else { 
    window.onload = function() {
        oldonload();
        func();
    }
}
}

var map,
    infowin=new google.maps.InfoWindow({content:'moin'});
function loadMap() 
{
  map = new google.maps.Map(
    document.getElementById('map'),
    {   
      zoom: 12,
      mapTypeId:google.maps.MapTypeId.ROADMAP,
      center:new google.maps.LatLng(<?php echo $_SESSION['pav_event_latitude']; ?>, 
                                    <?php echo $_SESSION['pav_event_longitude']; ?>)
    });

  addPoints(myStores);
}

function addPoints( points )
{  
  var bounds=new google.maps.LatLngBounds();
  for ( var p = 0; p < points.length; ++p )
  {
    var pointData = points[p];
    if ( pointData == null ) {map.fitBounds(bounds);return; }
    var point = new google.maps.LatLng( pointData.latitude, pointData.longitude );
    bounds.union(new google.maps.LatLngBounds(point));
    createMarker( point,  pointData.html );
  }
  map.fitBounds(bounds);

}

var number = 2; // or whatever you want to do here
function createMarker(point,  popuphtml) 
{
  var popuphtml = "<div id=\"popup\">" + popuphtml + "<\/div>";
  var marker = new google.maps.Marker(
    {
      position:point,
      map:map,
      icon:'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld='+number+'|FF776B|000000',
      shadow:'https://chart.googleapis.com/chart?chst=d_map_pin_shadow'
    }
  );
  google.maps.event.addListener(marker, 'click', function() {
      infowin.setContent(popuphtml)
      infowin.open(map,marker);
    });

}
</script>

Any ideas why this might cause an error?

+5
2

, addLoadEvent() , , loadMap() PIE.htc. , , typeof object not function. , :

function addLoadEvent(func) { 
    if (window.addEventListener) {
        window.addEventListener('load', func, false);
    } else if(window.attachEvent) {
        window.attachEvent('onload', func);
    }
}

, , , jQuery $(document).ready(), domReady, .

Edit: , :

var myStores = [<?php echo $jsData;?>, null];

null, - PHP- .

+3

All Articles