user123 user123 - 1 year ago 83
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)});,marker);}google.maps.event.addDomListener(window, 'load', init_map);

<div id="map-canvas">

<a href='' style="visibility:hidden;"></a> <script type='text/javascript' src=''></script>

<button class="google_map_btn" onclick="'')">Google Map</button>

I have latitdue and longitude as 37.429138 and -122.165425.

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

Thank You.

Answer Source

<button class="google_map_btn" onclick="',+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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download