With here maps there is possibility to change language for both layers and controls. Here is example from here maps. http://jsfiddle.net/gh/get/jquery/2.1.0/heremaps/jsfiddle-github/tree/master/map-multi-language-support . The problem I'm having with this example is that it changes control translation with this line of code:
var ui = H.ui.UI.createDefault(map, defaultLayers, 'zh-CN');.
It's good for initial language, but what if I have a button that would change language, would I need to recreate this ui variable every time I would want to change control language? Is there no method like H.ui.UI.setLocale or something(I tried to search but couldn't find).
We suggest removing the old instance of the UI element and then creating the new one with the desired language.
H.ui.UI class offers the dispose() method to remove the object. To learn more, please refer to the following online doc.
https://developer.here.com/documentation/maps/3.1.26.0/api_reference/H.ui.UI.html#dispose
Here are the sample codes, and hopefully, it helps.
var ui,defaultLayers,platform,map;
function switchMapLanguageToCN(){
switchLanguage("zh-CN")
}
function switchMapLanguageToEN(){
switchLanguage("en-US")
}
function switchLanguage(language){
if(typeof(ui) == "object"){
ui.dispose();
}
ui = H.ui.UI.createDefault(map, defaultLayers, language);
}
Related
This is an instance of Rappid Toolkit which uses jointJS for building visual tools as for web development. http://i.stack.imgur.com/6XSis.png
In this toolkit you can make a graph which can become a website.
My problem is the following one:
In every single element of this graph there is a box below it with:x,y,width,height,angle.
I want to change this information of this boxcontent and to display some info from this element but the code in which I have to add my snippet is the following(var Halo is the var for my element in the graph):
var halo = new joint.ui.Halo({
cellView: cellView,
boxContent: function(cellView) {
return"Here I want to display my box content info instead of x,y,width,height, angle";
}
}).render();
If I try to add my code inside it to access in JSON format my current element info my full code is:
var halo = new joint.ui.Halo({
cellView: cellView,
boxContent: function(cellView) {
// Drawing
var selectedObjectDataText = JSON.stringify(this.cellView.toJSON());
var selectedObjectDataJSON = JSON.parse(selectedObjectDataText);
return(selectedObjectDataJSON[0].wi_name);
}
}).render();
where wi_name is the name of my element but in the first line I can't access the specific element of my graph.
var selectedObjectDataText = JSON.stringify(this.cellView.toJSON());
Is there any global way to access my halo(my graph element) since this.cellView.toJSON() doesn't work?
I tried this.model.toJSON() this.cellView.model.toJSON() etc with no result
Note that JointJS links and elements are Backbone Models (linkView and elementView are Backbone Views).
To get the current value of an attribute use get() method.
boxContent: function(cellView) {
return cellView.model.get('wi_name');
}
Alternatively you can use prop(), that can return also nested properties of a model.
boxContent: function(cellView) {
return cellView.model.prop('wi_name');
}
It worked for var selectedObjectDataText = JSON.stringify(cellView.model.toJSON());
Thank you all for your support.
So I'm creating an app in which there's a UIWebView which shows a list of locations. My goal is to make it possible that once the user clicks one of the locations, my app can get the lat and longitude of the spot and therefore launch an integrated Navigation SDK.
My point is how do I get and pass the location values from the webView to my Objective-C code?
I'm using WebViewJavascriptBridge.
You can set the hyperlinks on the locations.
For example: <a href="location1,latitude=21,longitude=22" id="location1" >Location1</a>
Once this Location1 gets clicked, - webView:shouldStartLoadWithRequest:navigationType: method will be called, and you can extract value of latitude and longitude
WebViewJavascriptBridge have no maintain for a long time.
Maybe you should change to use this library.
SDBridgeOC
self.bridge.consolePipeBlock = ^(id _Nonnull water) {
NSLog(#"Next line is javascript console.log------>>>>");
NSLog(#"%#",water);
};
This can easy to get javascript console.log.
Also have Swift language Version.
SDBridgeSwift
bridge.consolePipeClosure = { water in
guard let jsConsoleLog = water else {
print("Javascript console.log give native is nil!")
return
}
print("Next line is Javascript console.log----->>>>>>>")
print(jsConsoleLog)
}
Also have h5 demo for you.
How would I use the getLogo function to display the Spil Logo on inside my HTML5 game?
Here's the link to their docs
http://developers.spilgames.com/wiki/Developer_Platform_-_Learning_center_-_HTML5_API_getLogo
I don't understand if it's meant to display their logo automatically, or if I'm meant to do something with the object data it returns, and if so how would use it?
We provide basically only two properties: a URL to the image and a function. What you need to do within your game is attach the Javascript link to the image.
A typical logo implementation looks like this for a DOM implementation. But of course this depends on the nature of your game and if you're using a framework:
GameAPI.loadAPI(function (apiInstance) {
// getLogo example
var logoData = apiInstance.Branding.getLogo();
// Create a DOM element and use the values returned by the call
var logo = document.createElement('img');
logo.src = logoData.image;
logo.addEventListener('click', logoData.action);
document.body.appendChild(logo);
});
You can find a tutorial complete with jsFiddle example here: http://developers.spilgames.com/wiki/Developer_Platform_-_Learning_center_-_HTML5_API_-_(Tutorial)_Get_logo
If you run into technical issues, you can always get in touch with the Tech Support team using the "Support" tab on this page: http://developers.spilgames.com/contact
Hopefully this answers your question!
Building a single page / fat client application and I'm wondering what the best practice is for including and tracking using http://piwik.org/
I'd like to use Piwik in a way that is architecturally sound and replacable with a different library in the future.
It seems that there are two basic options for tracking with Piwik:
Fill up a global _paq array with commands, then load the script (it's unclear to me how to record future "page" views or change variables though)
Get and use var myTracker = Piwik.getTracker()
_paq approach:
myApp.loadAnalytics = function() { /* dynamically insert piwik.php script */ }
myApp.track = function(pageName) {
window._paq = window._paq || [];
_paq.push(['setDocumentTitle', pageName]);
_paq.push(["trackPageView"]);
}
myApp.loadAnalytics()
// Then, anywhere in the application, and as many times as I want (I hope :)
myApp.track('reports/eastWing') // Track a "page" change, lightbox event, or anything else
.getTracker() approach:
myApp.loadAnalytics = function() { /* dynamically insert piwik.php script */ }
myApp.track = function(pageName) {
myApp.tracker = myApp.tracker || Piwik.getTracker('https://mysite.com', 1);
myApp.tracker.trackPageView(pageName);
}
myApp.loadAnalytics()
// Then, anywhere in the application, and as many times as I want (I hope :)
myApp.track('reports/eastWing') // Track a "page" change, lightbox event, or anything else
Are these approaches functionally identical? Is one preferred over another for a single page app?
To have the tracking library used (eg. piwik) completely independent from your application, you would need to write a small class that will proxy the functions to the Piwik tracker. Later if you change from Piwik to XYZ you can simply update this proxy class rather than updating multiple files that do some tracking.
The Async code is a must for your app (for example a call to any 'track*' method will send the request)
The full solution using .getTracker looks like this:
https://gist.github.com/SimplGy/5349360
Still not sure if it would be better to use the _paq array instead.
There may be a better way of doing this...so please suggest if there is.
I've got some javascript that calls an AIR function. This AIR functions creates a new HTML element and adds it to the "Stage" like so:
// guid is the ID given to the new window (HTML element) by javascript
private function createNewWindow(guid:String):void {
var frame:HTML = new HTML();
frame.id = guid;
addElement(frame);
}
Now I've also got a function that sets the location of the frame based on its id...this is where I'm struggling.
// set the location of the window referenced by it's id (guid)
private function setLocation(guid:String, location:String):void {
// psuedocode. Obviously it won't work.
stage.getById(guid).location = location;
}
So, how do I "get" my HTML element based on its ID?
Short answer, you don't. This isn't javascript, this is a OO language and as such, you need to change your thought process. What are you trying to do? Create several html windows within an air application? If you want to have an id based approach, you're going to need to store the id and the pointer to the component in an data structure (like a dictionary).
private var _components:Dictionary = new Dictionary();
this._components['someId'] = someComponent;
And from there you can add a function that just saves/returns the components. I'm not entirely sure what's your approach and what you're trying to accomplish, but my gut tells me you're not doing something right.