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.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Google Maps API Javascript

  • 25-11-2014 06:32PM
    #1
    Registered Users, Registered Users 2 Posts: 2,609 ✭✭✭


    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,224 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,609 ✭✭✭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