Map Ready

Home Forums MapPress Support Map Ready

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13933
    ryderp
    Participant

    Chris,

    Is there a definitive or recommended way to tell if a map is ready? I’d like my page to manipulate the POIs obtained by mapp0.getPois during the page load (some checkbox stuff). In my onload function the mapp object is undefined. There is a horrible workround using intervals/timeouts but I’d rather use a listener event. Any recommends?

    I’m on pro latest version…

    Cheers, Paul

    #13944
    Chris
    Keymaster

    Hi,

    This may work: get the Google map object for the map, then use the ‘idle’ or ’tilesloaded’ event (they have a description in the API documentation):

    mapp0.getMap();
    google.maps.event.addListenerOnce(_gmap, 'tilesloaded', function() {
      alert('ready');
    });
    
    #13946
    ryderp
    Participant

    Chris

    The issue with that is mapp0.getMap doesn’t work as mapp0 is undefined in my onload procedure. I could do with a way to see when mapp0 is available… not sure if that’s possible though..?

    Cheers, Paul

    #13955
    Chris
    Keymaster

    Hi,

    If you check the page HTML, is the map object named mapp0? That’s the default name for the first map on the screen (you can also control it in the shortcode with name=”myname”).

    You can also see on the page source if the map is being loaded after document ready. If so, try using that jQuery event:

    jQuery(document).ready(function() {
      ..code...
    });

    If you queue your ‘ready’ event in the footer of the page, it should execute after the one queued to create the map object.

    If the above don’t help then you may want to look at modifying mappress.php where the map is output to include your ready event there. If you take that approach let me know and I’ll try to include an action or filter hook there for future development so you don’t need to keep applying the modification.

    #13961
    ryderp
    Participant

    Chris,

    My map is mapp0

    I tried adding the following after mapp0.display in mappress.php

    var prmap = window.mapp0.getMap();
    alert(prmap)

    The alert gives me a null value for prmap

    In the windows console this gives an error

    TypeError : a is null

    in line 14 of main.js – shown below

    No need to spend lots of time on this. My workround works (but is ugly!). I was hoping this might turn out to be a quickie…

    function le(a,b,c){var d=a[Lb](“head”)[0];a=a[xb](“script”);Va(a,”text/javascript”);a.charset=”UTF-8″;a.src=b;c&&Ra(a,c);d[eb](a);return a}function me(){return k.devicePixelRatio||fa.deviceXDPI&&fa.deviceXDPI/96||1}function ne(a,b){if(ba[F][Wb][Qc](a,b))return a[b]};var oe=this;var pe=”click”,qe=”contextmenu”,re=”dblclick”,se=”mousedown”,ve=”mousemove”,we=”mouseover”,xe=”mouseout”,ye=”mouseup”,ze=”forceredraw”,Ae=”rightclick”,Be=”staticmaploaded”,Ce=”panby”,De=”panto”,Ee=”insert”,Fe=”remove”;var O={};O.Qe=”undefined”!=typeof ga&&-1!=ga.userAgent[Xc]()[rc](“msie”);O.Wd={};O.addListener=function(a,b,c){return new Ge(a,b,c,0)};O.xf=function(a,b){var c=a.__e3_,c=c&&c[b];return!!c&&!Jd(c)};O.removeListener=function(a){a&&a[wb]()};O.clearListeners=function(a,b){Id(He(a,b),function(a,b){b&&b[wb]()})};O.clearInstanceListeners=function(a){Id(He(a),function(a,c){c&&c[wb]()})};function Ie(a,b){a.__e3_||(a.__e3_={});var c=a.__e3_;c[b]||(c[b]={});return c[b]}

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.