views:

12

answers:

1

Hi

I have images to overlay on google maps by using checkboxes. I made this script to not create the separate individual script for each overlay but it returns the error of proprty not supported in main.js of google maps api. However, i tried getting the output value in javascript alert and it returns the values as expected. Could anyone help please?

Here is the script.

function shImg(url,lat,lng) {
                var lat_ = "new GLatLng(" + lat + ")";
                var lng_ = "new GLatLng(" + lng + ")";
                var latlng = lat_ + ", " + lng_;
                var ticked_ = document.getElementById(url);

                var boundaries_ = "new GLatLngBounds(" + latlng + ")";
                var imgurl_ = "http://www.mywebsite.com/" + url + ".jpg";
                imageOverlay_ = new GGroundOverlay(imgurl_, boundaries_);
                map.addOverlay(imageOverlay_);
    if (!ticked_.checked)   {
                map.clearOverlays();
            //  imageOverlay_=null;
    }
        else {
                                alert(boundaries_);
                imageOverlay_.show();

} }

+1  A: 

The GLatLng constructor takes two arguments, a latitude and a longitude. Similarly GlatLngBounds takes two arguments, a GlatLng for the south west corner and one for the north east. See the api docs for more info.

Lastly why are you doing string concatenation all over the place? For example "new GLatLng(" + lat + ")"; should be new GLatLng(lat,lng);

dsas
Thanks mate. Parsing it as string was the problem in fact. Cheers
Jabran