Google Places API Autocomplete Not Showing Results - reactjs

In my React application. I'm using the Google Places API Autocomplete so users will be able to type their location and their city/state/country info will be automatically filled in, but I'm getting a problem I can't solve.
const autocomplete = new google.maps.places.Autocomplete(input);
When I don't specify options to the second parameter. Everything works good but I only want to return the user's city, state, and country but when I specify a type. The autocomplete don't even show me results.

I hope that there could be something wrong when declaring your option object. But I can't exactly say without having a look at your code.
But this is the example provided by google in their google Maps Api. I hope that this will solve your problem.
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(-33.8902, 151.1759),
new google.maps.LatLng(-33.8474, 151.2631));
var input = document.getElementById('searchTextField');
var options = {
types: ['(cities)'],
componentRestrictions: {country: 'fr'} // show only results for country France
};
autocomplete = new google.maps.places.Autocomplete(input, options);
For more details you can refer google maps API
https://developers.google.com/maps/documentation/javascript/places-autocomplete

Related

How to draw map using new Lat Lng in ionic

I am passing proper latitude and longitude to the map but it shows old map, having old lat lng. I know I am doing something wrong in this, but I can't figure out it. My project in ionic framework and for map I am using this plugin map plugin
This my html code
<div style="width:100%;height:200px" id="mapDisplay"></div>
This my angularJS code
var getLat = $scope.dealer.lat;
var getLng = $scope.dealer.lng;
var address = $scope.dealer.address;
var mapDiv = document.getElementById("mapDisplay");
const myGeoLocation = new plugin.google.maps.LatLng(getLat,getLng);
var map = plugin.google.maps.Map.getMap(mapDiv, {
'camera': {
'latLng': myGeoLocation,
'zoom': 15
}
});
map.addEventListener(plugin.google.maps.event.MAP_READY, function() {
map.addMarker({
'position': myGeoLocation,
'title': address
}, function(marker) {
marker.showInfoWindow();
});
});
From the docs of the map plugin you are using
This plugin generates only one map instance using the Map.getMap()
method. In general, you may want to create multiple maps, but this
plugin doesn't allow it.
So your plugin.google.maps.Map.getMap is only grabbing the existing instance, not creating a new one and the plugin.google.maps.event.MAP_READY is only fired once, the first time. However looking at the source code it looks like the instance exposes a remove method which you can use to destroy the existing instance and create a new one with the new sets of coordinates when the callback is called, e.g: map.remove(function() { /** reset map coordinates **/ }
** Extra **
If you just need to display a map with a set of coordinates you can do it using the native app by passing lat/lon to the $cordovaInAppBrowser plugin. As an example for iOS and Android you'd have the following:
iOS
$cordovaInAppBrowser.open('maps://?q=<latitude>,<longitude>', '_system');
Android
$cordovaInAppBrowser.open('geo:0,0?q=<latitude>,<longitude>', '_system');
And finally you need to enable the geo uri in your config.xml like so:
<allow-intent href="geo:*" />
The plugin doesn't allow to create multiple maps instance More detail.
But you can achieve this by using this code
var map = plugin.google.maps.Map.getMap(div);
map.clear();
map.off();
map.trigger("test");
map.addEventListener(plugin.google.maps.event.MAP_READY);

Linking Data in Firebase

I am designing a forum and have a layout like this in on my Firebase:
root
|-posts
|-postID1
|-creator: "userOne"
|-creatorUID: "simplelogin:1"
|-text: "Some Text"
|-postID2
|-creator: "userTwo"
|-creatorUID: "simplelogin:2"
|-text: "Some Other Text"
|-profile
|-simplelogin:1
|-firstName: "John"
|-user: "userOne"
|-simplelogin:2
|-firstName: "Sue"
|-user: "userTwo"
On my forum page. I simply use a Angular ng-repeat to get all of the posts on Firebase and list them out. I also want to print out the first name of whoever created the post, but right now, I can only access {{ post.creator }}, which just gives the username of the person who posted. How can I link the post's creator (or creatorUID) with the first name field of that person's profile?
If you're just displaying the the users firstName I would place the users name in the postIDX object.
This would be quicker and produce less requests to Firebase with you going back and fourth with each post to get the usersFirst name.
more information on structuring data and best practices can be found here: https://www.firebase.com/docs/web/guide/structuring-data.html
Updated from response
if you wanted to get the user details then within every request to the postIDx you'd need to do something similar to this (not tested and quick mock up).
var fbRef = new Firebase('firebase path'),
postDetailsObject = {};
fbRef.child('posts').once('value', function(snapshot) {
// loop through each post
snapshot.forEach(function(childSnapshot){
var postDetails = childSnapshot.val(),
profileDetails;
postDetailsObject.post = postDetails;
fbRef.child('profile/' + postDetails.creatorUID).once('value', function(profileData) {
postDetailsObject.profile = profileData;
});
})
});
Then return the postDetailsObject in to angular so you can loop through the single object.

Registration with profile picture using services in Drupal

I've been trying to upload a user profile picture during the user registration using Service 3 and so far I haven't had any luck. I tested passing a hard coded fid in the field "picture" and also tried to pass the fields "filemime", "filename", etc. and it didn't work neither.
Any idea about what fields I need to populate?
I guess it must be related to this post Using Drupal Services and DIOS SDK for setting user picture in iOS app
but it doesn't have and answer neither.
I use following code -
//Picture is first uploaded from ios using file service and fid is passed in $data object
$file_contents_object = file_load($data->picture_fid);
$file_contents_array['fid'] = $file_contents_object->fid;
$file_contents_array['uid'] = $file_contents_object->uid;
$file_contents_array['filename'] = $file_contents_object->filename;
$file_contents_array['uri'] = $file_contents_object->uri;
$file_contents_array['filemime'] = $file_contents_object->filemime;
$file_contents_array['filesize'] = $file_contents_object->filesize;
$file_contents_array['status'] = $file_contents_object->status;
$file_contents_array['timestamp'] = $file_contents_object->timestamp;
$file_contents_array['rdf_mapping'] = $file_contents_object->rdf_mapping;
//use your cck field here
$user_obj->field_user_profile_picture['und'][0] = $file_contents_array;
Hope this will help.

Parse.com iOS SDK: Create New Related Object on Object Save

I'm trying to use cloud code to create a new 'credit' every time a new User is created, the credit is for that user, as in it is a related object. For some reason I can't get writing to the 'Logs' tab to work using lines like console.log(tell me what is going on!); so I'm stumped, and with no way of knowing where I've gone wrong.
Parse.Cloud.afterSave("User", function(request) {
var Credit = Parse.Object.extend("credit");
var credit = new Credit();
credit.set("parent", request.object);
credit.set("expiry", null);
credit.set("type", "Opening");
credit.save();
});
You need to change it to this:
Parse.Cloud.afterSave(Parse.User, function(request)
Parse.User rather than "User".
For whatever reason this doesn't seem to be in the docs here: https://www.parse.com/docs/cloud_code_guide#functions-aftersave

tweetsharp implementation in mvc.net

Hi
I want to use Tweetsharp in my mvc.net application to get the list offriends and to share image with them.
But i haven't got the proper documentation and sample for the same. What is need to add in controller action and what in view page.
Please give some links for the same.
Thanks
munish
public void MyMethod() {
TwitterService service = new TwitterService(key, secret, "Token", "Secret");
ListFriendsOptions options = new ListFriendsOptions();
options.Cursor = 12345;
// should the response have user entities
options.IncludeUserEntities = false;
// The screen name of the user for whom to return results for.
options.ScreenName = "";
options.SkipStatus = false;
// The ID of the user for whom to return results for.
options.UserId = 12345;
// this will return a list of friends for the specified user.
TwitterCursorList<TwitterUser> listOfFriends = service.ListFriends(options);
}
Also note the code above uses a third party library called TweetSharp.
As for the images im not sure as to what to do but you can look at the twitter REST API v1.1 for information
https://dev.twitter.com/docs/api/1.1/get/friends/list
https://dev.twitter.com/docs/api/1.1
TweetSharp
https://github.com/danielcrenna/tweetsharp
I don't know about Tweetsharp but take a look at linq2twitter. It provides easy access to the Twitter API through the use of LINQ.

Resources