Last active
August 29, 2015 14:20
-
-
Save modemlooper/9ad395ec8bfa4b1f89b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // add marker for single address | |
| function findAddress(address) { | |
| var geocoder = new google.maps.Geocoder(); | |
| var addresses = ( typeof addresses != 'undefined' && x instanceof Array ) ? address.split('|') : address; | |
| for ( var i = 0; i < addresses.length; i++) { | |
| if( map_places ) { | |
| var newaddress = addresses[i]['single_address']; | |
| var detail = addresses[i]['single_address_details']; | |
| } else { | |
| var newaddress = addresses[i]; | |
| } | |
| geocoder.geocode({ 'address': newaddress }, function (results, status ) { | |
| if (status == google.maps.GeocoderStatus.OK) { | |
| var latitude = results[0].geometry.location.lat(); | |
| var longitude = results[0].geometry.location.lng(); | |
| var posLatlng = new google.maps.LatLng(latitude, longitude); | |
| window.reactorMap.setCenter(posLatlng); | |
| //setTimeout(function(){ | |
| marker = new google.maps.Marker({ | |
| position: posLatlng, | |
| map: window.reactorMap, | |
| title: detail, | |
| animation: google.maps.Animation.DROP, | |
| }); | |
| google.maps.event.addListener( marker, 'click', function() { | |
| var infowindow = new google.maps.InfoWindow(); | |
| console.log( marker ); | |
| infowindow.setContent('<p>' + marker.title + '</p>'); | |
| infowindow.open(window.reactorMap, this); | |
| //setTimeout( function () { infowindow.close(); }, 3500); | |
| }); | |
| //}, 500); | |
| google.maps.event.trigger(window.reactorMap, 'resize'); | |
| } else { | |
| console.log("Geocoder failed.") | |
| } | |
| }); | |
| } // end for loop | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment