├── readme.markdown └── releases ├── 2.5 ├── COPYING.lib ├── NEWS ├── README └── src │ └── GoogleMapAPI.class.php └── 3.0 ├── COPYING.lib └── src ├── GoogleMap.php └── JSMin.php /readme.markdown: -------------------------------------------------------------------------------- 1 | A fork of PHP Google Map API Class 2 | ================================== 3 | 4 | The original source: [http://code.google.com/p/php-google-map-api/](http://code.google.com/p/php-google-map-api/). If you don't know what this Class is about, then you are in the wrong place. You should visit [php-google-map-api](http://code.google.com/p/php-google-map-api/) to get up to speed. 5 | 6 | About 7 | ----- 8 | 9 | On a recent [project](http://culturedays.ca/en/celebration-schedule/by-region/british-columbia/map) we were using the PHP Google Map API Class. Very nice, very helpful. 10 | 11 | In any case, we needed some extra features. So, we added them (to the v3.0 class only!), and here's the code, which will hopefully help others. We will tell the maintainers of this project about these mods in the hope the changes can just be incorporated to the main project, but until then, here it is. 12 | 13 | What was added 14 | -------------- 15 | 16 | * Locale support: Ability to specify what language of the Google Map API you would like 17 | * Support for setting up your MarkerClusterer cluster icons via the API. 18 | * Compatibility with infoOnClick, which we added to the MarkerClusterer JS Library (You will need our modified code for the MarkerClusterer if you would like to use that feature. See [http://github.com/plank/MarkerClusterer/](http://github.com/plank/MarkerClusterer/) for more info. ) 19 | 20 | Usage 21 | ----- 22 | 23 | Pretty straight-forward. See the original [php-google-map-api](http://code.google.com/p/php-google-map-api/) for all docs, examples and whatnot. 24 | 25 | ### re: Language ### 26 | 27 | 28 | To specify the Language, once you have a Map Object, just do 29 | 30 | //For french 31 | $MAP_OBJECT->locale = "fr" 32 | 33 | Before you start outputting any code. 34 | 35 | Check [here](http://code.google.com/apis/maps/faq.html#languagesupport) for a full list of locales 36 | 37 | ### re: MarkerClusterer Icons ### 38 | 39 | $MAP_OBJECT->setClusterImageOptions(array( 40 | 'imagePath' => 'http://www.example.com/my/icons/m', 41 | 'imageExtension' => 'png 42 | )); 43 | 44 | This will lead MarkerClusterer using images like http://www.example.com/my/icons/m1.png, http://www.example.com/my/icons/m2.png and so forth for each of your styles. If you don't use setClusterImageOptions, it will use the defaults setup in your markerclusterer.js 45 | 46 | ### re: MarkerClusterer - Info On Click ### 47 | 48 | Added 2 new parameters to GoogleMapAPI::setClusterOptions() 49 | 50 | Info On Click: Whether we show the InfoWindow Content for all the markers in the cluster on click. 51 | 52 | $infoOnClick: defaults to false. If you set this to "true" (yes, use a string - it gets output in JS) 53 | 54 | Info On Click Zoom: So, once you zoomed in @ this level or closer, it will overide zoomOnClick and instead display an infowindow with the info from all the markers. 55 | 56 | $infoOnClickZoom: The zoom threshold that infoOnClick will trigger if its turned on. 57 | 58 | Always worth just looking at the code, there's comments for all the changes that have been made. 59 | 60 | m. 61 | -------------------------------------------------------------------------------- /releases/2.5/COPYING.lib: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | -------------------------------------------------------------------------------- /releases/2.5/NEWS: -------------------------------------------------------------------------------- 1 | 2.5 2 | --- 3 | 4 | fix "from address" bug (Thomas Jackson, mohrt) 5 | 6 | 2.4 7 | --- 8 | 9 | fix a couple bugs with drawing the javascript map (drakos7,nmweb,mohrt) 10 | fix lat/lon decimal when locale uses a comma (mohrt, Rene Schmidt) 11 | fix javascript escapement errors (Greg Wilson, Jerome Combaz, mohrt) 12 | 13 | 2.3 14 | --- 15 | 16 | * fixed db_cache_insert table issue (ezar, mohrt) 17 | 18 | 2.2 19 | --- 20 | 21 | * add geoGetDistance() to compute distance between two coords 22 | using great circle distance formula (mohrt) 23 | * update Google lookup to use official Google geo API (mohrt) 24 | 25 | 2.1 26 | --- 27 | 28 | * fix adjustCenterCoords to cast values as floats (hemmeter, mohrt) 29 | * made GOOGLE default lookup service 30 | * added support for tabbed info windows: pass an array of title => html pairs as the $html argument 31 | to addMarker. Directions, if enabled, appear in the first tab. (clark) 32 | * minor bugfix: only zoom encompass if there are two or more markers (clark) 33 | * added print/getOnLoad() so you can set window onload dynamically (Vaughn Anderson) 34 | * add (dis/en)ableOverviewControl() features (Antonio Costa, monte) 35 | * add (dis/en)ableScaleControl() features (Antonio Costa, monte) 36 | * use first suggestion with "Did you mean" result from google lookups, avoid loops, add property $use_suggest (Angelo Conforti, monte) 37 | * make GEOCODES db table configurable (Angelo Conforti, monte) 38 | 39 | 2.0 40 | --- 41 | 42 | * converted map type constants to G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, 43 | for version 2 of Google Map api. 44 | * fixed up driving direction HTML, remove

, add

(John Schulz, monte) 45 | * Moved to version 2 of the Google Maps JS API. (clark) 46 | Now use the GMap2 class instead of GMap and GLatLng instead of 47 | GPoint (for lat/lon pairs) along with other minor changes. 48 | * zoom encompass loop replaced by a new official function, map.getBoundsZoomLevel(bds), 49 | which returns the appropriate zoom level for a given GBounds object. (clark) 50 | * Converted three sections of the getMapJS() function into their own functions: 51 | getAddMarkersJS(), getPolylineJS(), and getCreateMarkerJS(), so that they can be extended 52 | by subclasses. (clark) 53 | * fix zoom encompass fudge factor bug; now apply the fudge factor in 54 | getMapJS(), just before we zoom. (clark) 55 | * addMarkerByAddress and addPolyLineByAddress now call addMarkerByCoords 56 | and addPolyLineByCoords instead of duplicating the code (clark) 57 | * added setBoundsFudge() (clark) 58 | 59 | 1.7 60 | --- 61 | 62 | * fix compatability problem with older PHP 63 | (change print_r to serialize) (monte) 64 | * fix bug with sidebar index counter (monte) 65 | * make map direction html more configurable with css and js (monte) 66 | * added more error checking to google geocoord lookups (monte) 67 | * add fudge factor to zoom_encompass so markers 68 | are away from the edges (monte) 69 | 70 | 1.6 71 | --- 72 | 73 | * move driving dir output to property var (monte) 74 | * add
ids to driving dirs (monte) 75 | * fix problem with quotes in titles of driving dir (monte) 76 | * fix driving dir wrapping (monte) 77 | * fix problem with empty lat/lon values (monte) 78 | * move some js funcs around, test for map
tag (monte) 79 | * don't supply style tags to
if width and height empty (monte) 80 | * add js function show_info_window() (monte) 81 | * track points and markers in global js arrays (monte) 82 | * make the map js var global (monte) 83 | * fix bug with icon anchor positioning (monte) 84 | * add enableInfoWindow() and disableInfoWindow() (monte) 85 | * remove unused message_id (monte) 86 | 87 | 1.5 88 | --- 89 | 90 | * add setLookupService() to switch between geocode lookup services (monte) 91 | * add addMarkerIcon() for setting icons for individual map markers (Clark Freifeld) 92 | * add $zoom_encompass so default map zoom closely encompasses map markers (Clark 93 | Friefeld) 94 | * change markder defaults to more closely match google map defaults when none 95 | are given (Clark Freifeld) 96 | 97 | 1.4 98 | --- 99 | 100 | * split out URL fetching to its own method so it can be easily overridden (monte) 101 | * wrap
tags inside javascript for browser compatability (Jake Krohn, monte) 102 | * make HTML markers display properly in firefox 1.5 (Jake Krohn, monte) 103 | * fixed bug with sidebar disabled (monte) 104 | 105 | 1.3 106 | --- 107 | 108 | * remove debug print_r statement from geoGetCoords() function (monte) 109 | * fixed bug when setting map type and disabling map controls (John Francis Lee, monte) 110 | 111 | 1.2 112 | --- 113 | 114 | * added UTF-8 charset setting to tags to work with IE in all langs (KADO, monte) 115 | * fix issue with multiple lat/lon findings from yahoo (andig,monte) 116 | * add setMapType() function (Isidor128,monte) 117 | * allow double quotes in title/html of markers (monte) 118 | * allow width/height in either px or % (TGKnIght,monte) 119 | * add setZoomLevel() function (monte) 120 | 121 | 1.1 122 | --- 123 | 124 | * replaced GoogleMapAPI.class.php with GOOD version, 1.0 had incorrect file! 125 | 126 | 1.0 127 | --- 128 | 129 | initial release 130 | -------------------------------------------------------------------------------- /releases/2.5/README: -------------------------------------------------------------------------------- 1 | NAME: 2 | 3 | GoogleMapAPI - A library used for creating google maps. 4 | 5 | AUTHOR: 6 | Monte Ohrt 7 | 8 | LATEST VERSION: 9 | 2.5 - Sep 20th, 2007 10 | 11 | SYNOPSIS: 12 | 13 | setDSN('mysql://USER:PASS@localhost/GEOCODES'); 19 | // enter YOUR Google Map Key 20 | $map->setAPIKey('YOURGOOGLEMAPKEY'); 21 | 22 | // create some map markers 23 | $map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','PJ Pizza'); 24 | $map->addMarkerByAddress('826 P St Lincoln NE 68502','Old Chicago','Old Chicago'); 25 | $map->addMarkerByAddress('3457 Holdrege St Lincoln NE 68502',"Valentino's","Valentino's"); 26 | ?> 27 | 28 | 29 | 30 | 31 | printHeaderJS(); ?> 32 | printMapJS(); ?> 33 | 34 | 39 | 40 | 41 | 42 | 47 |
43 | printMap(); ?> 44 | 45 | printSidebar(); ?> 46 |
48 | 49 | 50 | 51 | 52 | 53 | OUTPUT: 54 | 55 | View the output of the above example here: 56 | 57 | http://www.phpinsider.com/php/code/GoogleMapAPI/demo/ 58 | 59 | 60 | DESCRIPTION: 61 | 62 | GoogleMapAPI - A library used for creating google maps using the 63 | Google Map public API. Features include multiple map markers, customizable 64 | icons, map directions built into info window, and sidebar generation. 65 | 66 | More information on the Google Map API can be found here: 67 | 68 | http://www.google.com/apis/maps/ 69 | 70 | 71 | DISCUSSION: 72 | ----------- 73 | 74 | Discussions are currently held in the Smarty add-on forum (although Smarty 75 | is not necessary to use GoogleMapAPI.) 76 | 77 | http://www.phpinsider.com/smarty-forum/viewforum.php?f=19 78 | 79 | 80 | BASE CLASS METHODS: 81 | ------------------- 82 | 83 | GoogleMapAPI($map_id = 'map', $app_id = 'MyMapApp') 84 | --------------------------------------------------- 85 | 86 | Class Constructor. 87 | The map id is needed only if you have multiple maps on the same page. 88 | The App ID is used for the Yahoo GeoCode API, if you use Yahoo for lookups. 89 | Use a unique App ID per application. 90 | 91 | Example: 92 | 93 | // use defaults 94 | $map = new GoogleMapAPI(); 95 | 96 | // set custom map id and app id 97 | $map = new GoogleMapAPI('mymap','myapp'); 98 | 99 | 100 | setDSN($dsn) 101 | ------------ 102 | 103 | Used to set the database DSN. The database is used to cache 104 | geocode lookups (highly recommended!) The PEAR::DB module 105 | is required for database access. You will need to create 106 | the following database schema (mysql example given): 107 | 108 | CREATE TABLE GEOCODES ( 109 | address varchar(255) NOT NULL default '', 110 | lon float default NULL, 111 | lat float default NULL, 112 | PRIMARY KEY (address) 113 | ); 114 | 115 | Example: 116 | 117 | $map->setDSN('mysql://DBUSER:DBPASS@DBHOST/DBNAME'); 118 | $map->setDSN('mysql://geo:foobar@localhost/GEOCODES'); 119 | 120 | 121 | setAPIKey($key) 122 | --------------- 123 | 124 | Sets the Google Map API Key. This is mandatory, you will need 125 | an API Key for your hostname! You can register free here: 126 | 127 | http://www.google.com/apis/maps/signup.html 128 | 129 | Example: 130 | 131 | // enter YOUR registered API Key 132 | $map->setAPIKey('ABQIAAAAxp5FF-A0RhHOnnTBwrlRbx'); 133 | 134 | 135 | setWidth($width) 136 | ---------------- 137 | 138 | Sets the width of the map window. This can be either px or %. 139 | Default is 500px. 140 | 141 | Example: 142 | 143 | $map->setWidth('500px'); 144 | $map->setWidth('100%'); 145 | 146 | 147 | setHeight($height) 148 | ------------------ 149 | 150 | Sets the height of the map window. This can be either px or %. 151 | Default is '500px'. 152 | 153 | Example: 154 | 155 | $map->setHeight('500px'); 156 | $map->setHeight('100%'); 157 | 158 | 159 | enableMapControls() 160 | ------------------- 161 | 162 | This will enable the map controls to zoom/move around the map. 163 | Enabled by default. 164 | 165 | 166 | disableMapControls() 167 | -------------------- 168 | 169 | This will disable the map controls to zoom/move around the map. 170 | Enabled by default. 171 | 172 | 173 | setZoomLevel() 174 | -------------- 175 | 176 | This sets the default map zoom level. 177 | 178 | Example: 179 | 180 | $map->setZoomLevel(4); 181 | 182 | 183 | setControlSize($size) 184 | --------------------- 185 | 186 | This sets the map control size. Relevant only if map controls are 187 | enabled. large = map zoom/move with slider. small = zoom/move without 188 | slider. Large is default. 189 | 190 | Example: 191 | 192 | $map->setControlSize = 'small'; 193 | 194 | 195 | enableTypeControls() 196 | -------------------- 197 | 198 | This will enable the map type controls (map/satellite/hybrid). 199 | Enabled by default. 200 | 201 | 202 | disableTypeControls() 203 | --------------------- 204 | 205 | This will disable the map type controls (map/satellite/hybrid). 206 | Enabled by default. 207 | 208 | 209 | setMapType($type) 210 | ----------------- 211 | 212 | This sets the default map type. Relevant only if map type controls are 213 | enabled. map = default map. satellite = satellite view. hybrid = hybrid 214 | view. 215 | 216 | Example: 217 | 218 | $map->setMapType('map'); // default 219 | $map->setMapType('satellite'); 220 | $map->setMapType('hybrid'); 221 | 222 | 223 | enableSidebar() 224 | --------------- 225 | 226 | This enables the map sidebar. Use printSideBar() or getSideBar() to 227 | output the sidebar text. Enabled by default. 228 | 229 | 230 | disableSidebar() 231 | ---------------- 232 | 233 | This disables the map sidebar. Enabled by default. 234 | 235 | 236 | enableDirections() 237 | ------------------ 238 | 239 | This enables map directions in the bottom of the pop-up info window. 240 | Enabled by default. 241 | 242 | 243 | disableDirections() 244 | ------------------- 245 | 246 | This disables map directions in the bottom of the pop-up info window. 247 | Enabled by default. 248 | 249 | enableZoomEncompass() 250 | --------------------- 251 | 252 | This enables zoom encompass so default map zoom is as small as possible 253 | and include all map markers. 254 | Enabled by Default. 255 | 256 | disableZoomEncompass() 257 | ---------------------- 258 | 259 | This disables zoom encompass. 260 | Enabled by Default. 261 | 262 | 263 | setBoundsFudge($val) 264 | -------------------- 265 | 266 | Set the map boundary fudge factor. This will adjust how much map 267 | boundary encompasses the map markers. (0.01 is default.) 268 | 269 | Example: 270 | 271 | $map->setBoundsFudge(0.01); 272 | 273 | 274 | setBrowserAlert($message) 275 | ------------------------- 276 | 277 | This sets the alert message that pops up when a browser is not 278 | compatible with the Google Map API. Default is: 279 | "Sorry, the Google Maps API is not compatible with this browser." 280 | 281 | 282 | setJSAlert($message) 283 | -------------------- 284 | 285 | This sets the alert message that displays when javascript is disabled. 286 | Default: "Javascript must be enabled in order to use Google Maps." 287 | 288 | 289 | enableOnLoad() 290 | -------------- 291 | 292 | This enables the onLoad() javascript function, which is used by default. 293 | This allows the map javascript to be put into the tag, 294 | then loaded upon page entry with either right 295 | in the body tag, or use printOnLoad() to place this elsewhere. With onLoad 296 | disabled, the map javascript must be embedded inside the 297 | tags. Using onLoad() is the best method to use for browser 298 | compatability. 299 | 300 | 301 | enableInfoWindow() 302 | ------------------ 303 | 304 | enables info windows on map markers. 305 | Enabled by default. 306 | 307 | 308 | disableInfoWindow() 309 | ------------------- 310 | 311 | disables info windows on map markers. 312 | Enabled by default. 313 | 314 | 315 | enableScaleControl() 316 | -------------------- 317 | 318 | enables the map scale. 319 | Enabled by default. 320 | 321 | 322 | disableScaleControl() 323 | --------------------- 324 | 325 | disables the map scale. 326 | Enabled by default. 327 | 328 | 329 | enableOverviewControl() 330 | ----------------------- 331 | 332 | enables the map overview. 333 | Disabled by default. 334 | 335 | 336 | disableOverviewControl() 337 | ------------------------ 338 | 339 | disable the map overview. 340 | Disabled by default. 341 | 342 | 343 | disableOnLoad() 344 | --------------- 345 | 346 | This disables the onLoad() javascript function. (see enableOnLoad()) 347 | Enabled by default. 348 | 349 | 350 | setInfoWindowTrigger($type) 351 | --------------------------- 352 | 353 | This sets the info window trigger behavior. click = info window comes up 354 | when clicking on a marker. mouseover = info window comes up when mousing 355 | over a marker. Default is click. 356 | 357 | Example: 358 | 359 | $map->setInfoWindowTrigger('mouseover'); 360 | 361 | 362 | addMarkerByAddress($address,$title = '',$html = '') 363 | --------------------------------------------------- 364 | 365 | This adds a marker to the map. The address must be a fully qualified 366 | address that can be used by the available geocode lookup services. 367 | 368 | To add markers with geocodes directly, see addMarkerByCoords(). 369 | 370 | The title is used for the sidebar navigation link. The html is used 371 | in the info window that pops up when you click on the map marker. If 372 | no html is provided, the title will be used. 373 | 374 | Note: map centering is done automatically as markers are added. 375 | 376 | Note: You can use tabbed windows by passing an array of 377 | title=>text values as the $html parameter. If driving directions 378 | are enabled, they show up under the first tab. 379 | 380 | Example: 381 | 382 | $map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','PJ Pizza'); 383 | 384 | 385 | addMarkerByCoords($lon,$lat,$title = '',$html = '') 386 | --------------------------------------------------- 387 | 388 | This adds a map marker by geocode (lon/lat) directly. See 389 | addMarkerByAddress() for more details. 390 | 391 | Example: 392 | 393 | $map->addMarkerByAddress(-96.6539,40.8191,'PJ Pizza','PJ Pizza'); 394 | 395 | 396 | 397 | addPolyLineByAddress($address1,$address2,$color,$weight,$opacity) 398 | ----------------------------------------------------------------- 399 | 400 | This adds a polyline between the two given addresses. You can optionally 401 | supply a color (in #ffffff hex notation), weight (thickness in pixels), 402 | and opacity (in percentage 0-100). 403 | 404 | Example: 405 | 406 | $map->addPolyLineByAddress( 407 | '3457 Holdrege St Lincoln NE 68502', 408 | '826 P St Lincoln NE 68502','#eeeeee',5,50); 409 | 410 | 411 | addPolyLineByCoords($lon1,$lat1,$lon2,$lat2,$color,$weight,$opacity) 412 | -------------------------------------------------------------------- 413 | 414 | This adds a polyline between the two given geocoordinate points. You can optionally 415 | supply a color (in #ffffff hex notation), weight (line thickness in pixels), 416 | and opacity (in percentage 0-100). 417 | 418 | Example: 419 | 420 | $map->addPolyLineByCoords(-96.67,40.8279,-96.7095,40.8149,'#eeeeee',5,50); 421 | 422 | 423 | adjustCenterCoords($lon,$lat) 424 | ----------------------------- 425 | 426 | This adjusts the map center coords by the given lon/lat. This is done 427 | automatically as you add markers to the map, or you can do it manually 428 | with this function. Note: this function is used internally by the 429 | library, it isn't normally necessary unless you have a specific need and 430 | you know what you are doing. 431 | 432 | 433 | setCenterCoords($lon,$lat) 434 | -------------------------- 435 | 436 | This sets the map center coords to the given lon/lat. Center coords are 437 | calculated automatically as you add markers to the map, or you reset it 438 | manually with this function. Note: this function is used internally by 439 | the library, it isn't normally necessary unless you have a specific need 440 | and you know what you are doing. 441 | 442 | 443 | setLookupService('GOOGLE') 444 | ------------------------- 445 | 446 | This sets the geocode lookup service. Default is GOOGLE, which uses the 447 | GOOGLE Geocode API. If you use the YAHOO Geocode API, be sure to set 448 | your application ID when instantiating GoogleMapAPI. NOTE: Yahoo API 449 | works only for US addresses (AFAIK). 450 | 451 | 452 | setMarkerIcon($iconImage,$iconShadowImage,$iconAnchorX,$iconAnchorY,$infoWindowAnchorX,$infoWindowAnchorY) 453 | ---------------------------------------------------------------------------------------------------------- 454 | 455 | This sets the icon image for ALL the map markers. Call this once. If you 456 | want to set a different icon for each marker, use addMarkerIcon() 457 | instead. 458 | 459 | You must supply a separate image for the icon and its shadow. 460 | iconAnchorX/Y is the X/Y coordinates of the icon for the map point. 461 | infoWindowAnchorX/Y is the X/Y coordinates of the icon where the info 462 | window connects. 463 | 464 | The iconImage and iconShadowImage can be either fully qualified URLs, or 465 | a relative path from your web server DOCUMENT_ROOT. These images MUST 466 | exist and readable so the library can calculate the dimensions. 467 | 468 | Example: 469 | 470 | $map->setMarkerIcon('/images/house.png','/images/house_shadow.png',0,0,10,10); 471 | 472 | 473 | addMarkerIcon($iconImage,$iconShadowImage,$iconAnchorX,$iconAnchorY,$infoWindowAnchorX,$infoWindowAnchorY) 474 | ---------------------------------------------------------------------------------------------------------- 475 | 476 | This sets the icon image for the CURRENT map marker. IMPORTANT: you MUST 477 | call addMarkerIcon() once for every marker. Do not use setMarkerIcon() 478 | if you use this function. 479 | 480 | You must supply a separate image for the icon and its shadow. 481 | iconAnchorX/Y is the X/Y coordinates of the icon for the map point. 482 | infoWindowAnchorX/Y is the X/Y coordinates of the icon where the info 483 | window connects. 484 | 485 | The iconImage and iconShadowImage can be either fully qualified URLs, or 486 | a relative path from your web server DOCUMENT_ROOT. These images MUST 487 | exist and readable so the library can calculate the dimensions. 488 | 489 | Example: 490 | 491 | $map->addMarkerIcon('/images/house.png','/images/house_shadow.png',0,0,10,10); 492 | 493 | 494 | printHeaderJS() 495 | --------------- 496 | 497 | This prints the header javascript that goes into the tags. 498 | To return the header javascript in a variable, use getHeaderJS(). 499 | 500 | Example: 501 | 502 | 503 | printHeaderJS(); ?> 504 | 505 | 506 | 507 | getHeaderJS() 508 | ------------- 509 | 510 | This returns the header javascript that goes into the tags. 511 | To print the header javascript directly, use printHeaderJS(). 512 | 513 | Example: 514 | 515 | 518 | 519 | 520 | 521 | 522 | 523 | printMapJS() 524 | ------------ 525 | 526 | This prints the map javascript. If onLoad() is enabled, put this in the 527 | tags, and supply in the body tag 528 | (or use printOnLoad()). 529 | 530 | Otherwise, put this just before the tag to make it load 531 | automatically. Note that using onLoad() is recommended over this method. 532 | 533 | To return the map javascript in a variable, use getMapJS(). 534 | 535 | Example: 536 | 537 | 538 | printMapJS(); ?> 539 | 540 | 541 | 542 | getMapJS() 543 | ---------- 544 | 545 | This returns the map javascript that goes into the tags. 546 | To print the map javascript directly, use printMapJS(). 547 | 548 | Example: 549 | 550 | printMapJS(); 552 | ?> 553 | 554 | 555 | 556 | 557 | 558 | printOnLoad() 559 | ------------- 560 | 561 | This prints the onLoad() javascript call. This is an alternate to 562 | using in the body tag. You can place 563 | this anywhere in the html body. 564 | 565 | To return the onLoad() javascript in a variable, use getOnLoad(). 566 | 567 | Example: 568 | 569 | 570 | printMapJS(); ?> 571 | 572 | 573 | printMap(); ?> 574 | printOnLoad(); ?> 575 | 576 | 577 | 578 | getOnLoad() 579 | ----------- 580 | 581 | This returns the map javascript that goes into the tags. 582 | To print the map javascript directly, use printMapJS(). 583 | 584 | Example: 585 | 586 | getOnLoad(); 588 | $mapjs = $map->getMapJS(); 589 | $map = $map->getMap(); 590 | ?> 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | printMap() 602 | ---------- 603 | 604 | This prints the map html. 605 | To return the map html in a variable, use getMap(). 606 | 607 | Example: 608 | 609 | 610 | printMapJS(); ?> 611 | 612 | 613 | printMap(); ?> 614 | 615 | 616 | Example 2 (using printOnLoad): 617 | 618 | 619 | printMapJS(); ?> 620 | 621 | 622 | printMap(); ?> 623 | printOnLoad(); ?> 624 | 625 | 626 | 627 | 628 | getMap() 629 | -------- 630 | 631 | This returns the map html in a variable. 632 | To print the map html directly, use printMap(). 633 | 634 | Example: 635 | 636 | getMap(); 638 | ?> 639 | 640 | 641 | 642 | 643 | 644 | printSidebar() 645 | -------------- 646 | 647 | This prints the sidebar html. 648 | To return the sidebar html in a variable, use getSidebar(). 649 | 650 | Example: 651 | 652 | 653 | 654 | 655 | 658 | 661 | 662 |
656 | printMap(); ?> 657 | 659 | printSidebar(); ?> 660 |
663 | 664 | 665 | 666 | getSidebar() 667 | ------------ 668 | 669 | This returns the sidebar html in a variable. 670 | To print the sidbar html directly, use printSidebar(). 671 | 672 | Example: 673 | 674 | getMap(); 676 | $sidebar = $map->getSidebar(); 677 | ?> 678 | 679 | 680 | 681 | 684 | 687 | 688 |
682 | 683 | 685 | 686 |
689 | 690 | 691 | 692 | getGeocode($address) 693 | -------------------- 694 | 695 | This looks up the geocode of an address. It will use the database cache 696 | if available. If you want to lookup a geocode without using the database 697 | cache, use geoGetCoords(). Note: this function is used internally by the 698 | library, it isn't normally necessary unless you have a specific need and 699 | you know what you are doing. 700 | 701 | Example: 702 | 703 | $geocode = $map->getGeocode('237 S 70th suite 220 Lincoln NE 68510'); 704 | 705 | echo $geocode['lat']; 706 | echo $geocode['lon']; 707 | 708 | 709 | getCache($address) 710 | ------------------ 711 | 712 | This will get the cached geocode info for an address from the database 713 | cache, or return FALSE if nothing is available. Note: this function is 714 | used internally by the library, it isn't normally necessary unless you 715 | have a specific need and you know what you are doing. 716 | 717 | Example: 718 | 719 | $geocode = $map->getCache('237 S 70th suite 220 Lincoln NE 68510'); 720 | 721 | echo $geocode['lat']; 722 | echo $geocode['lon']; 723 | 724 | 725 | putCache($address,$lon,$lat) 726 | ---------------------------- 727 | 728 | This will insert geocode info for the given address into the database 729 | cache. Note: this function is used internally by the library, it isn't 730 | normally necessary unless you have a specific need and you know what you 731 | are doing. 732 | 733 | Example: 734 | 735 | $map->putCache('237 S 70th suite 220 Lincoln NE 68510',-96.62538,40.812438); 736 | 737 | 738 | geoGetCoords($address) 739 | ---------------------- 740 | 741 | This looks up the geocode of an address directly (not from cache.) Note: 742 | this function is used internally by the library, it isn't normally 743 | necessary unless you have a specific need and you know what you are 744 | doing. 745 | 746 | Example: 747 | 748 | $geocode = $map->geoGetCoords('237 S 70th suite 220 Lincoln NE 68510'); 749 | 750 | echo $geocode['lon']; 751 | echo $geocode['lat']; 752 | 753 | geoGetDistance($lat1,$lon1,$lat2,$lon2,$unit) 754 | --------------------------------------------- 755 | 756 | This gets the distance between too coordinate points using the great 757 | circle formula. $unit can be M (miles),K (kilometers),N (nautical 758 | miles),I (inches), or F (feet). Default is M. 759 | 760 | Example: 761 | 762 | $distance = $map->geoGetDistance($lat1,$lon1,$lat2,$lon2,$unit); 763 | 764 | 765 | 766 | INTEGRATING GOOGLE MAPS WITH SMARTY TEMPLATES 767 | --------------------------------------------- 768 | 769 | Integrating with Smarty is as simple as assigning the necessary vars to the 770 | template and then displaying them. Note: This example does not cover how to 771 | setup Smarty, please use the Smarty documentation. 772 | 773 | Example: 774 | 775 | setDSN('mysql://USER:PASS@localhost/GEOCODES'); 784 | // enter YOUR Google Map Key 785 | $map->setAPIKey('YOURGOOGLEMAPKEY'); 786 | 787 | // create some map markers 788 | $map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','PJ Pizza'); 789 | $map->addMarkerByAddress('826 P St Lincoln NE 68502','Old Chicago','Old Chicago'); 790 | $map->addMarkerByAddress('3457 Holdrege St Lincoln NE 68502',"Valentino's","Valentino's"); 791 | 792 | // assign Smarty variables; 793 | 794 | $smarty->assign('google_map_header',$map->getHeaderJS()); 795 | $smarty->assign('google_map_js',$map->getMapJS()); 796 | $smarty->assign('google_map_sidebar',$map->getSidebar()); 797 | $smarty->assign('google_map',$map->getMap()); 798 | 799 | // display the template 800 | $smarty->display('index.tpl'); 801 | ?> 802 | 803 | contents of index.tpl: 804 | ---------------------- 805 | 806 | 807 | 808 | 809 | {$google_map_header} 810 | {$google_map_js} 811 | 812 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 |
{$google_map}{$google_map_sidebar}
825 | 826 | 827 | 828 | 829 | CREDITS: 830 | -------- 831 | 832 | Excellent Google Maps tutorials by Mike: 833 | http://www.econym.demon.co.uk/googlemaps/index.htm 834 | 835 | People who have helped/contributed: 836 | 837 | Charlie Dawes 838 | Jake Krohn 839 | Clark Freifeld 840 | Angelo Conforti 841 | Jerome Combaz 842 | drakos7 (from forums) 843 | nmweb (from forums) 844 | 845 | Anyone I missed, drop me a line! 846 | 847 | Monte Ohrt 848 | -------------------------------------------------------------------------------- /releases/2.5/src/GoogleMapAPI.class.php: -------------------------------------------------------------------------------- 1 | 28 | * @package GoogleMapAPI 29 | * @version 2.5 30 | */ 31 | 32 | /* $Id: GoogleMapAPI.class.php,v 1.63 2007/08/03 16:29:40 mohrt Exp $ */ 33 | 34 | /* 35 | 36 | For best results with GoogleMaps, use XHTML compliant web pages with this header: 37 | 38 | 39 | 40 | 41 | For database caching, you will want to use this schema: 42 | 43 | CREATE TABLE GEOCODES ( 44 | address varchar(255) NOT NULL default '', 45 | lon float default NULL, 46 | lat float default NULL, 47 | PRIMARY KEY (address) 48 | ); 49 | 50 | */ 51 | 52 | class GoogleMapAPI { 53 | 54 | /** 55 | * PEAR::DB DSN for geocode caching. example: 56 | * $dsn = 'mysql://user:pass@localhost/dbname'; 57 | * 58 | * @var string 59 | */ 60 | var $dsn = null; 61 | 62 | /** 63 | * YOUR GooglMap API KEY for your site. 64 | * (http://maps.google.com/apis/maps/signup.html) 65 | * 66 | * @var string 67 | */ 68 | var $api_key = ''; 69 | 70 | /** 71 | * current map id, set when you instantiate 72 | * the GoogleMapAPI object. 73 | * 74 | * @var string 75 | */ 76 | var $map_id = null; 77 | 78 | /** 79 | * sidebar
used along with this map. 80 | * 81 | * @var string 82 | */ 83 | var $sidebar_id = null; 84 | 85 | /** 86 | * GoogleMapAPI uses the Yahoo geocode lookup API. 87 | * This is the application ID for YOUR application. 88 | * This is set upon instantiating the GoogleMapAPI object. 89 | * (http://developer.yahoo.net/faq/index.html#appid) 90 | * 91 | * @var string 92 | */ 93 | var $app_id = null; 94 | 95 | /** 96 | * use onLoad() to load the map javascript. 97 | * if enabled, be sure to include on your webpage: 98 | * 99 | * 100 | * @var string 101 | */ 102 | var $onload = true; 103 | 104 | /** 105 | * map center latitude (horizontal) 106 | * calculated automatically as markers 107 | * are added to the map. 108 | * 109 | * @var float 110 | */ 111 | var $center_lat = null; 112 | 113 | /** 114 | * map center longitude (vertical) 115 | * calculated automatically as markers 116 | * are added to the map. 117 | * 118 | * @var float 119 | */ 120 | var $center_lon = null; 121 | 122 | /** 123 | * enables map controls (zoom/move/center) 124 | * 125 | * @var boolean 126 | */ 127 | var $map_controls = true; 128 | 129 | /** 130 | * determines the map control type 131 | * small -> show move/center controls 132 | * large -> show move/center/zoom controls 133 | * 134 | * @var string 135 | */ 136 | var $control_size = 'large'; 137 | 138 | /** 139 | * enables map type controls (map/satellite/hybrid) 140 | * 141 | * @var boolean 142 | */ 143 | var $type_controls = true; 144 | 145 | /** 146 | * default map type (G_NORMAL_MAP/G_SATELLITE_MAP/G_HYBRID_MAP) 147 | * 148 | * @var boolean 149 | */ 150 | var $map_type = 'G_NORMAL_MAP'; 151 | 152 | /** 153 | * enables scale map control 154 | * 155 | * @var boolean 156 | */ 157 | var $scale_control = true; 158 | 159 | /** 160 | * enables overview map control 161 | * 162 | * @var boolean 163 | */ 164 | var $overview_control = false; 165 | 166 | /** 167 | * determines the default zoom level 168 | * 169 | * @var integer 170 | */ 171 | var $zoom = 16; 172 | 173 | /** 174 | * determines the map width 175 | * 176 | * @var integer 177 | */ 178 | var $width = '500px'; 179 | 180 | /** 181 | * determines the map height 182 | * 183 | * @var integer 184 | */ 185 | var $height = '500px'; 186 | 187 | /** 188 | * message that pops up when the browser is incompatible with Google Maps. 189 | * set to empty string to disable. 190 | * 191 | * @var integer 192 | */ 193 | var $browser_alert = 'Sorry, the Google Maps API is not compatible with this browser.'; 194 | 195 | /** 196 | * message that appears when javascript is disabled. 197 | * set to empty string to disable. 198 | * 199 | * @var string 200 | */ 201 | var $js_alert = 'Javascript must be enabled in order to use Google Maps.'; 202 | 203 | /** 204 | * determines if sidebar is enabled 205 | * 206 | * @var boolean 207 | */ 208 | var $sidebar = true; 209 | 210 | /** 211 | * determines if to/from directions are included inside info window 212 | * 213 | * @var boolean 214 | */ 215 | var $directions = true; 216 | 217 | /** 218 | * determines if map markers bring up an info window 219 | * 220 | * @var boolean 221 | */ 222 | var $info_window = true; 223 | 224 | /** 225 | * determines if info window appears with a click or mouseover 226 | * 227 | * @var string click/mouseover 228 | */ 229 | var $window_trigger = 'click'; 230 | 231 | /** 232 | * what server geocode lookups come from 233 | * 234 | * available: YAHOO Yahoo! API. US geocode lookups only. 235 | * GOOGLE Google Maps. This can do international lookups, 236 | * but not an official API service so no guarantees. 237 | * Note: GOOGLE is the default lookup service, please read 238 | * the Yahoo! terms of service before using their API. 239 | * 240 | * @var string service name 241 | */ 242 | var $lookup_service = 'GOOGLE'; 243 | var $lookup_server = array('GOOGLE' => 'maps.google.com', 'YAHOO' => 'api.local.yahoo.com'); 244 | 245 | var $driving_dir_text = array( 246 | 'dir_to' => 'Start address: (include addr, city st/region)', 247 | 'to_button_value' => 'Get Directions', 248 | 'to_button_type' => 'submit', 249 | 'dir_from' => 'End address: (include addr, city st/region)', 250 | 'from_button_value' => 'Get Directions', 251 | 'from_button_type' => 'submit', 252 | 'dir_text' => 'Directions: ', 253 | 'dir_tohere' => 'To here', 254 | 'dir_fromhere' => 'From here' 255 | ); 256 | 257 | 258 | /** 259 | * version number 260 | * 261 | * @var string 262 | */ 263 | var $_version = '2.5'; 264 | 265 | /** 266 | * list of added markers 267 | * 268 | * @var array 269 | */ 270 | var $_markers = array(); 271 | 272 | /** 273 | * maximum longitude of all markers 274 | * 275 | * @var float 276 | */ 277 | var $_max_lon = -1000000; 278 | 279 | /** 280 | * minimum longitude of all markers 281 | * 282 | * @var float 283 | */ 284 | var $_min_lon = 1000000; 285 | 286 | /** 287 | * max latitude 288 | * 289 | * @var float 290 | */ 291 | var $_max_lat = -1000000; 292 | 293 | /** 294 | * min latitude 295 | * 296 | * @var float 297 | */ 298 | var $_min_lat = 1000000; 299 | 300 | /** 301 | * determines if we should zoom to minimum level (above this->zoom value) that will encompass all markers 302 | * 303 | * @var boolean 304 | */ 305 | var $zoom_encompass = true; 306 | 307 | /** 308 | * factor by which to fudge the boundaries so that when we zoom encompass, the markers aren't too close to the edge 309 | * 310 | * @var float 311 | */ 312 | var $bounds_fudge = 0.01; 313 | 314 | /** 315 | * use the first suggestion by a google lookup if exact match not found 316 | * 317 | * @var float 318 | */ 319 | var $use_suggest = false; 320 | 321 | 322 | /** 323 | * list of added polylines 324 | * 325 | * @var array 326 | */ 327 | var $_polylines = array(); 328 | 329 | /** 330 | * icon info array 331 | * 332 | * @var array 333 | */ 334 | var $_icons = array(); 335 | 336 | /** 337 | * database cache table name 338 | * 339 | * @var string 340 | */ 341 | var $_db_cache_table = 'GEOCODES'; 342 | 343 | 344 | /** 345 | * class constructor 346 | * 347 | * @param string $map_id the id for this map 348 | * @param string $app_id YOUR Yahoo App ID 349 | */ 350 | function GoogleMapAPI($map_id = 'map', $app_id = 'MyMapApp') { 351 | $this->map_id = $map_id; 352 | $this->sidebar_id = 'sidebar_' . $map_id; 353 | $this->app_id = $app_id; 354 | } 355 | 356 | /** 357 | * sets the PEAR::DB dsn 358 | * 359 | * @param string $dsn 360 | */ 361 | function setDSN($dsn) { 362 | $this->dsn = $dsn; 363 | } 364 | 365 | /** 366 | * sets YOUR Google Map API key 367 | * 368 | * @param string $key 369 | */ 370 | function setAPIKey($key) { 371 | $this->api_key = $key; 372 | } 373 | 374 | /** 375 | * sets the width of the map 376 | * 377 | * @param string $width 378 | */ 379 | function setWidth($width) { 380 | if(!preg_match('!^(\d+)(.*)$!',$width,$_match)) 381 | return false; 382 | 383 | $_width = $_match[1]; 384 | $_type = $_match[2]; 385 | if($_type == '%') 386 | $this->width = $_width . '%'; 387 | else 388 | $this->width = $_width . 'px'; 389 | 390 | return true; 391 | } 392 | 393 | /** 394 | * sets the height of the map 395 | * 396 | * @param string $height 397 | */ 398 | function setHeight($height) { 399 | if(!preg_match('!^(\d+)(.*)$!',$height,$_match)) 400 | return false; 401 | 402 | $_height = $_match[1]; 403 | $_type = $_match[2]; 404 | if($_type == '%') 405 | $this->height = $_height . '%'; 406 | else 407 | $this->height = $_height . 'px'; 408 | 409 | return true; 410 | } 411 | 412 | /** 413 | * sets the default map zoom level 414 | * 415 | * @param string $level 416 | */ 417 | function setZoomLevel($level) { 418 | $this->zoom = (int) $level; 419 | } 420 | 421 | /** 422 | * enables the map controls (zoom/move) 423 | * 424 | */ 425 | function enableMapControls() { 426 | $this->map_controls = true; 427 | } 428 | 429 | /** 430 | * disables the map controls (zoom/move) 431 | * 432 | */ 433 | function disableMapControls() { 434 | $this->map_controls = false; 435 | } 436 | 437 | /** 438 | * sets the map control size (large/small) 439 | * 440 | * @param string $size 441 | */ 442 | function setControlSize($size) { 443 | if(in_array($size,array('large','small'))) 444 | $this->control_size = $size; 445 | } 446 | 447 | /** 448 | * enables the type controls (map/satellite/hybrid) 449 | * 450 | */ 451 | function enableTypeControls() { 452 | $this->type_controls = true; 453 | } 454 | 455 | /** 456 | * disables the type controls (map/satellite/hybrid) 457 | * 458 | */ 459 | function disableTypeControls() { 460 | $this->type_controls = false; 461 | } 462 | 463 | /** 464 | * set default map type (map/satellite/hybrid) 465 | * 466 | */ 467 | function setMapType($type) { 468 | switch($type) { 469 | case 'hybrid': 470 | $this->map_type = 'G_HYBRID_MAP'; 471 | break; 472 | case 'satellite': 473 | $this->map_type = 'G_SATELLITE_MAP'; 474 | break; 475 | case 'map': 476 | default: 477 | $this->map_type = 'G_NORMAL_MAP'; 478 | break; 479 | } 480 | } 481 | 482 | /** 483 | * enables onload 484 | * 485 | */ 486 | function enableOnLoad() { 487 | $this->onload = true; 488 | } 489 | 490 | /** 491 | * disables onload 492 | * 493 | */ 494 | function disableOnLoad() { 495 | $this->onload = false; 496 | } 497 | 498 | /** 499 | * enables sidebar 500 | * 501 | */ 502 | function enableSidebar() { 503 | $this->sidebar = true; 504 | } 505 | 506 | /** 507 | * disables sidebar 508 | * 509 | */ 510 | function disableSidebar() { 511 | $this->sidebar = false; 512 | } 513 | 514 | /** 515 | * enables map directions inside info window 516 | * 517 | */ 518 | function enableDirections() { 519 | $this->directions = true; 520 | } 521 | 522 | /** 523 | * disables map directions inside info window 524 | * 525 | */ 526 | function disableDirections() { 527 | $this->directions = false; 528 | } 529 | 530 | /** 531 | * set browser alert message for incompatible browsers 532 | * 533 | * @params $message string 534 | */ 535 | function setBrowserAlert($message) { 536 | $this->browser_alert = $message; 537 | } 538 | 539 | /** 540 | * set