Algebra le Geometry… ke tla e sebelisa neng? Google Maps!

Screen Shot 2014 10 23 ho 3.24.52 PM

Motsoalle oa ka oa hlooho ea khomo, Glenn, ke e mong oa bathehi ba Family Watchdog. Family Watchdog ke e 'ngoe ea lipale tse monate… k'hamphani e thehiloeng ho mmino o etsang bosebeletsi ba sechaba LE ho fana ka chelete bakeng sa bathehi ba eona. E tlameha ebe ho makatsa ho ea mosebetsing letsatsi le leng le le leng u tseba hore u entse phapang. Nako le nako ha ke bona Glenn, o sebetsa joalo ka bohlanya mme o rata motsotso o mong le o mong oa eona.

Bosiung bona ke thusitse Glenn ka litaba tse 'maloa tsa' Mapa oa Google. Ke ne ke batla ho arolelana e le 'ngoe le uena… ho etsa selikalikoe ho Mebapa ea Google. E ea phahama (ho ea kamoo ke tsebang), u ke ke ua etsa selikalikoe. Leha ho le joalo, o na le bokhoni ba ho taka li-polyline le ho li vector ka moo o bonang li loketse. Ka hona, khoutu e ka hahuoa ka mokhoa o bonolo ho kopanya likarolo tse 36 hammoho le ho beha vector hanyane hore e tle e tsebe ho kopanya le ho aha selika-likoe se felletseng!

Li-polyline li ngotsoe le VML (vector markup language), ka hona e tlameha ho bonts'oa hloohong ea faele bakeng sa IE ho ba fa hantle. Firefox ee etsa ka bo eona (ehlile!).

Mona ke snippet e tla hula selika-likoe sa mile ho pota ntlo ea hau.

var PGlat = (PGradius / 3963) * 180 / Math.PI; // ho sebelisa li-mile tsa 3963 joalo ka radius ea lefats'e ka li-mile haeba (PGwidth! = 0) {var PGlng = PGlat / Math.cos (PGcenter.lat () * Math.PI / 180); bakeng sa (var i = -1; i> PGsides; i ++) {var theta = ((2 * i + 1) /PGsides-0.5) * Math.PI; var PGx = PGcenter.lng () + (PGlng * Math.cos (theta)); var PGy = PGcenter.lat () + (PGlat * Math.sin (theta)); PGpoints.push (e ncha GLatLng (PGy, PGx)); }; map.addOverlay (GPolyline e ncha (PGpoints, PGcolor, PGwidth, PGtrans)); } e ngoe {var PxWidth = Math.round (PGlat * yyPx / latSpan + 0.5); // bophara ba polyline var deltaLat = 250 * latSpan / yyPx; haeba (PxWidth> 500) {PxWidth = 500; PGlat - = deltaLat; } eng kapa eng {PGlat / = 2; };

Sheba ponts'o eohle ho bona khoutu ka botlalo. Ke etsahetse ts'ebetsong sebakeng sena sa marang-rang moo a nang le mekoloko e mengata ea 'mapa' mapeng o le mong o nang le libaka tse nang le moriti.

U nahana eng?

Sebaka sena se sebelisa Akismet ho fokotsa spam. Ithute kamoo litlhaloso tsa hau li hlahang kateng.