Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Probocop 51 posts 71 karma points
    May 03, 2011 @ 17:25
    Probocop
    0

    Getting a JavaScript error when trying to render map.

    Hi,

    I have installed the package, included the Google Maps API, and added the JavaScript code to my jQuery document ready function - But upon trying to render the map I'm getting the following error in FireBug.

    "fm is not defined"

    Any idea what could be causing this?

    Thanks

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    May 03, 2011 @ 18:07
    Darren Ferguson
    0

    Not unless you post your code and provide a lot more information. Is the page available on a public URL?

  • Probocop 51 posts 71 karma points
    May 04, 2011 @ 10:24
    Probocop
    0

    Hi Darren,

    Unfortunately it is not on a public URL, but the code I'm using is as follows.

    In my template I have:

    <div id="map1" class="map">
    <umbraco:Item field="map" runat="server"></umbraco:Item>
    </div>

    I can confirm the umbraco:Item is returning the co-ordinates and zoom level correctly.

    And in my jQuery document ready function I have the following:

    if (typeof ItemEditing == 'undefined'{
        $('div[class=map]').each(function({

          $(this).addClass('mapdimensions');
          var mapId $(this).attr('id');
          
          var value $(this).html();
          value $.trim(value);
          
          var point value.split(',');

          var lat parseFloat(point[0]);
          var lon parseFloat(point[1]);
          var zoom parseFloat(point[2]);
          
          fm.maps[fm.maps.lengthnew GMap2(document.getElementById(mapId));
          var fm.maps[fm.maps.length-1];
          
          var new GLatLng(latlon);
          m.setCenter(pzoom)
            

          var marker new GMarker(p);
          m.addOverlay(marker);  
        });
      }

    I am using jQuery version 1.4.2 and I'm also including the Google Maps API with the following code:

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=[MY_KEY_IS_HERE]" type="text/javascript"></script>

    Thanks, Dave

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    May 04, 2011 @ 10:27
    Darren Ferguson
    0

    The error message is just that you haven't declared the fm variable. you need something like:

    var fm = {};

    at the top of your script.

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    May 04, 2011 @ 10:41
    Lee Kelleher
    0

    Hi Dave,

    Not sure why you are using the "fm.maps" namespace/array at all... wouldn't the following work fine?

    var m = new GMap2(document.getElementById(mapId));

    Cheers, Lee.

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    May 04, 2011 @ 10:44
    Darren Ferguson
    0

    @lee - i think the example comes from an old blog post of mine. perhaps we need to blog an update??

  • Probocop 51 posts 71 karma points
    May 04, 2011 @ 10:46
    Probocop
    0

    Hi Darren,

    Thanks for your response.

    I've added 'var fm = {}' to my script but FireBug is telling me now that 'fm.maps is undefined'.

    Dave

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    May 04, 2011 @ 10:49
    Darren Ferguson
    0

    @dave - erm ok:

    var fm = {};
    fm.maps = new Array();

     

  • Probocop 51 posts 71 karma points
    May 04, 2011 @ 10:56
    Probocop
    0

    Thanks, it's working now.

    It did indeed come from a blog post - Linked to from the project page

    "Information on rendering maps on the front end of your Umbraco website is here: www.darren-ferguson.com/.../...mbraco-website.aspx"

    Thanks for the help.
    Dave

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    May 04, 2011 @ 10:56
    Darren Ferguson
    0

    Could you mark the topic as solved please?

    Thanks.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies