Skip to content Skip to sidebar Skip to footer

Show Image From Google Api Place Photo Response

I am working with Meteor.js. I need place photos of google place. I am working with Javascript here. So here is what I've done. Meteor.call('getPlaceDetails', result.pl

Solution 1:

I did miss that function of what Sorin Lascu has commented. If someone is doing that in Meteor.js I will provide a complete and easy answer. I created an input field which has Google Maps API autocomplete, and shows the place on a map instantly. You also get all the necessary data you need to show to photos and other details.

I added this package jeremy:geocomplete to my project.

I created a map in HTML like this:

<div class="col s12 m10 l10 push-m1 push-l1"id="google_mapPlace">
    {{> googleMap name="mapPlace" options=mapOptions}}
</div>

I added an input field in HTML

<input value=""type="text"class="findPlace">

Then in my js file I update my function with autorun.

Template.adminCollections.onRendered(function() {
    this.autorun(function () {
        if (GoogleMaps.loaded()) {
            $(".findPlace").geocomplete({
                map: "#google_mapPlace",
                nearbySearchKeys: ['photos', 'place_id', 'name', 'geometry']
            }).bind("geocode:result", function(event, result){
                $('.myimg').attr('src', result.photos[0].getUrl({'maxWidth': 500, 'maxHeight': 500}));
            });
        });
    });
});

Post a Comment for "Show Image From Google Api Place Photo Response"