Algebra thiab Geometry… thaum twg kuv yuav siv tas? Google Maps!

Tshuaj Ntsuam Cov 2014 10 23 ntawm 3.24.52 PM

Tus phooj ywg zoo ntawm kuv, Glenn, yog ib tus tsim ntawm Tsev Neeg Saib Xyuas. Family Watchdog yog ib qho ntawm cov dab neeg zoo tshaj plaws… lub tuam txhab tau tsim ntawm lub mashup uas tau ua tiav kev pabcuam pej xeem THIAB ua tau muab kev nyob rau nws cov neeg tsim. Nws yuav tsum xav tsis thoob mus ua haujlwm txhua hnub paub tias koj tau ua qhov sib txawv. Txhua zaus kuv pom Glenn, nws ua haujlwm zoo li vwm thiab hlub txhua feeb ntawm nws.

Hmo no Kuv tau pab tawm Glenn nrog ob peb qhov teeb meem Google Map. Kuv xav qhia ib qho rau koj… kos lub voj voog ntawm Google Maps. Nws cua hlob (raws li qhov kuv paub), koj tsis tuaj yeem kos ib lub voj voog. Txawm li cas los xij, koj muaj peev xwm kos duab polylines thiab vector lawv raws li koj pom zoo. Yog li, qhov kev cai tsim tau los ua kom tsuas yog muab 36 ntu ua ke thiab me ntsis kaum lub vector kom lawv ntxiv thiab tsim ib lub voj voog tiav!

Cov kab ntawv sau yog sau nrog VML (vector markup language), yog li nws yuav tsum tau qhia nyob rau hauv lub header ntawm cov ntaub ntawv rau IE kom tsim nyog lawv. Firefox ua nws tau txiav (tas li!).

Ntawm no yog qhov snippet uas yuav kos lub voj voog 1 mais ncig ntawm koj lub tsev.

var PGlat = (PGradius / 3963) * 180 / Math.PI; // siv 3963 mais raws li lub ntiaj teb hluav taws xob hauv mais yog (PGwidth! = 0) {var PGlng = PGlat / Math.cos (PGcenter.lat () * Math.PI / 180); rau (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 (tshiab GLatLng (PGy, PGx)); }; map.addOverlay (tshiab GPolyline (PGpoints, PGcolor, PGwidth, PGtrans)); } lwm {var PxWidth = Math.round (PGlat * yyPx / latSpan + 0.5); // dav ntawm polyline var deltaLat = 250 * latSpan / yyPx; yog (PxWidth> 500) {PxWidth = 500; PGlat - = deltaLat; } lwm {PGlat / = 2; };

Saib tag nrho demo saib cov code kom puv. Kuv tau tshwm sim hla qhov kev ua haujlwm ntawm tus xaib no uas nws tau txais ntau cov voj voog ntawm cov voj voog ntawm ib daim pheem thib ib nrog thaj tsam tsaus.

Yuav ua li cas koj xav hais tias?

Qhov Web site no siv Akismet los txo cov kev pabcuam. Kawm li cas koj cov ntaub ntawv tawm tswv yim tiav.