HERE map is blank in outsystems - here-api

I am trying to implement a Web Application using HERE Maps on the tool OutSystems.
On The application I have a web block that contains a Container (where the map will be drawn), an expression (with Escape Content as 'no', and the scripts below as value so it may be inserted on the html of the page) and a button that try to run the same script again (just for test measures and see if it was a problem of the script executing before the div was ready).
<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>
<script type ="text/javascript">
// Initialize the platform object:
var platform = new H.service.Platform({
'app_id': '{APP_KEY}',
'app_code': '{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.Id + "'),
maptypes.normal.map,
);
map.setBaseLayer(maptypes.satellite.traffic);
</script>
(MapContainer.Id returns the id of the container as in the HTML, since the tool automatically creates the id of the elements)
On the following image:
you can see the structure I am using on the web block:
The problem is: this code I am using isn't working on the OutSystems, leaving a blank screen webpage:
But the same code on a HTML file works fine. No errors are listed on the browser console and upon inspecting the code with development tools (Chrome) I noticed that the canvas was being created but has height = 0 (editing this value changes nothing).
If someone knows a way to work around these problems I would love to hear about. Thanks for your attention.

It seems like the styles of the map container have not been computed and rendered, when the map is instantiated. Therefore, the map is there but has a height of zero pixels. This is probably related to how the view is created by Outsystems.
Requesting the browser to resize the map at the next animation frame should help:
requestAnimationFrame( () => map.getViewPort().resize() );

Related

How to debug JS code with breakpoints if the code is inserted via GTM

In GTM I have added a custom html:
<!--Start of Tawk.to Script-->
<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
///////////////
// Chat started
function notifyFacebookAboutAboutChatStarted(content_category){
fbq('track', 'Contact', {how: "chat_started", content_category: content_category}); // Breakpoint
}
function notifyAllSystemsAboutChatStarted(content_category){
notifyFacebookAboutAboutChatStarted(content_category);
}
//////////////
// Chat form submit
function notifyFacebookAboutChatFormSubmit($element, content_category){
fbq('track', 'Lead', {content_category: content_category});
}
function notifyAllSystemsAboutChatFormSubmit(content_category){
notifyFacebookAboutChatFormSubmit($element=$element, content_category=content_category);
}
// Event listeners
Tawk_API.onChatStarted = function(data){notifyAllSystemsAboutChatStarted(content_category=content_category);};
Tawk_API.onOfflineSubmit = function(data){notifyAllSystemsAboutChatFormSubmit(content_category=content_category);};
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/6131ae1fd6e7610a49b36846/1fel10b81';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
Please, don't pay much attention to this code because the question is not about it. It is just a piece of code to show what I usually put into GTM containers rather than to be analysed.
And I want to debug this JavaScript in Chrome. In other words I'd like to be able to stop at the breakpoint (marked in the code as // Breakpoint).
I mean in Chrome DevTools panel. Like this:
But this is some code inserted without GTM. I open Sources tab and try to find my JavaScript addeb via GTM there.
Tawk is an online chat I have added via GTM. And it is definitely there as the icon of Tawk has appeared on the site.
So, I'd like to debug my JavaScript code by stopping at breakpoints. But I fail to find where to put those breakpoints. Whether it is possible at all? Or should I debug the code first outside GTM and then insert it inside GTM? But this is clumsy: if users report an error, I'd like to first analyse the problem without changing anything.
So, the question: how to debug JS code with breakpoints if the code is inserted via GTM?
If you put this in a Custom HTML tag it will be inserted as string and run through eval at runtime, so I doubt the debugger will even notice this is JavaScript.
Basically your alternatives are
put it in an external file, which kind of defeats the purpose of GTM
rewrite the code as a custom template (which will require a lot of effort, but means that at least you can write tests inside GTM to make sure your code runs. However custom template code is transpiled, so it might be hard to identify in the debugger)
I think your best choice is actually to test outside GTM first (which I admit is not a real test, since this means you do not test the configuration that will run in the end).

plotly_click does not trigger

Following this example https://community.plot.ly/t/hyperlink-to-markers-on-map/17858/6, I am trying to make points my scatter plot clickable (specifically, open a webpage when clicked). How do I get the click event to trigger when a data point is clicked?
This is a python turbogears app, with the plotly_click event happening in js. I'm using plotly.js v1.44.1.. Like in the example, I first create the fig:
plotlyHtml = webhelpers2.html.literal(plotly.offline.plot(fig, include_plotlyjs=True, output_type='div'))
Then I find a div in the figure:
res = re.search('<div id="([^"]*)"', plotlyHtml)
div_id = res.groups()[0]
Then I build a js callback to be inserted into a script tag in the template, as in the example. Here's the script tag injected into the html:
<script type="text/javascript">
var plot_element = document.getElementById('3f56277f-e84b-4b68-ae85-91d3cd62d01c');
console.log('callback js has been added to page. did we get plot_element?');
console.log(plot_element);
plot_element.on('plotly_click', function(data){
console.log('Im inside the plotly_click!!');
console.log(data);
var point = data.points[0];
if (point) {
console.log(point.customdata);
window.open(point.customdata);
}
})
</script>
The first two console.log statements before the event listener print when the page is rendered, meaning the js is successfully injected into the html. Particularly, plot_element is a div with class="plotly-graph-div js-plotly-plot". However clicking points on my scatterplot never results in anything, no errors, events, or console log statements. I at least expect the console log statements in the if to occur. Am I selecting the wrong div id?
The issue was in my layout. I had 'clickmode': 'select', which screwed things up. Removing that enabled events to fire as expected.

