This is a collection of location based functions that can get a users location based on their ip address using the IPInfoDB api, return advanced details on a specific location with the Yahoo PlaceFinder api, or dynamically create maps (as images or with javascript) using the Google Maps api.
IP Location
This function interacts with the IPInfoDB.com API to get a users location based on their IP address. It can return city, state, country, latitude & longitude and is accurate within a 25 mile radius. This function accepts an IP Address and returns an array of location based values.
$location = $location->ip ($_SERVER['REMOTE_ADDR']); // Values returned $location['country']; $location['country_code']; $location['state']; $location['city']; $location['post_code']; $location['latitude']; $location['longitude'];
Your IP Based Location
Country: United States
Country Code: US
State: Washington
City: Kirkland
Post Code:
Latitude: 47.6966
Longitude: -122.197
On the map
See below on how to generate maps
Place Finder
This function uses the Yahoo PlaceFinder API to get detailed information about a specific location. This is the way to go if you want to get more detailed information or find a more exact location. It accepts a textual location (zip code, city/state, street address, latitude/longitude, etc) and returns an array of location based values.
$info = $location->info ('400 Broad St Seattle, WA 98109'); // Values returned $info['country']; $info['country_code']; $info['state']; $info['state_code']; $info['county']; $info['city']; $info['post_code']; $info['cross_street']; $info['house']; $info['street']; $info['radius']; $info['quality']; $info['woeid']; $info['latitude']; $info['longitude'];
Country: United States
Country Code: US
State: Washington
State Code: WA
County: King County
City: Seattle
Post Code: 98109
Cross Street: Near the intersection of Broad St and John St
House: 400
Street: Broad St
Radius: 500
Quality: 87
Where on Earth ID: 12798953
Latitude: 47.619859
Longitude: -122.348749
Google Maps
Use this to automatically generate Google Maps for a specific location. This function accepts a number of parameters:
- 1. location (required. options: latitude and longitude)
- 2. format (options: javascript, jpg, jpg-baseline, png, png32, gif))
- 3. map type (options: roadmap, hybrid, satellite, terrain)
- 4. width (options: value in px or %)
- 5. height (options: value in px or %)
- 6. zoom level (options: number between 1 and 21)
- 7. id (options: any valid css id)
Example 1 (Javascript)
The first example uses javascript to generate a dynamic map. To generate a map with javascript you’ll need to pass both the latitude and longitude coordinates to the location parameter (the latidude and longitude can be retreived with either the ip location or place finder functions descriped above). The map is injected into a div with an id of “map_canvas” by default (whose height/width can be modified via css). If you want to set the width & height with css instead of via the function, pass “css” to both the width and height parameters.
$coordinates = $info['latitude'].','.$info['longitude']; echo $location->map($coordinates, 'javascript', 'hybrid', '100%', '300px', '16', 'map_1');
Results…
Google Maps (Image)
Currently the map function in only able to add one javascript map per page. If you need multiple maps (or just want to generate an image instead) simply set the second parameter to the type of image you want returned (jpg, jpg-baseline, png, png32 or gif). You can set the dimensions to anything you like, but Google’s maximum allowed image size is 630 by 630 pixels. A few examples of different image settings follow…
echo $location->map($coordinates, 'png32', 'roadmap', '630px', '630px', '11', 'map_2');
echo $location->map($coordinates, 'jpg', 'satellite', '630px', '200px', '7', 'map_3');
echo $location->map($coordinates, 'gif', 'terrain', '200px', '200px', '5', 'map_4');
echo $location->map($coordinates, 'png', 'satellite', '630px', '200px', '1', 'map_5');
More Files From the PHP Plugin Suite
[eltd_button size=”huge-full-width” type=”outline” text=”Download & Demo Links” custom_class=”#” icon_pack=”font_awesome” fa_icon=”” link=”” target=”_blank” color=”” hover_color=”” background_color=”” hover_background_color=”” border_color=”” hover_border_color=”” font_size=”” font_weight=”” margin=””]
Demo = PHP Map + Location Plugin
[eltd_button size=”huge” type=”” text=”Full Live Demo” custom_class=”” icon_pack=”font_awesome” fa_icon=”fa-laptop” link=”https://codecanyon.net/item/php-map-location-plugin/156763″ target=”_blank” color=”” hover_color=”” background_color=”” hover_background_color=”” border_color=”” hover_border_color=”” font_size=”” font_weight=”” margin=””]
Kindly Note: We update new contents like WordPress Themes, Plugins, PHP Scripts everyday. But remember that you should never use this items in a commercial website. All the contents posted here for development & testing purpose only. We’re not responsible for any damage, use at your own RISK! We highly recommend to buy PHP Map + Location Plugin from the The Developer ( sublantic ) website. Thank you.
Download = PHP Map + Location Plugin-[Updated].zip