Home › Forums › MapPress Support › Map Ready
- This topic has 4 replies, 2 voices, and was last updated 9 years, 1 month ago by
ryderp.
-
AuthorPosts
-
December 13, 2013 at 9:47 pm #13933
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
December 15, 2013 at 7:10 pm #13944Hi,
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'); });
December 15, 2013 at 9:00 pm #13946Chris
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
December 16, 2013 at 6:37 am #13955Hi,
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.
December 16, 2013 at 9:15 pm #13961Chris,
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]}
-
AuthorPosts
- You must be logged in to reply to this topic.