locked
Exception thrown error when trying to set a pushpin

    Question

  • Hi

     

       I seem to be having trouble setting a pushpin on a map.  I can generate the map and set the style, zoom and centre but when I try to add the pin, I get an exception thrown and not caught error.  I am testing on version 6.0.2 browers, could that be the problem??  Here is the code in question.  Everything seems to work fine up until the alert.  Thanks Mike

     

    <head>
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5">
    </script>
    <script>
    var map = null;
    var location = new Array();
    var location_desc = new Array();
    var location_lat = new Array();
    var location_lon = new Array();
    function ready_map() {
          if ( document.getElementById('map_div').innerHTML != "" ) {
       document.getElementById('map_div').innerHTML = "";
       map = new VEMap('map_div');
       var temp_home =   new VELatLong(" 42.961784362793", " -81.231071472168");
          map.LoadMap(temp_home, 13);
                 map.SetMapStyle("r");
                 alert("now");
                 add_pin();  
          return;
          }
    }
    function add_pin() {
                     var pin_location = new VELatLong(location_lat[1], location_lon[1]);        
                     var pin = new VEShape(VEShapeType.Pushpin, pin_location);
       pin.SetTitle(location[1]);
       pin.SetDescription(location_desc[1]);
       map.AddShape(pin);
       }
    </script>

         
    </head>
    <body onload="ready_map();">
       <div id="map_div" style="height:425px;width:425px">A Map is generated here</div><script type="text/javascript">
                     location[1] = "Country Bulk";
         location_desc[1] = "<b>Weber Street North<BR>Waterloo's Farmers Market<BR>Waterloo, ON";
         location_lat[1] = " 43.468566894531";
         location_lon[1] = " -80.511100769043";

                     </script>
    </body>

    mercredi 25 juillet 2007 19:17

Réponses

  • simple but anoying, treat lat long as numeric not string so remove the quotes for each and it works fine

     

     

    Brian Norman
    www.earthware.co.uk


    Need instant Virtual Earth help? Try calling me on Skype Prime Call Me

    mercredi 25 juillet 2007 20:56

Toutes les réponses

  • simple but anoying, treat lat long as numeric not string so remove the quotes for each and it works fine

     

     

    Brian Norman
    www.earthware.co.uk


    Need instant Virtual Earth help? Try calling me on Skype Prime Call Me

    mercredi 25 juillet 2007 20:56
  • Thanks Brian

        I can't believe I spent days looking for the problem.  The quotes were exactly the problem. 
    mercredi 25 juillet 2007 23:03