Windows 8 ListView Control not showing up when placed inside a CSS Grid

I am following along the Microsoft tutorial "Quickstart: Adding a ListView" (Can't post link because of spam prevention) for Windows 8 app development and I am attempting to simply show the raw data from my array in ListView format. I have slightly modified the tutorial so that I am using CSS Grids to structure the page (as Microsoft recommends, I believe). The problem I am having is that when the ListView is situated outside of a Grid, it show's and display's perfectly, but, when located inside a CSS Grid, will not show up on my app. I have very limited knowledge in both CSS Grids and the new Windows 8 platforms so I am sure it is a simple mistake that I have made. Below is my CSS and HTML code, all the Javascript should be identical to that used in the Microsoft tutorial...
http://pastebin.com/cgV5PHnf - HTML
http://pastebin.com/HvVPuhkG - CSS
With your HTML and CSS, verbatim, data is showing fine for me. This is my tempData.js:
(function () {
"use strict";
var items = new WinJS.Binding.List();
items.push({ value1: "foo", value2: "bar" });
items.push({ value1: "foo2", value2: "bar2" });
WinJS.Namespace.define("TempData", {
itemList: items.dataSource
});
})();
Note, I included dataSource in the definition of itemList, since your data-win-options did NOT include it (the Quickstart pulls that into the attribute). Without it though you'd be getting a pretty noticeable exception, so suspect you're doing the same in your TempData definition.
One thing you could try is DOM Explorer in Visual Studio or open the application in Blend and use Interactive Mode to see if there is some sort of unexpected CSS class overriding.

Disable cache in google chrome (Mac) for developing in flex/flash

What is the best way to go about disabling the cache in google chrome for mac, so that when I am developing a flash application, it will bring in the new movie every time?
Please advise, I can't figure out how to ensure the version of the .swf I am looking at is the most recent version.
One solution might be to get the flex compiler to append a timestamp to the .swf filenames, is this possible?
Thanks!
Go to the 'View' menu, open Developer Tools. In the bottom right corner of the Developer Tools is a gear icon. Click it, then check the 'Disable Cache' checkbox.
In your embed code where ever you the swf file you have to put a random number or a time stamp of some sort on the query. Whenever there is a query string that changes the browser will not cache the page.
"MySWFName.swf?t=" + new Date().getTime();
Best method would be to embed your SWF using SWFObject with this code.
In the html body tag do this.
<body onLoad="loaded()" onunload"doUnload( )">
<div id="replaceMe">Loading content.</div>
</body>
and for the javascript do this ( obviously changing the stuff wrapped in { } to your needs
<script type="text/javascript" src="swfobject.js">
<script type="text/javascript">
function loaded() {
var flashvars={}, params={}, attributes={}, tmp, version, width, height, container, flashObj;
flashvars.userName = "testvar";
params.menu = "true";
params.quality = "high";
params.bgcolor = "${bgcolor}";
params.allowscriptaccess = "always";
params.allownetworking = "all";
attributes.id = "${application}";
attributes.name = "${application}";
attributes.align = "middle";
attributes.allowscriptaccess = "always";
attributes.allownetworking = "all";
tmp = "expressInstall.swf";
version = "${version_major}.${version_minor}.${version_revision}";
width = "${width}";
height = "${height}";
container = "replaceMe";
flashObj = "${swf}.swf?t=" + new Date().getTime();
swfobject.embedSWF(flashObj, container, width, height, version, tmp, flashvars, params, attributes);
}
</script>
Don't forget to add a copy of SWFobject
You will never have caching issues again
EDIT:
BTW if you replace your code in your html.template.html file with this code it will generate the values for you. :)
Personally, I would never do that. Caching is there for a reason and shouldn't be disabled when you're running it locally. In my experience, the best way to do it is have a 'version' (normally a static properly in a Class) number increment every time you build (by using Ant or Maven; even better if you have an automation engine to do it too) which then attached that version number as a url parameter for the flash movie like Movie.swf?version=1.31 in the html.

Want to show Busy Loading message with percentage download when form will load using JQuery

suppose my page content is huge so in my asp.net application i want to show busy icon with percentage downloading the content in client side. i saw many flash and sliver light site that they show busy icon and also they show percentage that means how much content has been loading in client machine. how could i achieve this using JQuery and when page content has been downloaded in client machine the busy icon goes out and actual page content will display.
please me with sample code to achieve it. thanks
You could have a placeholder image, and when the image you want is loaded, you could replace the placeholder with the new source
var img = new Image();
img.src= "largerImage.png";
img.onload = function() { oldImage.src = img.src; };
This could be taken a step further, and the code could be added to the image itself
<img src="http://www.codedigest.com/img/loading.gif"
onload="var t = this; var img = new Image(); img.src ='http://hardgeek.org/wp-content/uploads/2010/07/firefox-logo-1024x969.jpg'; img.onload = function() { t.src = img.src }" />
Which could also be taken a step further, as you might not always have the ability to apply the onload directly like this, just a suggestion.
I would recommend something like Uploadify. It does require a flash plugin. This is by far the easiest way.
http://www.uploadify.com/
Here is an example (ASP.NET MVC):
http://blog.bobcravens.com/2010/02/upload-files-with-progress-using-uploadify/
[Update] If you are trying to lazy load images, then use the jquery lazyload plugin. This only loads images that are in the current viewing area. As you scroll down, it fetches the next images. I use it on my blog page.
http://blog.bobcravens.com
View source and you will see (around line 13) a script that sets lazy loading on all post images.
Bob

Resources