Guest User

Untitled

a guest
Jan 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. marker.addListener('click', function(e) {
  2. closeAllInfoWindows();
  3. infowindow.open(marker.get('map'), marker);
  4. var geocoder = new google.maps.Geocoder;
  5. geocoder.geocode({'location': e.latLng}, function(results, status) {
  6. infowindow.open(marker.get('map'), marker);
  7. if (status === 'OK') {
  8. if (results[1]) {
  9. console.log(results[0].formatted_address)
  10. console.log(results[0].address_components[0].long_name)
  11. console.log(results[0].address_components[1].long_name)
  12. cont = infowindow.content
  13. console.log(cont)
  14. regex = new RegExp(/<small class="grey-500">(.*?)</small>/g)
  15. cont = cont.replace(regex,
  16. ('<small class="grey-500">'+
  17. results[0].address_components[1].long_name + ', ' +
  18. results[0].address_components[0].long_name +
  19. '</small>')
  20. ).toString()
  21. console.log(cont);
  22. } else {
  23. window.alert('No results found');
  24. }
  25. } else {
  26. window.alert('Geocoder failed due to: ' + status);
  27. }
  28. });
  29.  
  30. closeAllInfoWindows();
  31.  
  32. infowindow.setContent(cont);
  33. infoWindow.setPosition(e.latLng);
  34.  
  35. infowindow.close(marker.get('map'), marker);
  36. infowindow.open(marker.get('map'), marker);
  37. });
  38.  
  39. 11:04:42.887 map4.html:162 <small class="grey-500"></small>
  40.  
  41. 11:04:42.897 map4.html:162 <small class="grey-500">Красногорский бульвар, 13</small>
Add Comment
Please, Sign In to add comment