خرید بک لینک

Vote count: 0

I have used google map place search box.

https://developers.google.com/maps/documentation/javascript/examples/places-searchbox (In this api we can search more than place name.for example,we can search 'hospitals near Sidney') In below code section push.arryName used to insert markers into array.

//insert markers to array markers.push(new google.maps.Marker({ map: map, icon: icon, title: place.name, position:place.geometry.location })); //Also there is a code to delete oldmarkers // Clear out the old markers. markers.forEach(function(marker) { marker.setMap(null); }); markers = [];

then I wanted to latLng value and place name from each markers and I have modified push.markers code section to below code.

 //insert latLng list to array markers
 markers.push(place.geometry.location); 
 //inser place name list to array pls
 pls.push(place.name);


 for(i=0;i<markers.length;i++){
 var ltln= markers[i]; 
 var pl=pls[i];
  var marker=new google.maps.Marker({
   position:ltln,
    icon:pinIcon,
   title:place.name,
   map:map
 });

  (function(marker,ltln,pl){

 google.maps.event.addListener(marker,"click",function(e){

document.getElementById('name').ierHTML=pl;
document.getElementById('lt').value=ltln.lat();
document.getElementById('ln').value=ltln.lng();

});
  })(marker,ltln,pl);


 }

all working. But after modified, I can't search more than one time.I have to reload the page to search a new place. What is wrong? Is not match old marker delete section with my modified code? please help me..

asked 2 mins ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 11 اسفند 1394 ساعت: 9:06

صفحه بندی