Home Ask Login Register

Developers Planet

Your answer is one click away!

E.Sen February 2016

Meteor implementing Google Maps and Google Places

I'm attempting to implement a Google Map on my Meteor app that will get the user's location and then will find places that serve food near the user. I began by implementing the example

given by Google, and it worked fine when I did it that way; however I'm trying to implement it properly by adding it to the actual Javascript file and it is now giving me a "Google is undefined" error.

menuList = new Mongo.Collection('items');
if (Meteor.isClient) {

    var pls;
    var map;
    var infowindow;
    Meteor.startup(function () {
        //get user location and return location in console
        var options = {
            enableHighAccuracy: true,
            timeout: 5000,
            maximumAge: 0
        };

        function success(pos) {
            var crd = pos.coords;

            console.log('Your current position is:');
            console.log('Latitude : ' + crd.latitude);
            console.log('Longitude: ' + crd.longitude);
            console.log('More or less ' + crd.accuracy + ' meters.');
            pls = {lat: crd.latitude, lng: crd.longitude};
        };

        function error(err) {
            console.warn('ERROR(' + err.code + '): ' + err.message);
        };

        navigator.geolocation.getCurrentPosition(success, error, options);
    })

    Meteor.methods({
        callback: function (results, status) {
            if (status === google.maps.places.PlacesServiceStatus.OK) {
                for (var i = 0; i < results.length; i++) {
                    createMarker(results[i]);
                }
            }
        },

        createMarker: function (place) {
            var placeLoc = place.geometry.location;
                 

Answers


Xavier Cazalot February 2016

You should try the dburles:google-maps package.

Here is an example written by its author: http://meteorcapture.com/how-to-create-a-reactive-google-map/

Have fun!

Post Status

Asked in February 2016
Viewed 1,819 times
Voted 8
Answered 1 times

Search




Leave an answer


Quote of the day: live life

Devs Planet ®

2014-2016 www.devsplanet.com

Devs Planet © all rights reserved

Search