javascript - Meteor implementing Google Maps and Google Places -


i'm attempting implement google map on meteor app user's location , find places serve food near user. began implementing example

given google, , worked fine when did way; i'm trying implement adding actual javascript file , giving me "google undefined" error.

menulist = new mongo.collection('items');  if (meteor.isclient) {        var pls;      var map;      var infowindow;      meteor.startup(function () {          //get user location , 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) {                  (var = 0; < results.length; i++) {                      createmarker(results[i]);                  }              }          },            createmarker: function (place) {              var placeloc = place.geometry.location;              var marker = new google.maps.marker({                  map: map,                  position: place.geometry.location              });                google.maps.event.addlistener(marker, 'click', function () {                  infowindow.setcontent(place.name);                  infowindow.open(map, this);              });          }          })        template.searchit.helpers({          'initmap': function () {              console.log("here");              //dummy values placed stackoverflow              var pyrmont = {lat: -33.234, lng: 95.343};                map = new google.maps.map(document.getelementbyid('map'), {                  center: pyrmont,                  zoom: 15              });                infowindow = new google.maps.infowindow();              var service = new google.maps.places.placesservice(map);              service.nearbysearch({                  location: pyrmont,                  radius: 500,                  types: ['food']              }, callback);          }          })  }
<head>      <title>place searches</title>      <meta name="viewport" content="initial-scale=1.0, user-scalable=no">      <meta charset="utf-8">      <div id="map"></div>      <script src="https://maps.googleapis.com/maps/api/js?key=aizasyacgadfjrh2pmm-bsta1s40wpkddspxo2m	  &signed_in=true&libraries=places" async defer></script>      <style>        html, body {          height: 100%;          margin: 0;          padding: 0;        }        #map {          height: 100%;        }      </style>          </head>    <body>        {{>searchit}}          </body>      <template name="searchit">  {{initmap}}  </template>

you should try dburles:google-maps package.

here example written author: http://meteorcapture.com/how-to-create-a-reactive-google-map/

have fun!


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -