Vraag : Google Maps, ahhhh hulp pls!

Hallo hebben allen,

I een nieuw project die omhoog komen en is het invloves het integreren google kaarten, nu mijn probleem dat ik nooit om het even welk ding als dit heb gedaan en van bij het begin het als een painfullcodage excersie kijkt, maar houd is dan verzenden ik van een challenge.

I ben begonnen het bekijken de googlekaart API, en gedownload het HTML- voorbeeld, maar wat de behoefte van I aan bekwaam om een stad, van een daling en dat neer te selecteren van aangezien het verzoek om een kaart te produceren om aan dat location.

Questons
1) te richten ik de grootte van het kaartvenster kan controleren?
2) hoe ik een stadsnaam of richten/postcodedetails in kaartkoorden vertaal of google dit voor me kan doen als zo hoe alstublieft?
3) als ik een kaart omhoog word, kan ik verschillende plaatsen op het in kaart brengen als zo how.

PHP/javascripy/HTML en CSS is wat ik webpages vooraf in dank normaly.

Many voor uw help
Bob
ontwikkel

Antwoord : Google Maps, ahhhh hulp pls!

Antwoorden… Nadat u dit ziet, te lezen gelieve zorgvuldig deze pagina:
http://code.google.com/apis/maps/documentation/staticmaps/

(1) u kunt de grootte van het venster tot pixel controleren 640x640
(2) Google kan dit voor u doen - de statische kaart API kan adresfragmenten of zelfs namen van oriëntatiepunten goedkeuren.  Of u kunt een geocoder gebruiken.  Zowel bieden Google als Yahoo geocoders aan.  Gelieve te zien het codefragment bij een voorbeeld van dit.
(3) u kunt heel wat verschillende plaatsen op een kaart in kaart brengen.  Ik zal een vervolgreactie met een voorbeeld posten dat enkele manieren toont u Google Maps API aan post veelvoudige punaisen of pictogrammen op een kaart kunt gebruiken.

Vriendelijke groeten, ~Ray
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
    
    


    De Manifestatie van SimpleGeoCoder van Yahoo/Google
    
    
    
    Addr:  
    Stad:  
    ST:   
    Pit:  
    
    
    
    
    adres = $_GET [„a“];
$demo->city    = $_GET [„c“];
$demo->state   = $_GET [„s“];
$demo->zip     = $_GET [„z“];


// TEST YAHOO! GEOCODER
$demo->geocodeYahoo ();
echo PHP_EOL. „YAHOO! “;
print_rr ($demo);


// TEST GOOGLE GEOCODER
$demo->geocodeGoogle ();
echo PHP_EOL. „GOOGLE“;
print_rr ($demo);

// GEDAAN ALLEN
matrijs ();


// EENVOUDIGE KLASSE GEOCODER
klasse SimpleGeoCoder
{
    // VERKLAART DE GEGEVENS VAN DE INPUT
    openbare $location;

    // HET GEBRUIK DIT VOOR EEN VRAAG FREEFORM, OF GEBRUIKT DE DELEN
    openbare $address;
    openbare $city;
    openbare $state;
    openbare $zip;

    // VERKLAART DE WERKENDE GEGEVENS
    privé $precis;

    // VERKLAART DE GEGEVENS VAN DE OUTPUT
    openbare $latitude;
    openbare $longitude;
    openbare $precision;
    openbare $warning;
    openbare $geocoder;

    // VERKLAART DE AANNEMER
    overheidsfunctie __construct ()
    {
        $this->latitude  = 0.0;
        $this->longitude = 0.0;
        $this->precision = VALS;  // WIL EEN HOGERE WAARDE VAN 5 OF HOGER, IS BETER
        $this->warning   = '';
        $this->geocoder  = '';
        unset ($this->precis);
    }

    // VERKLAART DE GEGEVEN-SCHOONMAAKBEURT
    privé functie _cleanup ($str)
    {
        $str = preg_replace („/[^ \“ a-zA-Z0-9&! #$% () „+:? \/@, _ \. \ -]/', '', $str);
        terugkeer versiering (preg_replace („/\ s \ s+/“, '', $str));
    }

    // VERKLAART YAHOO! VERSIE VAN HET WERKPAARD
    openbare functiegeocodeYahoo ()
    {
        als (! bepaald („YAHOO_API“)) bepaal („YAHOO_API“, „YAHOO_API“);
        $this->geocoder = „Yahoo! “;
        $yahooUrl       = „http://local.yahooapis.com/MapsService/V1/geocode?&appid=“. YAHOO_API;

        // U OM EEN VRAAG KUNT VRAGEN FREEFORM
        als ($this->location! = '')
        {
            $yahooUrl. = „&location=“. urlencode ($this->_cleanup ($this->location));
        }

        // U OM INDIVIDUELE STUKKEN VAN EEN ADRES KUNT VRAGEN
        anders
        {   $yahooUrl. = „&street=“. urlencode ($this->_cleanup ($this->address));
            $yahooUrl. = „&city=“   . urlencode ($this->_cleanup ($this->city));
            $yahooUrl. = „&state=“  . urlencode ($this->_cleanup ($this->state));
            $yahooUrl. = „&zip=“    . urlencode ($this->_cleanup ($this->zip));
        }

        // VOERT VRAAG YAHOO UIT GEOCODER
        // NOTA - DE AFSCHAFFING VAN DE FOUT VAN HET GEBRUIK OF ZAL HET UIT DE SLEUTEL VAN YAHOO API ONTSCHORSEN - OVER HTTP 400 VAN DE WINST VAN DE MISLUKKING SLECHT VERZOEK
        als ($yfp = @fopen ($yahooUrl, „r“))
        {
            $yahooResponse = '';
            terwijl (! feof ($yfp))
            {
                $yahooResponse. = fgets ($yfp);
            }
            fclose ($yfp);
        }
        anders
        {
            VALSE terugkeer;
        }

        // ONDERZOEKT HET RESULTAAT
        als ($yahooResponse! = '') NIET LEEG //, KREGEN WIJ GEGEVENS
        {
            $ydata    = nieuwe SimpleXMLElement ($yahooResponse);

            // DE CONTROLE VOOR OM HET EVEN WELKE FOUTENMELDING, ALS NIETS, HAALT DE PUNTEN VAN GEGEVENS
            $yerror    = $ydata->Message;
            als ($yerror == '')
            {
                $this->precis    = (koord) $ydata->Result [„precisie“];
                $this->warning   = (koord) $ydata->Result [„waarschuwing“];
                $this->latitude  = (koord) $ydata->Result->Latitude;
                $this->longitude = (koord) $ydata->Result->Longitude;

                // DEZE VERKLARINGEN AAN TERUGKEER GENORMALISEERD ADRES KUNNEN WORDEN GEBRUIKT
                $this->address   = (koord) $ydata->Result->Address;
                $this->city      = (koord) $ydata->Result->City;
                $this->state     = (koord) $ydata->Result->State;
                $this->zip       = (koord) $ydata->Result->Zip;

                // PRECISIE WORDT GEPLAATST AAN EEN WAARDE DIE VAN HET AANTAL
                als ($this->precis == „pit“)     {$this->precision = „5“; }
                als ($this->precis == „straat“)  {$this->precision = „6“; }
                als ($this->precis == „adres“) {$this->precision = „8“; }
            }
            anders
            {
                VALSE terugkeer;
            }
        }

        // GEEN RESULTAAT - IETS IS ZIEK BIJ YAHOO
        anders
        {
            VALSE terugkeer;
        }

        WARE terugkeer;
    } // de functiegeocodeYahoo van het EIND


    // VERKLAART DE VERSIE GOOGLE VAN HET WERKPAARD
    overheidsfunctie geocodeGoogle ()
    {
        als (! bepaald („GOOGLE_API“)) bepaal („GOOGLE_API“, „GOOGLE_API“);
        $this->geocoder = „Google“;
        $googleUrl      = „http://maps.google.com/maps/geo?key=“. GOOGLE_API. „&output=csv“;
        als ($this->location! = '') // U OM EEN VRAAG KUNT VRAGEN FREEFORM
        {
            $googleUrl. = „&q=“. urlencode ($this->_cleanup ($this->location));
        }
        ANDERS // U OM INDIVIDUELE STUKKEN VAN EEN ADRES KUNT VRAGEN
        {
            $googleUrl. = „&q=“. urlencode (versiering (
                    $this->_cleanup ($this->address)
            . ''. $this->_cleanup ($this->city)
            . ''. $this->_cleanup ($this->state)
            . ''. $this->_cleanup ($this->zip)
            ));
        }

        // VOERT VRAAG GOOGLE UIT GEOCODER
        als ($gfp = @fopen ($googleUrl, „r“))
        {
            $googleResponse = '';
            terwijl (! feof ($gfp))
            {
                $googleResponse. = fgets ($gfp);
            }
            fclose ($gfp);
        }
        anders
        {
            VALSE terugkeer;
        }

        // UITTREKSEL DE GEGEVENS VAN HET KOORD CSV
        $gdata    = explodeer („,“, $googleResponse);
        als ($gdata [0]! = „200“) // DE CODE VAN DE REACTIE „200“ MOETEN ZOU ZIJN -- ALS 602 - SLECHTE POSTCODE OF ONBRUIKBAAR ADRES
        {
            VALSE terugkeer;
        }
        $this->precision = $gdata [1]; // GEOCODE NAUWKEURIGHEID - DE POSTCODE = 5, HOGERE AANTALLEN IS BETER
        $this->latitude  = $gdata [2];
        $this->longitude = $gdata [3];
        WARE terugkeer;
    } // de functie van het EIND geocodeGoogle

} // de klasse SimpleGeocoder van het EIND



// NIET VERWANTE FUNCTIE OM DE OUTPUT TE MAKEN DE OPENBARE SLECHTS INFORMATIE TONEN
functie print_rr ($thing)
{
    $str = print_r (WARE $thing,);
    $arr = explodeer (PHP_EOL, $str);
    $num = tel ($arr) - 1;
    foreach ($arr als $ptr => $txt)
    {
        als (preg_match („/: privé]/“, $txt))
        {
            unset ($arr [$ptr]);
        }
    }
    de echo implodeert (PHP_EOL, $arr);
}
Andere oplossingen  
 
programming4us programming4us