Hi there,
This is my first time ever coding in any language and I have been trying to add 2 markers into google maps and set the zoom and center to have both coordinates on one screen and zoomed in as much as possible while keeping the markers on the screen.
after much research, I worked out that the code that I need to implement is:
map.fitBounds(this.map.bounds);
after putting that code in, it either didn't do anything or stopped working completely
any help would be greatly appreciated
thanks,
ps
I am a complete newb at coding and would appreciate your patience in helping me with this process.
This is the code that I have so far is (sorry for not posting a link to the code hosted publicly, this is IIS at the mo):
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
</script>
<script type="text/javascript">
function initialize() {
var lat1 = 13.51256;
var long1 = 45.43612;
var lat2 = -84.35151;
var long2 = 33.92062;
var centerlat = (lat1+lat2)/2;
var centerlong = (long1+long2)/2;
var latlng = new google.maps.LatLng(lat1,long1);
var latlng2 = new google.maps.LatLng(lat2,long2);
var myOptions = {
zoom: 1,
center: new google.maps.LatLng(centerlat,centerlong),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:"bill"
});
var marker2 = new google.maps.Marker({
position: latlng2,
map: map,
title:"kabeer"
});
marker.setMap(map);
};
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:500px; height:500px"></div>
</body>
</html>