Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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)

Thank you for your help.

Kind Regards, Matt

share|improve this question
    
Most of the time when two coordinates are needed for a "bounds", it is looking for two corners of the image, such as the southwest corner and northeast corner. Or the other two corners. –  MLowry Aug 6 '12 at 15:42
    
Yeah, but how do I get those corners? I know the exact coordinates of the center - that's just the center of the current destination of what I'm looking at inside google maps. But how do I get the corner-coordinates of a 50x50px image I want to center exactly on the coordinates I'm talking about. Is there a way to calculate the coordinates of the southwest and northeast corner when I know the center of the image and the dimensions of the image? I wonder how those coordinates and my pixel-values of the image are working together? –  matt Aug 6 '12 at 17:40
add comment

1 Answer 1

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.

enter image description here

var imageBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(40.716216,-74.213393), 
new google.maps.LatLng(40.765641,-74.139235));
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.