javascript - filter markers in accordance with user city location in google maps -
i have map markers in different location , match markers user location (city) i'm getting user city (hopefully it's best practice way )
`<script> $.getjson('https://geoip-db.com/json/geoip.php?jsonp=?') .done(function (location) { $('#country').html(location.country_name); $('#state').html(location.state); $('#city').html(location.city); $('#latitude').html(location.latitude); $('#longitude').html(location.longitude); }); </script>`
and i'm setting markers `
<script> "use strict"; var markers = @html.raw(json.encode(model.upcominglecturegigs)); window.onload = function (a) { var mapoptions = { center: new window.google.maps.latlng(markers[0].latitude, markers[0].longitude), zoom: 8, maptypeid: window.google.maps.maptypeid.roadmap }; var infowindow = new window.google.maps.infowindow(); var map = new window.google.maps.map(document.getelementbyid("dvmap"), mapoptions); (var = 0; < markers.length; i++) { var data = markers[i]; //console.log(data.longitude); var mylatlng = new window.google.maps.latlng(data.latitude, data.longitude); // console.log(data.latitude, data.longitude); var marker = new window.google.maps.marker({ position: mylatlng, draggable: true, animation: google.maps.animation.drop, map() { return map; } }); (function(marker, data) { window.google.maps.event.addlistener(marker, "click", function(e) { infowindow.setcontent(data.venue + " " + data.genre.name); infowindow.open(map, marker); }); })(marker, data); } }; </script>`
how can combine results? https://jsfiddle.net/0f1f4ob7/
Comments
Post a Comment