-
Notifications
You must be signed in to change notification settings - Fork 1
Allows PHP developers to use Microsoft Bing Maps API to include Bing Maps in their web applications
License
mindtree/BingMapsPHPSDK
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
BING MAPS SDK FOR PHP README ======================= Welcome! This is the Bing Maps SDK for PHP, a library that allows you to use Bing's APIs to display and interact with Bing Maps in your own web application. A complete class hierarchy and reference is available in the docs directory in HTML format. Directory Structure =================== The following directories are included in the library: - lib Contains the actual source for the SDK - docs Contains the autogenerated HTML reference for the SDK's classes - tests Contains the unit tests for the SDK Class Inclusion =============== In order to use the SDK in your project, you need to copy the lib folder under your web project and include the following files in your project files: - lib/Msft/Bing/Exception.php - lib/Msft/Bing/Map/Map.php - lib/Msft/Bing/MySQLPersistenceHandler.php For example, if you web project is called 'bingsdktest', your folder structure should be bingsdktest |- test.php |- lib |- Msft |- Bing |- Exception.php |- IPersistenceHandler.php |- MySQLPersistenceHandler.php |- js |- addJsFiles.js |- jquery-1.2.6.js |- maps.js |- Map |- GetResults.php |- Map.php Usage ===== Code Example 1 ============== // File: test.php <?php $bingObj = new Msft_Bing_Map('myMap', $myBingMapID); ?> <html> <body> <input type="button" value="Display Map" onclick="<?php $bingObj->displayMap();?>"/> <div id="myMap"/> </body> </html> The Bing Maps SDK for PHP is designed to give PHP developers an object-oriented interface to access the Bing Maps API. The heart of the SDK is the Msft_Bing_Map class. It supports many methods for interacting with the Bing Maps API. The API docs give complete details on the methods and parameters. As you can see from the example above, using the SDK is as simple as defining a <div> element in your web application, instantiating the class and calling the displayMap() method. This method in turn will interact with the Bing Maps web service using Javascript and displays a live map inside the given <div> element. The second parameter passed into the constructor is your Bing Maps Key. Each application with which you use the SDK will need its own key. You can obtain a Bing Maps Key from Microsoft by going to the web page https://www.bingmapsportal.com/ Once you have it, store it in your configuration file somewhere and use it every time you connect to the Bing Maps API. Code Example 2 ============== // File: test.php <?php $bingObj = new Msft_Bing_Map('myMap', $myBingMapID); $props = new Msft_Bing_MapProperties('600','500','7'); $props->setDefaultLocation('Bangalore,India'); $bingObj->setProperties($props); ?> <html> <body> <input type="button" value="Display Map" onclick="<?php $bingObj->displayMap(); $bingObj->addPushpinAddress('Bangalore,India');?>"/> <div id="myMap"/> </body> </html> Code Example 2 demonstrates the use of addPushpinAddress() method to display a pushpin on the map. Code Example 3 ============== // File: test.php <?php $bingObj = new Msft_Bing_Map('myMap', $myBingMapID); $props = new Msft_Bing_MapProperties('600','500','7'); $props->setDefaultLocation('Bangalore,India'); $bingObj->setProperties($props); $handler = new Msft_Bing_MySQLPersistenceHandler($dbhost, $dbname, $dbuser, $dbpassword); $bingObj->registerPersistenceHandler($handler); $pin = new Msft_Bing_Pushpin(1, 'FirstPin', 'My Home', 'Bangalore,India'); ?> <html> <body> <input type="button" value="Display Map" onclick="<?php $bingObj->displayMap(); $bingObj->addPushpinPushpin($pin); $bingObj->savePushpins();?>"/> <div id="myMap" style="position:relative"/> </body> </html> Code Example 3 demonstrates the use of savePushpins() method to save pushpin details in a database. To save pushpin details and map properties into a database, users have to register a persistence handler using registerPersistenceHandler() method. The persistence handler should implement the interface Msft_Bing_IPersistenceHandler. The SDK includes a default persistence handler which uses MySQL as the backend database. License ======= This library is released free of charge under the terms of the GNU General Public License v2. A copy of the license is available in the LICENSE file, included in the distribution.
About
Allows PHP developers to use Microsoft Bing Maps API to include Bing Maps in their web applications
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published