javascript - show markers on map with getJSON -


i trying place markers on google map first finding latitude , longitude of user geolocation , sending same using request.

here code:

function getlocation() {     if (navigator.geolocation) {         navigator.geolocation.getcurrentposition(function (position) {              $.ajax({                 type: "get",                 url: "http://localhost/baazar_search/public/walkalong/" + position.coords.latitude + "/" + position.coords.longitude,                 data: {                     lat: position.coords.latitude,                     log: position.coords.longitude                 },                 success: function () {                     window.location.replace("http://localhost/baazar_search/public/layer0");                  }             });         });     } else {         x.innerhtml = "geolocation not supported browser.";     } } 

and second file this-

function initialize() {                 var mapoptions = {                     center: new google.maps.latlng(17, 78.5463),                     zoom: 10,                     maptypeid: google.maps.maptypeid.roadmap                 };                 var map = new google.maps.map(document.getelementbyid("googlemap"), mapoptions);                 $.getjson("http://localhost/baazar_search/public/walkalong/" + position.coords.latitude + "/" + position.coords.longitude, function (data) {                     $.each(data.points, function (i, value) {                          var mylatlng = new google.maps.latlng(value.latitude, value.longitude);                         var marker = new google.maps.marker({                             position: mylatlng,                             map: map,                         });                      });                 });             }             google.maps.event.adddomlistener(window, 'load', initialize); 

i want plot markers on map according response getting in $.ajax method. error getting position not defined. can 1 help? want use response when page redirected unable that..


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -