How to combine JS API URL calls? - here-api

In Google maps I can load all libraries I need with one URL call:
https://maps.googleapis.com/maps/api/js?libraries=drawing,foo,bar,baz,qux,library6,etc
In HERE maps I must load all the libraries (they call it modules) separately:
<script src="https://js.api.here.com/v3/3.0/mapsjs-service.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-places.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-mapevents.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-ui.js" type="text/javascript" charset="utf-8"></script>
This is a total disaster.
How do I load all the modules I need in one URL call?
I'm looking for something like this:
https://js.api.here.com/v3/3.0/mapsjs.js?modules=core,service,bar,baz,qux,library6,etc

As you guessed from the accepted answer, there is no endpoint which allows you to concatenate different modules of HERE Maps JavaScript API, however if it really matters for you to concatenate them, you can achieve a similar service very easily.
The following uses curl command to download files:
curl https://js.api.here.com/v3/3.0/mapsjs-{core,service,ui}.js > mapsjs-custom.js

For any application based on the HERE Maps API for JavaScript it is necessary to load the code libraries or modules. The implementation of our basic use case requires two modules: core and service (see also HERE Maps API for JavaScript Modules).
This is the minimum and cannot be avoided or summed up into one link.
The Maps API for JavaScript is organized into a number of modules to give developers the possibility to use the API efficiently by selecting only the modules which their applications require.

Related

Warning "It looks like you're using the development build of the Firebase JS SDK."

Currently I am getting a warning :
It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import
the individual SDK components you intend to use.
For the CDN builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):
https://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js
I have gone through several related links to this problem but even after following all their solutions, I am not able to remove the error.
As the description says to use the given link with the name of the component I am using. I have included the links which I need, still I see the warning.
I have even tried to include all the links given in Firebase website, still I see it.
Currently I am only using Firebase Realtime Database, but while creating firebase init using CMD, I had included Functions, Hosting, Storage and Database.
<script src="https://www.gstatic.com/firebasejs/5.0.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.0.0/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.0.0/firebase.js"></script>
I have even tried changing the versions from 5.0.0 to 5.4.0, but no use.
How to solve this?
I have just solved it by adding two scripts.
<script src="https://www.gstatic.com/firebasejs/5.0.2/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.0.2/firebase-database.js"></script>

How do I unbundle a bundle with gulp MVC 6 for debugging?

I have a rather large Angular app that has a lot of javascript files dispersed in a tree in my project. It's an MVC 5 project that I've converted with these instructions to MVC 6 to use Browserify. Everything seems to work great, except that I need to not use a bundle in my development builds and instead include every script file separately. These articles show mildly different ways to replace a bundle with static markup depending on an environment variable, but I'd have to specify every file individually for the debug version. Is there some way to dynamically specify which files to include?
You should use environment tag helpers.
The environment helpers allows us to conditionally render scripts based on the environment. (Minified-Bundled version vs All Un minified version)
<environment names="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/js/ScriptForPage1.js"></script>
<script src="~/js/SomeOtherScript.js"></script>
</environment>
<environment names="Staging,Production">
<script src="//ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery">
</script>
<script src="~/js/CombinedVersionOfAllScripts.min.js" asp-file-version="true"></script>
</environment>
Make sure that you have invoked the UseStaticFiles() method inside the Configure() method(inside Startup.cs). This extension method enables static file serving including js files,css files etc..
Take a look at this post to understand how to minify your js file using gulp
If have 100+ js files and you do not wish to add one script tag for each of your script files, you can consider bundling all the files into one single file and use that.
To do this, add a new gulp task to your gulpfile.js
paths.bundledJsDest = paths.webroot + "js/bundledSingleFile.js";
gulp.task("bundleAllScriptsToOne", function () {
gulp.src([paths.js, "!" + paths.minJs, "!" + paths.bundledJsDest])
.pipe(concat(paths.bundledJsDest))
.pipe(gulp.dest("."));
});
Now open the Task runner (View->Other Windows->Task Runner Explorer), Right click on this new task we created(bundleAllScriptsToOne) and select Run.
This will genearate a new js file called bundledSingleFile.js. The content of this will be script content from all other script files inside the js folder(except the minified ones). You can include this single file in your layout inside Development environment. You can use the minified one(generated by another gulp task) in your Production environment.
<environment names="Development">
<script src="~/js/bundledSingleFile.js"></script>
</environment>
<environment names="Staging,Production">
<script src="~/js/yourSite.min.js" asp-file-version="true"></script>
</environment>
If you wish to get all the scripts from another folder(or a sub folder), just update the path you pass to the gulp.src()
If you do not wish to manually run this gulp task every time, You may select Bindings -> Before build so that this will automatically run that particular gulp task every time you build your project.

Signalr TypeError: chat is undefined issue

