Last active
October 16, 2019 14:47
-
-
Save sungraiz/a052215e939b1cfc542367b99a5afa22 to your computer and use it in GitHub Desktop.
Now user can search by both coordinates and address.
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
| if((/[a-z]/i.test(address))){ | |
| this.geocoder.geocode({'address': address}, function (results, status) | |
| { | |
| if ( status == window.google.maps.GeocoderStatus.OK ) | |
| { | |
| that.updatePositionInput(results[0].geometry.location); | |
| that.marker.setPosition(results[0].geometry.location); | |
| that.map.setCenter(that.marker.position); | |
| that.map.setZoom(15); | |
| } | |
| }); | |
| }else{ | |
| const latLngStr = address.split(',', 2), | |
| newLatLang = new window.google.maps.LatLng( latLngStr[0], latLngStr[1] ); | |
| this.geocoder.geocode({ 'latLng': newLatLang }, function (results, status) { | |
| if (status === google.maps.GeocoderStatus.OK) { | |
| that.updatePositionInput(newLatLang); | |
| that.marker.setPosition(newLatLang); | |
| that.map.setCenter(that.marker.position); | |
| that.map.setZoom(15); | |
| document.getElementById('address').value= results[0].formatted_address; | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment