Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

[REQ] Could someone check this page for me?

2»

Comments

  • Registered Users, Registered Users 2 Posts: 3,484 ✭✭✭randombar


    Basically, the google maps api loads in an initialize function, this then creates crate marker functions within this initialize function. I would like to run these functions via ajax after the page has loaded but unfortunately can't get at the variables within the initialize function?

    You can see the error on this page:

    http://www.ratemypub.ie/template/county.php?countyid=10

    Thanks for your time musician.


  • Moderators, Science, Health & Environment Moderators Posts: 9,205 Mod ✭✭✭✭mewso


    Is it not possible to declare the map object as global and then use it anywhere?:-
    <script type="text/javascript">
    [B]var map = null;
    [/B]function initialize() {
     if (GBrowserIsCompatible()) {
      [B]map = new GMap2(document.getElementById("map"));
    [/B]  map.addControl(new GSmallMapControl());
      map.setCenter(new GLatLng(53.3833,-6.15234), 8);
      var bounds = new GLatLngBounds();
      function clearBounds() {
      var bounds = new GLatLngBounds();
      }
      function addsmallmappoint(lat,lon,html) {
      var point = new GLatLng(lat, lon);
      map.addOverlay(createSmallMarker(point, html));
      bounds.extend(point);
      map.setZoom(map.getBoundsZoomLevel(bounds));
      map.setCenter(bounds.getCenter());
      }
     }
    }
    </script>
    ....
    <script type="text/javascript">
    if (map){
      //do my stuff
    } 
    </script>
    


  • Registered Users, Registered Users 2 Posts: 3,484 ✭✭✭randombar


    I've made that change there, thanks. But how do you make internal functions global?

    Thanks
    Gary


  • Moderators, Science, Health & Environment Moderators Posts: 9,205 Mod ✭✭✭✭mewso


    GaryCocs wrote: »
    I've made that change there, thanks. But how do you make internal functions global?

    Maybe take it out and create it as a function on it's own then make any vars it references global like map.


  • Registered Users, Registered Users 2 Posts: 3,484 ✭✭✭randombar


    EDIT:

    YESSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

    Ian hobo and musician, I def owe the two of ye a couple of pints! Savage Stuff!!

    Also how do I block my js file from prying eyes?


  • Advertisement
  • Moderators, Science, Health & Environment Moderators Posts: 9,205 Mod ✭✭✭✭mewso


    GaryCocs wrote: »
    EDIT:

    Also how do I block my js file from prying eyes?

    Well you can't really block folks from seeing your files but you can pack them or even obfuscate them. Do a google search for javascript obfuscation or something.


Advertisement