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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Google Maps API Javascript

  • 25-11-2014 6:32pm
    #1
    Registered Users, Registered Users 2 Posts: 2,608 ✭✭✭


    I'm currently working on a college project which incorporates the use of Google Maps API (v3). I am using HTML Templates - so I have a base.html, containing Css links, script links, etc, which is imported into all the other html pages by way of : {% extends 'base.html' %}

    Now I am going to have multiple pages using maps for different things such as 1 for adding locations and one for adding routes on maps for example. I was originally going to just call on 1 .js file for all my javascript but couldn't figure out how to call specific js variables to just specific HTML pages.

    But I have managed to work it so that I have a different .js file for each thing I want to use for the map on that particular page. And in my base.html, I am calling these .js files individually like so:
    <script src="/static/js/1.js"></script>
    <script src="/static/js/2.js"></script>
    <script src="/static/js/3.js"></script>
    

    My question is is this method ok to work, or will there be problems calling a number of different .js files? I'd imagine I would have about 5 or 6 in total.


Comments

  • Registered Users, Registered Users 2 Posts: 6,240 ✭✭✭hussey


    No problem to be declared like this, the thing to look out for are dependencies
    i.e. if 3 is depending on 1 (cross variables) then load 1 before 3 etc


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


    If 1.js is for setting up a div to show a map where you can add locations and 2.js is for setting up a div with the same id to allow the user to add routes then 2.js will override 1.js on both html pages. If each js file has code that won't clash then fine or if the divs on each html page have different ids then also fine. Unless I am misunderstanding this setup that is.


  • Registered Users, Registered Users 2 Posts: 2,608 ✭✭✭irish_stevo815


    mewso wrote: »
    If 1.js is for setting up a div to show a map where you can add locations and 2.js is for setting up a div with the same id to allow the user to add routes then 2.js will override 1.js on both html pages. If each js file has code that won't clash then fine or if the divs on each html page have different ids then also fine. Unless I am misunderstanding this setup that is.

    Yeah i will be using different id's for each div, so one page will call "map-canvas", and the other will call on "map-route", etc.


Advertisement