I'm working with the Google Maps API for the first time and I'm trying to append a simple image of a Building on top of my current map view.
This seems to be very straight forward when I look at the GMapsAPI here …
https://developers.google.com/maps/documentation/javascript/overlays#GroundOverlays
However, I have no idea how to calculate the bounds
and the exact position of my overlay.
As you can see in the documentation the position of the ground overlay is done via LatLng
var imageBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(40.716216,-74.213393),
new google.maps.LatLng(40.765641,-74.139235));
In my case I have no idea how to calculate those bounds. What are those values exactly? Why are there two seperate LatLng
positions needed?
I have a simple .png of a building that I want to layer on top of an exact position. I get this position by entering the destination in Google Maps and reading the Lat
and Lng
values from the embed-code.
Is there a better way of doing this? Any ideas, tipps or tricks on how I could do this?
Or is it possible to calculate those bounds
when I know the center of the image-position and the dimesions of my image file? (My image is 50x50px and a .png)
Best Answer
You can use 'LatLng Marker' Google Map in Map Labs mode to find the Coordinates for your image.
Bottom Left is first, Top right is the second coordinate.