blog.federicomaffei.com

current level - articles for beginners

Day 49.

$.get('/posts/' + postId + '.json', function(post){
            var map = new GMaps({
                div: '#map',
                lat: 0,
                lng: 0
            });

            GMaps.geocode({
                address: post.address,
                callback: function(results, status) {
                    if (status == 'OK') {
                        var latlng = results[0].geometry.location;
                        map.setCenter(latlng.lat(), latlng.lng());
                        map.addMarker({
                            lat: latlng.lat(),
                            lng: latlng.lng()
                        });
                    }
                    else {
                        alert('Could not find address')
                    }
                }
            });
        })

My pizzagram app is getting cooler and cooler.
Now it integrates Google Maps to the service, so now a user can enter an address along with the post, which triggers the creation of a link with a map that points to the exact address. Nice!

Plus, I managed to push it to Heroku, which is the cloud service we will use to make our applications available to the public, for now.

If you want to have a look at my humble work, click HERE.

HOMER

Away, to eat pizza of course.

comments powered by Disqus