开发者

JavaScript .length google maps

开发者 https://www.devze.com 2023-04-01 03:38 出处:网络
I am sure that I am missing something simple because I have found the length of an element within an array using several different languages in my time, but this one has me stumped.

I am sure that I am missing something simple because I have found the length of an element within an array using several different languages in my time, but this one has me stumped.

The function has an alert to notify of the lengths of the contents of the 0 position within each array. Yet, it continuously alerts me that the lengths are both one. At the same time, I have the alert of the actual contents. Granted, I took courses leading up to differential equations, so I am not a mathematician, but I know that the length of 183 is not the same length as 13600. What am I doing wrong?

    markerPosLat = streetAddressLat[0];
markerPosLng = streetAddressLng[0];

var point = new google.maps.LatLng(markerPosLat,markerPosLng);

var panoPos = mybigpano2.getPosition();
var schoolAdLen = schoolAddressSelectValue.length - 8;

var panoAd = new Array();
var schoolAd = new Array();
var tempPanoAd = '';
tempPanoAd = panoStreet[0];
var tempPanoAd2 = '';
tempPanoAd2=panoStreet[0].match(/\d+/,panoStreet[0]);
panoAd[0] = tempPanoAd2;
var tempStAd = '';
schoolAd[0] = schoolAddressSelectValue;
var tempStAd2 = '';
tempStAd2=schoolAd[0].match(/\d+/,schoolAd[0]);
schoolAd[0] = tempStAd2;
var panoAdLen = panoAd[0].length;
var stAdLen = schoolAd[0].length;
//alert(panoAd[0]+' '+schoolAd[0]);

var panoPosLat = panoPos.lat() / 180 * Math.PI;
var panoPosLng = panoPos.lng() / 180 * Math.PI;

var y = Math.sin(markerPosLng - panoPosLng) * Math.cos(markerPosLat); 
var x = Math.cos(panoPosLat)*Math.sin(markerPosLat) - Math.sin(panoPosLat)*Math.cos(markerPosLat)*Math.cos(markerPosLng - panoPosLng); 
brng = Math.atan2(y, x) / Math.PI * 255;

if(panoAd[0])
{
    if(panoAdLen == stAdLen)
    {
        if((isEven(panoAd[0])) && (isEven(schoolAd[0])))
        {

        }
        else if((isOdd(panoAd[0])) && (isOdd(schoolAd[0])))
        {

        }
        else
        {
            brng = brng * -1;
        }
    }
    else
    {
        brng = brng * 1;
    }       
}
else
{
    brng = brng * -1;
}

alert(panoAd[0]+' '+schoolAd[0]+' '+brng+' '+panoAdLen+' '+stAdLen);

Basically, if panoAdLen == stAdLen is true, the开发者_运维技巧n I need to know if the pano's address and the street(marker's) address are either both even or both odd, which if they are either of the two cases, then I do nothing.

However, if one is even and one is odd, then I need to make the bering negative to the pano's bering, so that the pano's bering is set the street(marker's) address.

All of this could work fine if I can for sure know whether or not the lengths of the street numbers are the same or not. Sometimes google returns a cross street which has no street number, etc...

Of course, without knowing if two variables are of the same length then none of this works.

The alert is always returning panoAdLen and stAdLen as both having the value of one.

sample to view

You can see for yourself with the link above. I choose the ABC district from the first set of selection menus, then, once the addresses have been populated, I choose the Cerritos Elementary - 13600 E 183rd St, Cerritos, CA.

You will see the alert show the contents of panoAd[0] as being 183 and schoolAd[0] as being 13600. Yet panoAdLen is 1, as well as, stAdLen is 1 -- HOW?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号