Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

[REQ] Could someone check this page for me?

Options
2»

Comments

  • Registered Users Posts: 3,401 ✭✭✭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: 8,956 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 Posts: 3,401 ✭✭✭randombar


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

    Thanks
    Gary


  • Moderators, Science, Health & Environment Moderators Posts: 8,956 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 Posts: 3,401 ✭✭✭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: 8,956 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