Geocomplete cities without country - geolocation

i am using Google Geocomplete to auto suggest my visitors when typing in cities.
It works well, but however it suggests country next to the city. For example, if i start to type Barce, it will suggest Barcelona, Spain. I need only Barcelona, without the country.
Does somebody know how to tell Geocomplete to show only cities without the country?
Thanks

I too faced the same problem
Here is the my solution, I hope this will help you.
1) Declare the option variable and types property.
for example,
var option = { types: ['(cities)'] };
and,
$("#input").geocomplete(option)
.geocomplete()
and then,
.bind("geocode:result", function(event, reuslt) {
console.log(result.name);
})
result.name is only show city name.
so, .bind inner function block add the this line.
$("#input").val(result.name);

Related

Telerik Kendo Chart : How to bind the chart to a string type

I've been stuggling for a moment and I'm unable to find anything related to that. I'm a total newbie with Kendo, and sadly I was not able to find anything that could help my question, documentation, forums and all of that : they haven't helped at all.
Situation :
I have a viewmodel in my ASP .NET app. I'm trying to make a chart out of one of the proripeties called "Type". This propriety represent a type of data - let's say fruits, like "Banana", "Apple" etc.
This type contains only and only one type at the time. It cannot contain something like "Apple and bananas". It's always a string, too.
This proriety is part of a larger model. But I'm only interested in this one.
Now, what I like to do :
I'd like to make a chart, using Kendo, from that propriety.
That means, I have to bind my chart to my model, and then, it will be able to know how many time some of those Types were used.
Like, example, If I have three objects :
Name : "Mjuzl"
Type : "Potato"
Name : "Uijqf"
Type : "Apple"
Name : "Zjli"
Type : Potato"
I'd like my char to count that my model used the type Potato twice, and the type Apple once.
I know how to get my datasource that contain all of the objects that use my model. (I have already used Kendo Grid just before but it's so simplier tbh) My issue right now, is that I have no idea - and I wasnt' able to find any - how to actually display what I want in my chart. I say it again, they are strings. I know how to get my datasource. I don't know how to actually show what I want to show. (Should I use columns ? sections ? I don't know)
Do I need to build a JSON from my controller that will ask the database to count ? Does Kendo is able to do it by it's own ? I'm so lost, I have no idea what Kendo is actually waiting for to make my chart working. The documentation isn't helping at all. I've been researching for a while, I haven't found anything that describes the exact same problem. And I've been searching for days.
Very badly drawn image I've done to put a picture on my problem :
I don't ask to do it for me, I ask for a path. A way to do it.
Thanks.
One way would be to create a view model specifically for your chart, and you can populate that view model based on your data.
Roughly (untested code - just to give you an idea), something like this:
public class MyChartViewModel
{
public int TypeCount { get; set; }
public string TypeName { get; set; }
}
and then in your read method for the chart where you are populating MyChartViewModel:
var myExistingDataModel = howeverYouGetYourDataHere;
var model = new MyChartViewModel();
var distinctTypes = myExistingDataModel.Select(x => x.Type).Distinct().ToList();
foreach (var distinctType in distinctTypes)
{
model.TypeCount = myExistingDataModel.Count(x => x.Type == distinctType);
model.TypeName = distinctType;
}
Finally ! I managed to do it !
For any future reference :
Based on G_P's answer, I used a LINQ request to count all of my types : Linq distinct - Count (don't forget to remove the .District() otherwise I won't work !)
Then, I did some debuging to see if I actually return my data, because nothing was showing in the chart. It did return my data and the right number.
The issue for this case was, I use
return Json(types.ToDataSourceResult(request, ModelState));
To return my data to my chart. But ! there is a little thing to know about Chart, they don't work like grids. You have to use a specific setup for showing your data if you use ToDataSourceResult : https://docs.telerik.com/aspnet-mvc/html-helpers/charts/data-binding (See "3) (Optional) Configure a Custom DataSource."), just change the call to your controller, and voilĂ  ! It worked !

Find an specific item in the master list of an split app by using oModel.createKey

I'm using a split app layout for editing and creating new employees. Therefore I do have a button "Add employee". After submitChanges is done, I want to find this new employee in the master list and select it.
I am using an event-bus for the communication between detail-controller and master-controller.
fnAfterSubmitChangesSuccess: function(sChanel, sEvent, oData) {
var oResponseData = oData.__batchResponses[0].__changeResponses[0].data;
var sBindingPath = oModel.createKey("/EmployeeSet", {Begda: oData.Begda, Endda: oData.Endda, Pernr: oData.Pernr}).replace(/:\s*/g, "%3A");
},
Is there a way to find the index of a specific listitem by the using binding-path. Or is there another way to solve this problem, instead of looping over the whole list a do a comparison?
I'm afraid the only way to find the index of a specific listItems by binding-path is to walk through the collection of list items. So, I'm afraid that a very plain and short answer would be "No".
It's quite easy though, code is not that lengthy, and it also shouldn't cost to much performance if you're not talking about humongous lists. You will have to walk through the list of items though. Once you have found the item with a binding to the context path you're looking for, you can select it using setSelectedItem, like so:
var list = this.getView().byId("list");
jQuery.each(list.getList(), function(idx, item) {
if (items.getBindingContext().getPath = sBindingPath) {
list.setSelectedItem(item);
}
});
Note: Do keep in mind that if you're working with OData services and are working with a so-called 'growing list', the entry you're looking for may not necessarily be in the list.
Apologies, wish I could give you a more pleasant answer.

