You can use a function to load Google map with Marker and bounds, function is as below.
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>
Done !
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>
Done !
No comments:
Post a Comment