I've become the editor of a website that i didn't create. There is a map feature on one of the webpages and i've been asked to alter how the map initially loads on the webpage.
I don't know if the javascript that i'm looking at is original or whether it's some stock code provided by someone like Google. Anyhow, some of the code that i'm looking at looks like this....
var gridChoice = "";
if (osbounds) gridChoice = osbounds.gridStyle;
var gridUse = QueryString("g");
if (gridUse) gridChoice = gridUse;
switch (gridChoice)
....
....
....
In the comments, it states that using g in the QueryString should override what ever the code does.
It selects the type of grid displayed on the map. There is another selection that is identical to this that selects the type of map shown (Eg. Google road, Terrain, Hybrid, etc). The code used to select the type of map uses m in the QueryString. With the same comment - that m should override.
I have no idea how QueryString works or or what it does. I've tried to Google it but i can only find people asking for advice on places like this. I can't seem to find any documentation that describes the function, and how it works. I know there will be something out there but my Google-foo is weak on this one.
May someone describe to me what it does? Or link a source that exlains it well please?
Thanks.
It uses location.search (w3schools.com/jsref/prop_loc_search.asp) So it turns out that querystring is the name for the part of the URL that represents the parameters of a webpage. In this application, the parameters would be...GPS coordinates, type of map, type of grid, etc. The input in to the function QueryString selects the parameter to be looked at. It then parses the URL for that parameter and then returns the appropriate response.
Related
how are you doing? Hope you're fine.
My name is Thiago. I'm a brazilian enterpreneur that runs a Marketing Agency.
It's been a very long while since I'm in need of help with a very specific matter.
I'll try to explain it here the clearest and easiest as possible.
I'd like to ask sorry for any bad english in advanced. =D
So, the thing is, conversion is a big game changing, whatever it's on Facebook or Google.
Setting up conversions it self isn't that hard, when you have an ecommerce platform that comes with a data layer already setup.
Most of my clients doesn't have an ecommerce with a Data Layer.
I was following the Measure School youtube tutorial to install Active Campaign Tracking, and by doing this I add a template in my Google Tag Manager that almost soved the problem, but the code is note quite working.
And that's where I need help. =D (sorry for the long story kkk)
The Custom Variable "Purchase Function" code is this:
function() {
var price = str.split("Adicionar R$ ", "{{Click Text}}",[1])
return price
}
It's returning unedefined.
I'll add some prints showing the whole process with the most details as possible.
0 - Adding Product to Cart
1 - Product Price in Button Click Text
2 - Purchase Price Not Working
3 - GTM Price Function
I really need help making this Custom Variable "Purchase Price" works.
Thanks a lot.
You are using the split function wrong (for starters, you apply it to a variable str which is undefined. Also, wrong number of parameters and wrong parameters).
Look at the documentation for split here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split
Your function should look something like this:
function() {
// splits Click Text by whitespace an returns an array
var parts = {{Click Text}}.split(" ");
// pop removes the last part from the array and returns it
// numerical index might not work if there is more than one whitespace in the click text
price = parts.pop();
return price;
}
So, I really love this example from Jake Zieve shown here: https://bl.ocks.org/jjzieve/a743242f46321491a950
Basically, on search for a term, the path to that node is highlighted. I would like to accomplish something similar but with the following caveats:
I would like to stay in D3 v4.
I'm concerned about cases where the path doesn't clear out on next node pick OR what happens when there are two nodes of the same
name (I would ideally like to highlight all paths)
I would like to AVOID using JQuery
Given a set search term (assume you're already getting the string from somewhere) I know I need to make use of the following lines specifically (you can see my stream of consciousness in the comments) but I'm just not quite sure where to start.
// Returns array of link objects between nodes.
var links1 = root.descendants().slice(1); //slice to get rid of company.
console.log(links1); //okay, this one is nice because it gives a depth number, this describes the actual link info, including the value, which I am setting link width on.
var links2 = root.links(); // to get objects with source and target properties. From here, I can pull in the parent name from a selected target, then iterate again back up until I get to source. Problem: what if I have TWO of the same named nodes???
console.log(links2);
Thoughts on this? I'll keep trying on my own, but I keep hitting roadblocks. My code can be found here: https://jsfiddle.net/KateJean/7o3suadx/
[UPDATE]
I was able to add a filter to the links2 to call back a specific entry. See
For example:
var searchTerm = "UX Designer"
var match = links2.filter(el => el.target.data.name === searchTerm); //full entry
console.log(match);
This single entry gives me all associated info, including the full list of all points back up to "COMPANY"
So, I can GET the data. I think the best way to accomplish what I want is to somehow add a class to each of these elements and then style on that "active" class.
Thank you!
The Google Maps Places Autocomplete does not work as expected anymore.
https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete
When inserting a search string in the map (for example "ZKM"), it will give some recommendations in the drop down list. In this case it will be "ZKM | Zentrum für Kunst und Medientechnologie Karlsruhe, Lorenzstraße, Karlsruhe, Deutschland". When clicking this item, no marker will be placed on the map!
But when searching for "Karlsruhe" and clicking the first search result "Karlsruhe, Deutschland" the marker is placed correctly.
In the code a function called getPlace() ist called.
var place = autocomplete.getPlace();
The place should contain an object "geometry", but it does not.
Is there any workaround for this problem?
Please be sure you set 'geometry' field in autocomplete like this:
autocomplete.setFields(['address_component', 'geometry']);
Take a look at the beginning of the function:
if (!place.geometry) {
return;
}
A PlaceResult may, but must not have a geometry-property.
To clarify how the autocomplete works:
when you type something, the API will request the predictions(to populate the dropdown). Only when you select a place from the dropdown it requests the data(including the geometry) for the particular place.
Obviously there are inconsistencies of the used data(the API shouldn't suggest a place where no informations are accessible), but that's how it is, it may happen that you get a prediction without a place.
Workaround: AFAIK no
Looks like it has been fixed by Google :)
Yes, the place contains an object "geometry".
To find this, you should use this :
autocomplete.getPlace().geometry.location.lat() //for the latitude
autocomplete.getPlace().geometry.location.lng() //for the longitude
Please don’t answer this if you don’t take the time to understand my question or have a reasonable answer. I have got a few answers that is far on the side and I think I explain my problem very clear. Shall this problem drive me nuts or is there somebody out there with a straight and clear answer on Titanium.App.Properties?
I have a login form that stores the username in one:
Titanium.App.Properties.setString("userName",e.value);
and the password in another:
Titanium.App.Properties.setString("passWord",e.value);
The forms TextFields holds these values(after a store) even if I close the window, shut down and restarts the app. This because of the App.Properties.getString("value"); I suppose….?!
But when I copy the hole form with its App.Properties.getString("value"); to another window, the TextFields are empty and contains no value at all. I understand that the Properties string must be there some where in App.Properties, but how can grab it and use it another place in the app?
My question is: How to get the value from my
var userNameValue = Titanium.App.Properties.getString("userNameValue");
to be available in another window or for the hole app(global)? How can I grab it and make use of it a another place in the app? I don’t see a good reason to make these, only separate words, into objects(JSON) since the userName only contains a e-mail address and the passWord consist only of continuing letters or numbers. But if you mean I have too, -how do I set this from my TextField and get it in another TextField somewhere else in my app. I have not had any luck so far. I hope you can help me out and I can keep sane.
Titanium.App.Properties.getString("userNameValue");
This is globally Available, any Propertie of the Titanium Object is accessible in each file.
but if for some reason this doesnt work for you and you want to set a global variable,
you could do the following:
Create a file called myGlobals.js //or anything else,
//Put this in there e.g
var myProperties = {};
in any file you want to use it write in the first line
Ti.include('myGlobals.js');
Then you can make a propertie global available, for example write this in app.js somewhere where the app initializes
myProperties.Username = Titanium.App.Properties.getString("userName");
Then you can get the value in each file by accesing the propertie
myProperties.Username
//of course the Propertie has to be set before you can get them
( Titanium.App.Properties.setString("userName",e.value); ) //like you do it
But, Titanium.App.Properties.getString("userName");
should be avilable from any file anyway, (but you can give this a try although i dont think its nice to do it like this)
i had a similar problem where this didnt get any value from a propertie set in the ios settings as default value.
I had to go to the settings and manually change or edit the default value and then after a restart
Titanium.App.Properties.getString("userName");
returned the value as it should,
i hope this helps you =)
Answer to the Comment
I'm glad i could help you =)
Yes you can Use an focus EventHandler like this :
textfield.addEventListener("focus",function(){
textfield.value = "Test";
});
Beside that , are you using the identical Textfield for both windows ? like
var Textfield = Ti.Ui.createTextField({...});
and add it to 2 different windows ?
win1.add(Textfield);
win2.add(Textfield);
That led for me to Problems with labels in TableViewRows, using an identical Row 2 times in the TableView
The Text displayed only on 1 Label, sometimes it switched the Labels
I think you can't add one and the same titanium object to more then one other object
Maybe that could be the culprit,
dunno just an idea =)
I am having a Search text-box for which I have to implement a search suggestion(like google search) kind of feature.
for example, if I type "abc" in the search box, I will get suggestions like
abcdef
xyzabcxyz
here each of these unique suggestion represents a jsp page whose url can be "hard-coded" in a java-script array. so when I click any suggested value, the webpage at the corresponding link is displayed.
For this, can you suggest me any efficient methods of implementing this.
This must be in pure javascript, no third-party libs like jquery,etc., can be used
Thanks in advance.
Assuming your data is in an associative JS array similar to this
var locationArray = {
'searchValue1' : 'url1',
'searchValue2' : 'url2',
...
};
and your search input field has a function associated to onkeyup
<input type="text" onkeyup="UpdateSuggestions(this);">
then the rest is simple JavaScript string functions.