-2

Origin Latitude/longitude: 39.50000000,-84.78000000

Destination Latitude/longitude: 28.42000000,-81.31000000

How can I draw its bounding box?

The correct bounding box is:

+-----1
|   / |
|  /  |
| /   |
2-----+

I'm intrested to find 1 and 2 points.

I'm also attaching Image for better understanding the requirements. enter image description here I am writing code in PHP.

Parveen Kumar
  • 397
  • 1
  • 5
  • 12
  • 2
    There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue which can be answered in a few paragraphs.I would suggest you find a development forum (perhaps [Quora](http://www.quora.com/Computer-Programming)?) to work out generalities. Then, when/if you have specific coding issues, come back to StackOverflow and we'll be glad to help. – Jay Blanchard Oct 06 '16 at 17:51

1 Answers1

2

you can use fitbounds

<body>
    .....
   <div id='your_map_id' style='height : 300px; width: 300px;'></div>
<body>

<style>

     var mapDiv = document.getElementById('your_map_id');
       var map = new google.maps.Map(mapDiv, {
       mapTypeId: google.maps.MapTypeId.ROADMAP
     });

     var southWest = new google.maps.LatLng(28.42000000, -84.780000);
     var northEast = new google.maps.LatLng(39.50000000, -81.31000000);
     var bounds = new google.maps.LatLngBounds(southWest,northEast);
     map.fitBounds(bounds);
</style>
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
  • What will be the 'your_map_id'? – Parveen Kumar Oct 06 '16 at 18:10
  • your_map_id is the name of the div id that you use as container for the map .. each google maps need a
    for the right work . i have update the answer ..
    – ScaisEdge Oct 06 '16 at 18:13
  • Hi scaisEdge, I think your solution is working for me. I have a question I'm interested to know that why you shuffle the latitude/longitude as var southWest = new google.maps.LatLng(28.42000000, -84.780000); var northEast = new google.maps.LatLng(39.50000000, -81.31000000); Also, I'm using google.maps.event.addListener(map, "bounds_changed", function() { // send the new bounds back to your server alert("map bounds{"+map.getBounds()); }); to get bounding box coordinates. Am I right in this? Please help me Thanks – Parveen Kumar Oct 07 '16 at 11:02
  • The map.fitBound function require that you pass as parameter two var. first must contain southWest cood and the second must cibt northEast .. so you must check for you origin/destination lat/lng th ìe southern, northern, the easthern and the western and use the proper value for southWest/northEast var .. ..i hope this is what you are looking ..and so if my answer is right please mark it as accepted – ScaisEdge Oct 07 '16 at 11:09