Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- marker.addListener('click', function(e) {
- closeAllInfoWindows();
- infowindow.open(marker.get('map'), marker);
- var geocoder = new google.maps.Geocoder;
- geocoder.geocode({'location': e.latLng}, function(results, status) {
- infowindow.open(marker.get('map'), marker);
- if (status === 'OK') {
- if (results[1]) {
- console.log(results[0].formatted_address)
- console.log(results[0].address_components[0].long_name)
- console.log(results[0].address_components[1].long_name)
- cont = infowindow.content
- console.log(cont)
- regex = new RegExp(/<small class="grey-500">(.*?)</small>/g)
- cont = cont.replace(regex,
- ('<small class="grey-500">'+
- results[0].address_components[1].long_name + ', ' +
- results[0].address_components[0].long_name +
- '</small>')
- ).toString()
- console.log(cont);
- } else {
- window.alert('No results found');
- }
- } else {
- window.alert('Geocoder failed due to: ' + status);
- }
- });
- closeAllInfoWindows();
- infowindow.setContent(cont);
- infoWindow.setPosition(e.latLng);
- infowindow.close(marker.get('map'), marker);
- infowindow.open(marker.get('map'), marker);
- });
- 11:04:42.887 map4.html:162 <small class="grey-500"></small>
- 11:04:42.897 map4.html:162 <small class="grey-500">Красногорский бульвар, 13</small>
Add Comment
Please, Sign In to add comment