i am trying to learning this signalr library. so i just install signalr related all dependency from Nuget.
when i run my code then i am getting error called TypeError: chat is undefined
this all js library are included.
<script src="Scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<!--Reference the SignalR library. -->
<script src="/Scripts/jquery.signalR-1.0.1.js" type="text/javascript"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src='<%= ResolveClientUrl("~/signalr/hubs") %>' type="text/javascript" ></script>
when this line execute then i am getting the above error
chat.client.broadcastMessage = function (name, message)
i follow the full instruction from this url to create a sample project. the url is
http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
can anyone tell me how to fix this error. thanks
In your server side Application Start make sure that you are calling RouteTable.Routes.MapHubs(). #7 in the tutorial

Aptana3 Code Assist with the Google Maps API v3

I'm trying to enable Code Assist for Google Maps API v3 in Aptana3.
It does not seem to work.
I followed the instructions from this page:
Drop the VSDoc files into your Web Project.
V3 Maps API: gmapvsdoc.codeplex.com
As instructed, I got the zip file from Google Maps API 3 Visual Studio Intellisense Helper
I extracted google-maps-3-vs-1-0.js and google-maps-3-vs-1-0-vsdoc.js in a scripts folder in my project (a PHP project).
This is how I included the API in my html file:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="scripts/google-maps-3-vs-1-0.js"></script>
The API works fine. I can access all its features.
Yet, when I type 'map.' (after initializing the variable with var map = new google.maps.Map(...)) Aptana has no proposals to assist me with.
Is Aptana3 not compatible with Google Maps API v3?
Have I done something wrong?
Could it be because I'm also using the JQuery Code Assist?

Object undefined error at var chat = $.connection.chat; while using SignalR

I tried installing SignalR library to create a sample chat application. I believe I have followed all steps given in documentation. I am not sure what could be a reason of failing.
It is failing when it creates a chat object. I am using VS2010 and I downloaded SignalR using VS2010 package download utility.
Is anyone had an issue with this?
Thanks,
Samir
Thanks Hurricanepkt for helping me out.
Yes, I did get all signalR via nuget, using VS2010 'Add Library Package' dialog box. I was getting object undefined error, at var chat = $.connection.chat;
I just made it work but it was ASP.NET Web Application Project. I could not make it work with ASP.NET Website project. I don't know why.
I believe it due to dynamic dll creation in Website Project vs. fixed dll in ASP.NET Web Application Project.
Have you encounter such issue?
What's the name of your hub? If you've changed it to something other than "Chat" then it won't work. I had the same issue because I changed mine to:
public class ChatHub : Hub
{
public void Send(string message)
{
Clients.addMessage(message);
}
}
Within the Javascript this:
var chat = $.connection.chat;
needed to change to
var chat = $.connection.chatHub;
I was frustrated because of the same problem.
It works in Web Project but in Web site it's not. So I checked the script file which is dynamically created.
Left: Web Project - Right: Web Site (http://i.imgur.com/X1XrT.jpg)
As you can see in web site it is not creating "chat" object so it says undefined.
After reading your sentences about dynamic dll creation, I put my code behind file in a seperate .cs file and I put that cs file in App_Code folder. I tried and bam, it worked. Checked the dynamic script file:
(http://i.imgur.com/CSInO.jpg)
I don't know much about the technical issue in here, but putting your code in a seperete Class file which is located in App_Code folder resolves the issue..
Have a nice day
Reading your problem, I ran into this same issue when using it in an MVC3 application.
Can you post your script reference? I can almost bet that you're using something like this, a static location string:
"../script/signalr.min.js"
When you should be using (or the WebForms equivalent of relative paths):
<!-- Used for SignalR -->
<script src="#Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.signalR.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/signalr/hubs")" type="text/javascript"></script>
I ran into this same exact issue today and David Fowler himself helped me.
In any case, read my blog post and follow it to a T and you'll have a working version with MVC3.
http://sergiotapia.com/2011/09/signalr-with-mvc3-chat-app-build-asynchronous-real-time-persistant-connection-websites/
Well I suspect that we have followed the same documentation/tutorial - tutorial for signalR 1.1.3 using ASP.net Web Application(Latest signalR version for .NET framework 4 - higher versions of signalR is not supported).
If you are like me, you should also run signalR in web application without any problem, and then proceed in implementing the same for the website. In my case, it is all about referencing my JavaScript files, thanks to Lars Höppner.
These lines
<script src="/Scripts/jquery-1.6.4.min.js" ></script>
<script src="/Scripts/jquery.signalR-1.1.3.js"></script>
<script src="/signalr/hubs"></script>
should only be
<script src="Scripts/jquery-1.6.4.min.js" ></script>
<script src="Scripts/jquery.signalR-1.1.3.js"></script>
<script src="signalr/hubs"></script>

Resources