Beginning Google Maps Applications with PHP and Ajax: From Novice to Professional
Jeffrey Sambells, Michael Purvis, Cameron Turner
Format: PDF / Kindle (mobi) / ePub
Until recently, building interactive web-based mapping applications has been a cumbersome affair. This changed when Google released its powerful Maps API. Beginning Google Maps Applications with PHP and Ajax was written to help you take advantage of this technology in your own endeavorswhether you’re an enthusiast playing for fun or a professional building for profit. This book covers version 2 of the API, including Google’s new Geocoding service.
Authors Jeffrey Sambells, Cameron Turner, and Michael Purvis get rolling with examples that require hardly any code at all, but you’ll quickly become acquainted with many facets of the Maps API. They demonstrate powerful methods for simultaneously plotting large data sets, creating your own map overlays, and harvesting and geocoding sets of addresses. You’ll see how to set up alternative tile sets and where to access imagery to use for them. The authors even show you how to build your own geocoder from scratch, for those high-volume batch jobs.
By tracking the movements of the map and retrieve the points based on the map’s viewable area, as you’ll see later in Chapter 7. To start, remove the reference to map_data.php from the head of your index.php file and create the retrieveMarkers.php file in Listing 3-7 on your server in the same directory as your HTML document. Listing 3-7. retrieveMarkers.php Script Used to Format and Retrieve the data.xml File
Commercial) and cross-referenced everything to weed out the inevitable errors in each set. This means that the Geocoder.ca service is quite possibly the most accurate information for Canada so far. (However, now that Google’s solution covers Canada with relatively good accuracy, we’re afraid that this extremely comprehensive service will become marginalized.) Geocoder.ca provides a lot of neat features like intersection geocoding, reverse geocoding, and a suggestion system for correcting mistyped.
Seen again, such as plotting the current position of a GPS device. To cache the data for your store locator map, you’ll modify the code in Listing 4-6 to create a script (Listing 4-13) that does a bulk geocoding of all of the stores and adds the latitude and longitude to the data file in Listing 4-14. In the next section, you’ll use this data file to make your map, and assume that the stores already have latitude and longitude values associated with them. Listing 4-13. Modified Code Showing.
IMPROVING THE USER INTERFACE Showing and Hiding Points The current implementation of initializePoint() (as of Listing 6-15) doesn’t provide any obvious mechanism for toggling the points on and off—it’s a one-way operation. This isn’t hard to fix, though. All you need to do is create a pair of functions for each point: one to show and the other to hide. As for where to store these functions, what better place than inside the original markers array itself? Listing 6-20 shows how we added the new.