javascript - Getting current location on a map using Meteor -
hey using 2 packages dburles:maps
, mdg:geolocation
, goal plot current location on map. current js code display's map, not sure how proceed it.
map.js edited
meteor.startup(function() { googlemaps.load(); }); template.map.helpers({ mapoptions: function() { if (googlemaps.loaded()) { return { center: new google.maps.latlng(current), zoom: 8 }; } } }); template.map.oncreated(function() { googlemaps.ready('map', function(map) { if (navigator.geolocation) { // support navigator.geolocation.getcurrentposition(function(position) { var current = new google.maps.latlng(position.coords.latitude, position.coords.longitude); }); map.setcenter(current); } else { // no support console.log("something wrong!") } }) })
i think supposed add in if(navigator.geolocation
, place value in center: new google.maps.latlng()
, not sure. ideas?
you're on right track. have seen google's geolocation example?
Comments
Post a Comment