How do I handle selecting a property in ABPeoplePickerNavigationController?

I am having some trouble with this.. I see that we are supposed to be using the property:
predicateForSelectionOfProperty
for determining which properties get 'selected', and I'm actually kind of bummed for there not being a
predicateForEnablingProperty
because I only want phone numbers, for my use case.
That said, nothing I use for predicateForSelectionOfProperty seems to do what I want. What I want is, when I select a contact's phone number, it should call the delegate callback.. but instead, right now, it is calling them!
Maybe I'm just completely missing something, because I would actually rather just have a list of my contacts, with phone numbers, and only show the phone numbers.. maybe I'm not even heading in the right direction with this.
Thanks for any help you can offer!
If you don't want it to call the number, you should:
specify the peoplePickerDelegate; and
implement peoplePickerNavigationController:didSelectPerson:property:identifier:
don't specify a predicateForSelectionOfProperty (or if you do, make sure it returns true, e.g. NSPredicate(value: true))
Obviously, if you don't even want it to show you unrelated information about contacts, specify the displayedProperties array, e.g.
controller.displayedProperties = [NSNumber(int: kABPersonPhoneProperty)]
Alternatively, if you wanted to customize this UI further, you could just use the AddressBook.framework to extract the phone numbers from the address book and present whatever UI you want.

JSF Strategies For Long Lists in SelectOneMenu e.g. TimeZones

I am implementing a way for a user to specify their timezone. Nothing new there. I want to hear what people say is a good strategy for handling cases when users need to select from a list of a couple hundred choices, but might not know the correct value for it in the list right away. I know I can use something like autocomplete, but that only works if people know what they are looking for. Sure countries should be obvious but... lowest common denominator (some people are dumb... like me ;).
There are something over 400 distinct iso timezones (not including things like EST, PST, etc. which I am not including). That is a long list. It can be conveniently divided if we let the user chose the country they are in first in say, another selectonemenu. But there are more than 200 countries. So how to present 200 countries that is easy and efficient to work with?
I have already created and packaged in a jar a number of classes to read from the Olson timezone files (iso3166.tab and zone.tab) and provide arraylists of timezone and and timezonecountries, including prioritizing specified countries to the top of the list. But now I would like to maybe learn a better way to present the countries and the timezones. I did this myself since I found it an easier and cleaner way to extract and correlate country codes and timezone codes.
For your particular requirement, I can think of using a world map like you see in a Linux distro like Ubuntu centered at Greenwich. Then placing markers for the data that you have and letting the user select the nearest marker.
See Timezone selection for Ubuntu
For this you can make use the Primefaces GMAP component and add an overlay like this:
LatLng coord1 = new LatLng(36.885233, 30.702323);
PlaceResult placeResultObj1 = new new PlaceResult("660")
//Basic marker
simpleModel.addOverlay(new Marker(coord1, "Konyaalti", placeResultObj1));
PlaceResult.java
public class PlaceResult {
private String utc_offset;
public PlaceResult(String utc_offset){
this.utc_offset = utc_offset;
}
public String getUtc_offset() {
return utc_offset;
}
public void setUtc_offset(String utc_offset) {
this.utc_offset = utc_offset;
}
}
Another approach is to use the Places library from Google maps. Using that you can get the google.maps.places.PlaceResult object by various methods, I like the autocomplete feature where you can choose the city. After a city is selected you can show the utc_offset in the infowindow.
You can take a look at this demo
Currently, it seems that most of the cities don't have utc_offset already set. One of the address I found that had utc_offset was
Newy Airport Transport Shuttle in Australia. Then you can pass the off_set as a input hidden parameter to submit the value to the server.
See also:
Google Places Library

jquery UI autocomplete - extended data?

I would like to use Jquery's UI autocomplete but with some additional functions: after user selects suggested item, I would also like to display additional data related with that item (for example if database of contacts are being searched, then I'd like to display contact's email, addres...) in some html element.
Is there a way to accomplish this?
Thanks in advance,
Ile
EDIT:
I'd like to provide more detail description of what I actually need:
When user starts searching contacts, as a result from database I would like to return contact's ID and Full Name. After user selects certain contact, then ajax function is called and it retrieves all details from selected contact using it's ID. But I don't know how to do following:
As a result from database return the ID and Full Name of contact as a JSON result (probably I would find the solution to get the right format, but I don't know how it needs to be passed to Autocomplete script)
How to handle the result data so that I display only full name and ID is used only when certain contact is selected, so that I can retrieve full details of certain contact
Have a look at its events: You can add a handler for the select event and display all your informations once it fires.
You can specify extra data in formatMatch function. The parameter must be some delimiter separated string. Later in .result function , which takes 3 arguments [event, data, formatted], you can retrieve it by splitting the formatted by the delimiter use and populate the required values.

Resources