The root file of SMap
The layered map view is not for the faint of heart. If you are new to this, expect to spend quite a bit of time going back and fourth trying to understand what is going on. Of course I've done my best to make things simple, but this is simply complicated by nature.
I'll attempt an overview:
I've tried to implement common functionality, but you'll need to extend classes. At a minimum, you need to extend SMap_Data, SMap_Form, SMap_Lang, and SMap_Geo to define the characteristics of your map. You will most likely extend varients of SMap_Object and SMap_Layer to draw out your map.
The calling structure is to create instances of your custom classes, and pass them to the constructor of SMap. Once you have an instance of SMap, you call SMap::addView() to add your view to the map. Each view can be thought of as a drawing window. By default, they are linked to move and zoom together. So, you can display the same area with different layers showing.
The interesting work takes place within the layer. Layers are added to each view via SMap_View::addLayer(). When the time comes, SMap_Layer::getImgObjs() or SMap_Layer::getMapObjs() will be called. The layer will construct, organize, and return a set of objects appropriate for the view and bounds. The objects will draw your info.
SMap_Object handles the brunt work of translating from whatever your layer wants to the canvas. Because these are primitives, you may or may not need to extend them.
Returning to our instance of SMap, we have now set up our map structure. SMap takes over the hard part from here. Layers have been turned on or off and other changes may have been returned via SMap_Form. Those are collected and applied. Call SMap::getViewXHTML() to get the XHTML to insert into the page. Or call SMap::dispTileImg() to generate the raw image to return to the browser. And you're done!
Ideas for source data:
SMap requires at least PHP version 5, but there are important bug fixes in more recent versions of PHP. Try to stay current.License:
Copyright (c) 2006-2007, Seth Price <seth@pricepages.org> All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.