user123 user123 - 1 month ago 11
Javascript Question

Open a google map in new window on click event

I want to open a google map window with desired address when click on Google Map Text.



<script type='text/javascript'>
function init_map(){
var myOptions = {zoom:12,center:new google.maps.LatLng(37.429138,-122.165425),mapTypeId: google.maps.MapTypeId.ROADMAP};
map = new google.maps.Map(document.getElementById('map-canvas'), myOptions);
marker = new google.maps.Marker({map: map,position: new google.maps.LatLng(37.429138,-122.165425)});infowindow.open(map,marker);}google.maps.event.addDomListener(window, 'load', init_map);
</script>

<div id="map-canvas">

</div>
<a href='http://maps-generator.com/' style="visibility:hidden;">maps-generator.com</a> <script type='text/javascript' src='https://embedmaps.com/google-maps-authorization/script.js?id=8c625687c25478af5f90bfa006dcfc0007e43f63'></script>


<button class="google_map_btn" onclick="window.open('http://www.google.com')">Google Map</button>





I have latitdue and longitude as 37.429138 and -122.165425.

on this
coordinate
, i want to open address in google map when clicking on google map button.

Thank You.

Answer

<button class="google_map_btn" onclick="window.open('https://www.google.co.in/maps/place/366+Galvez+St,+Stanford,+CA+94305,+USA/@37.4291376,-122.1676142,17z/data=!3m1!4b1!4m5!3m4!1s0x808fbb28286ff66b:0x5c5eec818db4c4b1!8m2!3d37.4291376!4d-122.1654255')">Google Map</button>

Try this.

Hope this helps.