Loading third party scripts such src=“http://js.api.here.com/v3/3.0/mapsjs-service.js” into Nodejs...












1















I am trying to integrate Here maps into my Nodejs website. What I want to do is create a map object as show below inside my app.js file.



var map = new H.Map(
document.getElementById('mapContainer'),
maptypes.normal.map,
{
zoom: 10,
center: { lng: 13.4, lat: 52.51 }
});


Then I want to pass this map object to my ejs file to display. But I am not able to figure how to load the below scripts into my application. These files are the scripts provided by Here maps, which needs to be loaded for creating the map object.



<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
type="text/javascript" charset="utf-8"></script>
<script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
type="text/javascript" charset="utf-8"></script>


If I try to load these files into my ejs files I get an error stating H is not defined. Can someone please tell me how to load these scripts in my application so I have access for new H.map(...). And how do I make these variables available in my ejs file




Long Story Short I want to add the following code in to my nodejs application, separating the code inside the script tag in a js file and HTML part into a EJS file







<html>
<head>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
type="text/javascript" charset="utf-8"></script>
<script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div style="width: 640px; height: 480px" id="mapContainer"></div>
<script>
// Initialize the platform object:
var platform = new H.service.Platform({
'app_id': '{YOUR_APP_ID}',
'app_code': '{YOUR_APP_CODE}'
});

// Obtain the default map types from the platform object
var maptypes = platform.createDefaultLayers();

// Instantiate (and display) a map object:
var map = new H.Map(
document.getElementById('mapContainer'),
maptypes.normal.map,
{
zoom: 10,
center: { lng: 13.4, lat: 52.51 }
});
</script>
</body>
</html>












share|improve this question





























    1















    I am trying to integrate Here maps into my Nodejs website. What I want to do is create a map object as show below inside my app.js file.



    var map = new H.Map(
    document.getElementById('mapContainer'),
    maptypes.normal.map,
    {
    zoom: 10,
    center: { lng: 13.4, lat: 52.51 }
    });


    Then I want to pass this map object to my ejs file to display. But I am not able to figure how to load the below scripts into my application. These files are the scripts provided by Here maps, which needs to be loaded for creating the map object.



    <meta name="viewport" content="initial-scale=1.0, width=device-width" />
    <script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
    type="text/javascript" charset="utf-8"></script>
    <script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
    type="text/javascript" charset="utf-8"></script>


    If I try to load these files into my ejs files I get an error stating H is not defined. Can someone please tell me how to load these scripts in my application so I have access for new H.map(...). And how do I make these variables available in my ejs file




    Long Story Short I want to add the following code in to my nodejs application, separating the code inside the script tag in a js file and HTML part into a EJS file







    <html>
    <head>
    <meta name="viewport" content="initial-scale=1.0, width=device-width" />
    <script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
    type="text/javascript" charset="utf-8"></script>
    <script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
    type="text/javascript" charset="utf-8"></script>
    </head>
    <body>
    <div style="width: 640px; height: 480px" id="mapContainer"></div>
    <script>
    // Initialize the platform object:
    var platform = new H.service.Platform({
    'app_id': '{YOUR_APP_ID}',
    'app_code': '{YOUR_APP_CODE}'
    });

    // Obtain the default map types from the platform object
    var maptypes = platform.createDefaultLayers();

    // Instantiate (and display) a map object:
    var map = new H.Map(
    document.getElementById('mapContainer'),
    maptypes.normal.map,
    {
    zoom: 10,
    center: { lng: 13.4, lat: 52.51 }
    });
    </script>
    </body>
    </html>












    share|improve this question



























      1












      1








      1








      I am trying to integrate Here maps into my Nodejs website. What I want to do is create a map object as show below inside my app.js file.



      var map = new H.Map(
      document.getElementById('mapContainer'),
      maptypes.normal.map,
      {
      zoom: 10,
      center: { lng: 13.4, lat: 52.51 }
      });


      Then I want to pass this map object to my ejs file to display. But I am not able to figure how to load the below scripts into my application. These files are the scripts provided by Here maps, which needs to be loaded for creating the map object.



      <meta name="viewport" content="initial-scale=1.0, width=device-width" />
      <script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
      type="text/javascript" charset="utf-8"></script>
      <script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
      type="text/javascript" charset="utf-8"></script>


      If I try to load these files into my ejs files I get an error stating H is not defined. Can someone please tell me how to load these scripts in my application so I have access for new H.map(...). And how do I make these variables available in my ejs file




      Long Story Short I want to add the following code in to my nodejs application, separating the code inside the script tag in a js file and HTML part into a EJS file







      <html>
      <head>
      <meta name="viewport" content="initial-scale=1.0, width=device-width" />
      <script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
      type="text/javascript" charset="utf-8"></script>
      <script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
      type="text/javascript" charset="utf-8"></script>
      </head>
      <body>
      <div style="width: 640px; height: 480px" id="mapContainer"></div>
      <script>
      // Initialize the platform object:
      var platform = new H.service.Platform({
      'app_id': '{YOUR_APP_ID}',
      'app_code': '{YOUR_APP_CODE}'
      });

      // Obtain the default map types from the platform object
      var maptypes = platform.createDefaultLayers();

      // Instantiate (and display) a map object:
      var map = new H.Map(
      document.getElementById('mapContainer'),
      maptypes.normal.map,
      {
      zoom: 10,
      center: { lng: 13.4, lat: 52.51 }
      });
      </script>
      </body>
      </html>












      share|improve this question
















      I am trying to integrate Here maps into my Nodejs website. What I want to do is create a map object as show below inside my app.js file.



      var map = new H.Map(
      document.getElementById('mapContainer'),
      maptypes.normal.map,
      {
      zoom: 10,
      center: { lng: 13.4, lat: 52.51 }
      });


      Then I want to pass this map object to my ejs file to display. But I am not able to figure how to load the below scripts into my application. These files are the scripts provided by Here maps, which needs to be loaded for creating the map object.



      <meta name="viewport" content="initial-scale=1.0, width=device-width" />
      <script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
      type="text/javascript" charset="utf-8"></script>
      <script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
      type="text/javascript" charset="utf-8"></script>


      If I try to load these files into my ejs files I get an error stating H is not defined. Can someone please tell me how to load these scripts in my application so I have access for new H.map(...). And how do I make these variables available in my ejs file




      Long Story Short I want to add the following code in to my nodejs application, separating the code inside the script tag in a js file and HTML part into a EJS file







      <html>
      <head>
      <meta name="viewport" content="initial-scale=1.0, width=device-width" />
      <script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
      type="text/javascript" charset="utf-8"></script>
      <script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
      type="text/javascript" charset="utf-8"></script>
      </head>
      <body>
      <div style="width: 640px; height: 480px" id="mapContainer"></div>
      <script>
      // Initialize the platform object:
      var platform = new H.service.Platform({
      'app_id': '{YOUR_APP_ID}',
      'app_code': '{YOUR_APP_CODE}'
      });

      // Obtain the default map types from the platform object
      var maptypes = platform.createDefaultLayers();

      // Instantiate (and display) a map object:
      var map = new H.Map(
      document.getElementById('mapContainer'),
      maptypes.normal.map,
      {
      zoom: 10,
      center: { lng: 13.4, lat: 52.51 }
      });
      </script>
      </body>
      </html>








      <html>
      <head>
      <meta name="viewport" content="initial-scale=1.0, width=device-width" />
      <script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
      type="text/javascript" charset="utf-8"></script>
      <script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
      type="text/javascript" charset="utf-8"></script>
      </head>
      <body>
      <div style="width: 640px; height: 480px" id="mapContainer"></div>
      <script>
      // Initialize the platform object:
      var platform = new H.service.Platform({
      'app_id': '{YOUR_APP_ID}',
      'app_code': '{YOUR_APP_CODE}'
      });

      // Obtain the default map types from the platform object
      var maptypes = platform.createDefaultLayers();

      // Instantiate (and display) a map object:
      var map = new H.Map(
      document.getElementById('mapContainer'),
      maptypes.normal.map,
      {
      zoom: 10,
      center: { lng: 13.4, lat: 52.51 }
      });
      </script>
      </body>
      </html>





      <html>
      <head>
      <meta name="viewport" content="initial-scale=1.0, width=device-width" />
      <script src="http://js.api.here.com/v3/3.0/mapsjs-core.js"
      type="text/javascript" charset="utf-8"></script>
      <script src="http://js.api.here.com/v3/3.0/mapsjs-service.js"
      type="text/javascript" charset="utf-8"></script>
      </head>
      <body>
      <div style="width: 640px; height: 480px" id="mapContainer"></div>
      <script>
      // Initialize the platform object:
      var platform = new H.service.Platform({
      'app_id': '{YOUR_APP_ID}',
      'app_code': '{YOUR_APP_CODE}'
      });

      // Obtain the default map types from the platform object
      var maptypes = platform.createDefaultLayers();

      // Instantiate (and display) a map object:
      var map = new H.Map(
      document.getElementById('mapContainer'),
      maptypes.normal.map,
      {
      zoom: 10,
      center: { lng: 13.4, lat: 52.51 }
      });
      </script>
      </body>
      </html>






      javascript jquery node.js here-api here-maps-rest






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 5:50









      j12y

      6211617




      6211617










      asked Nov 14 '18 at 19:10









      Palash JainPalash Jain

      103




      103
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Since you are using EJS, you might want to check this out:
          How to include external .js file to ejs Node template page



          In short, the script in EJS runs on server side before the page is send to the client.



          To use the the third party scripts, try installing them on your server side.



          npm i here-js-api


          And then load the them into your script:
          Adding local script files to EJS views






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307200%2floading-third-party-scripts-such-src-http-js-api-here-com-v3-3-0-mapsjs-servi%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Since you are using EJS, you might want to check this out:
            How to include external .js file to ejs Node template page



            In short, the script in EJS runs on server side before the page is send to the client.



            To use the the third party scripts, try installing them on your server side.



            npm i here-js-api


            And then load the them into your script:
            Adding local script files to EJS views






            share|improve this answer






























              1














              Since you are using EJS, you might want to check this out:
              How to include external .js file to ejs Node template page



              In short, the script in EJS runs on server side before the page is send to the client.



              To use the the third party scripts, try installing them on your server side.



              npm i here-js-api


              And then load the them into your script:
              Adding local script files to EJS views






              share|improve this answer




























                1












                1








                1







                Since you are using EJS, you might want to check this out:
                How to include external .js file to ejs Node template page



                In short, the script in EJS runs on server side before the page is send to the client.



                To use the the third party scripts, try installing them on your server side.



                npm i here-js-api


                And then load the them into your script:
                Adding local script files to EJS views






                share|improve this answer















                Since you are using EJS, you might want to check this out:
                How to include external .js file to ejs Node template page



                In short, the script in EJS runs on server side before the page is send to the client.



                To use the the third party scripts, try installing them on your server side.



                npm i here-js-api


                And then load the them into your script:
                Adding local script files to EJS views







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 15 '18 at 1:58

























                answered Nov 15 '18 at 1:48









                Jonathan TsaiJonathan Tsai

                1464




                1464
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307200%2floading-third-party-scripts-such-src-http-js-api-here-com-v3-3-0-mapsjs-servi%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Bressuire

                    Vorschmack

                    Quarantine