Posts

Showing posts with the label google map bounds..

Rails + Google Map V3 with Marker, Bounds

Hi I have used this function to load Google map with Marker and bounds. function initialize(lat, lon, div_id) { var myLatlng = new google.maps.LatLng(lat, lon); var myOptions = { zoom: 8, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var bounds = new google.maps.LatLngBounds (); var map = new google.maps.Map(document.getElementById(div_id), myOptions); var trucklatlng = new google.maps.LatLng(lat,lon); var marker = new google.maps.Marker({ position: trucklatlng, map: map, title:"Assist" }); var LatLngListFake1 = new google.maps.LatLng(lat + 0.005 , lon + 0.005); var LatLngListFake2 = new google.maps.LatLng(lat - 0.005, lon - 0.005); bounds.extend(LatLngListFake1); bounds.extend(LatLngListFake2); map.fitBounds (bounds); } In the View File: Just call, <script>initialize(lat, lon, div_id)</script>