PHP - Mpdf And Google Static Maps Api
I finally got my kml to display through the static maps api thinking I could then display my map on the pdf I'm generating using mpdf. But, it is not displaying the image in the pdf. It works fine on a blank test page.
$kmlMap = "<img src=\"http://maps.googleapis.com/maps/api/staticmap?zoom=15&size=500x300&maptype=hybrid&path=color:0xff0000ff|weight:3|$correctedCoords \" /><br />";Any ideas on how I could make this work with mpdf? Similar TutorialsAccording to i upload my mpdf to my real host on internet and try to print pdf out but i got fail at code below: I dont't know why this code $mpdf = new \Mpdf\Mpdf(); cann't work it's print out only "01" echo "0"; require_once __DIR__ . '/vendor/autoload.php'; echo "1"; $mpdf = new \Mpdf\Mpdf(); echo "2"; $mpdf->WriteHTML('Hello World'); $mpdf->Output('filename.pdf');
I'm having trouble loading this kind of KML with PHP http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#RetrievingFeatures example <atom:entry xmlns='http://www.opengis.net/kml/2.2' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005'> <atom:id> http://maps.google.com/maps/feeds/features/userID/mapID/full/featureID</atom:id> <atom:published>2008-08-14T17:46:06.462Z</atom:published> <atom:updated>2008-08-14T18:12:31.589Z</atom:updated> <atom:category scheme='http://schemas.google.com/g/2005#kind' ..... it seems like the column in atom:entry, etc is causing this. $response = simplexml_load_string($response); print_r($response); the above just gives an empty SimpleXMLElement Object() Any ideas Hi guys Mods please move if this is the wrong place to ask. I have a google maps api added to my web site but i want to be able to position "pins" on the map to show all the the registered clubs in an area... eg the user searches dublin and all teh clubs pop up... My question is.. is there anyway to do this without needing the user to supply the long/lat.. ie can it be gotten automatically?? I really just want it to work off the addrees/area they supplied when they registered. thanks tt Hello! I am trying to find a way to assign the JSON value Google Map's API Returns when passed an address. I would search Google, but I am only a few month deep into PHP and really don't know what keywords to use. I really don't even know what a JSON is? Anyway, I found this article that explains how to query Google Maps with an address and have it return a GPS Location. When I tested it in my browser, the text appears. I just don't know what to use to take what the browser is displaying and assign in to an Object in a PHP page. This is the Google Maps Query: Code: [Select] http://maps.google.com/maps/geo?q="ADDRESS"&output=csv&oe=utf8 This my function where I want to use this: Code: [Select] //Querries Google Map's API with an address and assigns the returned GPS Location //to this Object public function build_me($this_address) { //Builds the query from the address array to send to the Goole Maps API $query = $this_address["Line1"].",".$this_address["Line2"].",". $this_address["City"].",".$this_address["State"].",".$this_address["Zip"]; //Location_Array = http://maps.google.com/maps/geo?q=$query&output=csv&oe=utf8 $this->latitude = //Location_Array['Something']; $this->longitude = //Location_Array['Something']; } This is the article that I am referring to: http://martinsikora.com/how-to-get-gps-coordinates-from-an-address My question is, how would I go about doing this? Are there any good tutorials on this? Thanks in advance for anyone pointing me in the right direction! Need help with this, has anyone does this before? Here is the tutorial I have been following: https://developers.google.com/maps/articles/phpsqlajax#outputxml The part I am on from the tutorial is where it says Checking that XML output works it is meant to display the data from the database but i just get a blank page, no data is shown from my database on the page? I just have a php file with the code from the tutorial. I am attempting to create a Map on my web page that will have the directions (which will be dynamically pulled from a database) however I have been unable to find a good tutorial on how to achieve this, also there doesn't seem to be any PHP classes available out there (for free anyway) to create this easily. Any suggestions? i have code that i found and modified slightly that pulls data from mysql and plots it on a google map. this works fine as is. what i want to do is change the pin colour depending on a value from mysql. the java is outside of the while loop and i can not get it to work from inside the loop. this line of code changes the pin colour var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/red.png", im crap with javascript and sorry if this is better in java forum. any help greatly appreciated Code: [Select] $dbcnx = mysql_connect ("$dbserver", "$dbuser", "$dbpass"); mysql_select_db("$dbname") or die(mysql_error()); ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google Map API V3 with markers</title> <style type="text/css"> body { font: normal 10pt Helvetica, Arial; } #map { width: 700px; height: 600px; border: 0px; padding: 0px; } </style> <script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script> <script type="text/javascript"> //Sample code written by August Li var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/red.png", new google.maps.Size(32, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 32)); var center = null; var map = null; var currentPopup; var bounds = new google.maps.LatLngBounds(); function addMarker(lat, lng, info) { var pt = new google.maps.LatLng(lat, lng); bounds.extend(pt); var marker = new google.maps.Marker({ position: pt, icon: icon, map: map }); var popup = new google.maps.InfoWindow({ content: info, maxWidth: 300 }); google.maps.event.addListener(marker, "click", function() { if (currentPopup != null) { currentPopup.close(); currentPopup = null; } popup.open(map, marker); currentPopup = popup; }); google.maps.event.addListener(popup, "closeclick", function() { map.panTo(center); currentPopup = null; }); } function initMap() { map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(0, 0), zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR }, navigationControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL } }); <?php $query = mysql_query("SELECT * FROM poi_example"); while ($row = mysql_fetch_array($query)){ $name=$row['name']; $lat=$row['lat']; $lon=$row['lon']; $desc=$row['desc']; echo ("addMarker($lat, $lon,'<b>$name</b><br/>$name');\n"); } ?> center = bounds.getCenter(); map.fitBounds(bounds); } </script> </head> <body onload="initMap()" style="margin:0px; border:0px; padding:0px;"> <div id="map"></div> </html> Hi all I am trying to get the lat and long properties from the googlemaps geocoding api. $xml=simplexml_load_file($url); if ($xml === false) { echo "Failed loading XML\n"; foreach(libxml_get_errors() as $error) { echo "\t", $error->message; } } else{ $path = $xml->xpath( "/GeocodeResponse/result/geometry/location"); $lat = $path->lat; $lng = $path->lng; echo $lat; echo $lng; $sql1 = "UPDATE tbl_clubs set lat='$lat',lng='$lng' where club_id =$id"; echo $sql1; $result1 = mysqli_query($dbConn,$sql1) or die($mysqli_error($dbConn)); } This is the XML I am using <GeocodeResponse> <status>OK</status> <result> <type>establishment</type> <type>point_of_interest</type> <type>stadium</type> <formatted_address>Aldridge Rd, Perry Barr, Birmingham B42 2ET, UK</formatted_address> <address_component> </address_component> <address_component> </address_component> <address_component> </address_component> <address_component> <long_name>West Midlands</long_name> <short_name>West Midlands</short_name> <type>administrative_area_level_2</type> <type>political</type> </address_component> <address_component> <long_name>England</long_name> <short_name>England</short_name> <type>administrative_area_level_1</type> <type>political</type> </address_component> <address_component> <long_name>United Kingdom</long_name> <short_name>GB</short_name> <type>country</type> <type>political</type> </address_component> <address_component> <long_name>B42 2ET</long_name> <short_name>B42 2ET</short_name> <type>postal_code</type> </address_component> <geometry> <location> <lat>52.5196698</lat> <lng>-1.8986236</lng> </location> <location_type>GEOMETRIC_CENTER</location_type> <viewport> <southwest> <lat>52.5183208</lat> <lng>-1.8999726</lng> </southwest> <northeast> <lat>52.5210188</lat> <lng>-1.8972746</lng> </northeast> </viewport> </geometry>
But I am getting the following response Notice: Trying to get property of non-object in /home/sites/1a/9/95f15f28a6/public_html/results/getLatLng.php on line 22 I am guessing my path is wrong, any guidance would be great Hi All, I have code to generate a route in google maps on my site. The code works great in Firefox but not in IE8. It works in IE8 if you just have just a start and finish only but whe you add a waypoint in the route does not show. Any ideas? Code: [Select] <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"> </script> <script type="text/javascript"> var directionDisplay; var geocoder; var directionsService = new google.maps.DirectionsService(); var latlng = new google.maps.LatLng(54.559322587438636, -4.1748046875); function load() { geocoder = new google.maps.Geocoder(); directionsDisplay = new google.maps.DirectionsRenderer(); var myOptions = { zoom: 6, mapTypeId: google.maps.MapTypeId.ROADMAP, center: latlng, mapTypeControl: true, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, position: google.maps.ControlPosition.TOP_RIGHT }, navigationControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.ZOOM_PAN, position: google.maps.ControlPosition.TOP_LEFT} }; var map = new google.maps.Map(document.getElementById('map'), myOptions); directionsDisplay.setMap(map); var directionRendererOptions ={ suppressMarkers: true, polylineOptions:{ strokeColor: "#FF0000", strokeOpacity: 1, strokeWeight: 3 } }; directionsDisplay.setOptions(directionRendererOptions); var start = '<?php echo $start; ?>'; var end = '<?php echo $end; ?>'; <?php if($via != null){ echo "var points = ["; foreach($via as $point){ if($point != ""){ echo "{location:"; echo " '".$point."'"; echo "},"; } } echo "];\n"; } ?> var request = { origin:start, waypoints: points, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); geocoder.geocode( { 'address': start}, function(results, status) { var routeStart = new google.maps.Marker({ map: map, position: results[0].geometry.location, icon: './images/motorcycling.png', shadow: './images/motorcycling.shadow.png' }); }); geocoder.geocode( { 'address': end}, function(results, status) { var routeEnd = new google.maps.Marker({ map: map, position: results[0].geometry.location, icon: './images/motorcyclingend.png', shadow: './images/motorcycling.shadow.png' }); }); <?php $adverts = mysql_query("SELECT * FROM adverts WHERE ad_area = '$county' AND ad_visible='1' "); while($ad_row = mysql_fetch_array($adverts)){ $position = $ad_row[ad_postcode]; $type = $ad_row[ad_type]; echo "var position".$ad_row[ad_id]." = '".$position."'\n"; $ad_id = $ad_row[ad_id]; $pics = mysql_query("SELECT * FROM photos WHERE ad_id = '$ad_id' AND main_pic = '1'"); $pic_row = mysql_fetch_array($pics); $pic_name = $pic_row[photo_name]; $pic_name = str_replace(' ', '%20', $pic_name); ?> geocoder.geocode( { 'address': position<?php echo $ad_row[ad_id]; ?>}, function(results, status) { var marker<?php echo $ad_row[ad_id]; ?> = new google.maps.Marker({ map: map, position: results[0].geometry.location, <?php if ($type == 'accommodation'){ echo "icon: 'images/hotel.png'\n"; }elseif($type == 'fooddrink'){ echo "icon: 'images/bar.png'\n"; }elseif($type == 'essentials'){ echo "icon: 'images/motorcycle.png'\n"; } ?> }); var content = "<p><\a style='color:black;' href='./advert.php?advert=<?php echo $ad_row[ad_id]; ?>'><?php echo $ad_row[ad_company]; ?><\/a></p><img src='./thumbs/<?php echo $pic_name; ?>' />"; var infowindow<?php echo $ad_row[ad_id]; ?> = new google.maps.InfoWindow({ content: content }); google.maps.event.addListener(marker<?php echo $ad_row[ad_id]; ?>, "click", function() { infowindow<?php echo $ad_row[ad_id]; ?>.open(map,marker<?php echo $ad_row[ad_id]; ?>); }); }); I am trying to use Google's map API to dynamically create new maps. For example, I would like to be able to make a replica of this page using PHP. I just don't see where in the API it allows you to add all this information, such as adding categories, details, pictures, videos, etc. I've been researching for quite a while, and can't seem to come up with something that is similar to what I'm trying to do. Here is a link I found that shows you how to create maps, but I still don't see how to add all the information that you could if you did it manually! http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#CreatingMaps It would be great if someone can point me in the right direction. Thanks! I'm not a new comer to web design, but to date all of my experience has been in content management based systems (Joomla, Wordpress etc...) I was recently approached by a client to add a page to his existing website and after some research I think that using Google Maps API would be the easiest way to implement what he needs. Basically he wants to have a map of the USA with an icon for each of his office locations. (There are about 70 across the states) Once clicked on, each of the locations will pop up with all the info for that office, and if there are any job openings there. I would like for it to be all in one page, dynamically changing as the user manipulates the map. I found the perfect example for this at ZipCar.com http://www.zipcar.com/nyc/find-cars Everything fits within one simple page, the user can zoom in and out, and all the pertinent information shows up with along the side without anything reloading. I was basically hoping someone could point me in the right direction as to the steps that would be needed to get this done. I don't want someone to hold my hand through the whole process, I'm just fairly new to PHP and HTML and wondering what all will be involved with completing a project like this. Consider my first born child yours for the person who can help me out with this... Hello all, I am a relative newbie, and have been recently trying to get to grips with the Google Maps v3 API. I'm hoping someone here will be kind enough to take pity and help me with some difficulty I am having. First, let me set the scene. I'm helping a friend develop a website for a hobby. It's a simple, PHP / MySQL based site which lists different establishments. There is a database of companies, which includes a name, address, long lats, etc. I have managed to write the SQL query to poll the database, and return a list of markers on a map of London: http://datanalyst.co.uk/dev/flmap/mapexample7a.php However, I am getting confused regarding the markers, it would seem like my code (which can be found below) is iterating through all of the companies, and then setting just one marker for all points? The code can be found at http://paste.bradleygill.com/index.php?paste_id=348277 I am hoping you can see what I'm doing here. The PHP script is printing HTML / JavaScript code to the page, which includes a foreach loop, which grabs the long lats and puts them into google.maps.LatLng I am just just struggling with the markers - and I cannot see where I've gone wrong! Thanks so much in advance for any help you can provide me! All the best, and Merry Christmas, Michael Hi there, So the below code is working for 1 entry, however there is 2 entries in the database which are different postcodes and I cannot get to show in Google Maps. When I do it without Mysql and just do it direct it works, but really want to do it from MYSQL - both postcodes are valid and tested as well.
<?php $sql4 = "SELECT * FROM MK_migration_details"; $result4 = $conn->query($sql4); ?> function initialize() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(40.768505,-111.853244); var myOptions = { mapTypeControl: false, fullscreenControlOptions: false, zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); <?php while($row4 = $result4->fetch_assoc()) { $mig_postcode = $row4["postcode"]; } echo 'addPostCode("'.$mig_postcode.'")'; ?> } I know the issue lies with the PHP / Mysql Loop and the Javascript element 'addpostcode' when I put into the loop does not work, but works for a single address outside the loop.
Really appreciate your help guys!
Thanks you This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=328756.0 Hi, I currently have a google map which shows a marker where the postcode is for a certain pub (converts postcodes to coords lat/long) I would like to loop through all my pubs in my database as place a marker for each on one map, I am uncertain of how to loop through and show each marker for each postcode either PHP or JavaScript. here is my code for a single pub / postcode: Code: [Select] <!doctype html> <?php include "../config.php"; $loggedIn = (isset($_COOKIE['loggedin']) && $_COOKIE['loggedin'] == 'true')?true:false; $PUBID = intval($_REQUEST['PUBID']); $PUB = mysql_query("SELECT * FROM pubs WHERE PUBID = '".$PUBID."'"); $pubdetails = mysql_fetch_array($PUB); ?> <html> <head> <meta charset="UTF-8" /> <title><?php echo $pubdetails['rsPubName']; ?>, <?php echo $pubdetails['rsTown']; ?>, <?php echo $pubdetails['rsCounty']; ?></title> <style type="text/css" media="screen">@import "jqtouch/jqtouch.min.css";</style> <style type="text/css" media="screen">@import "themes/jqt/theme.min.css";</style> <script src="jqtouch/jquery.1.3.2.min.js" type="text/javascript" charset="utf-8"></script> <script src="jqtouch/jqtouch.min.js" type="application/x-javascript" charset="utf-8"></script> <script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key=ABQIAAAAM17e4xGXwO4sBd_QYtRiSRQXB4T7UHWaz4zUQgLx9muJZW0c3hS8jRMJg733CHqOihn7BVfhZTkLiA" type="text/javascript"></script> <script type="text/javascript"> function initialize() { var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.G_NORMAL_MAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } </script> <script type="text/javascript" charset="utf-8"> var jQT = new $.jQTouch({ icon: 'jqtouch.png', addGlossToIcon: false, startupScreen: 'jqt_startup.png', statusBar: 'black', preloadImages: [ 'themes/jqt/img/back_button.png', 'themes/jqt/img/back_button_clicked.png', 'themes/jqt/img/button_clicked.png', 'themes/jqt/img/grayButton.png', 'themes/jqt/img/whiteButton.png', 'themes/jqt/img/loading.gif' ] }); </script> </head> <body onLoad="ukPostcodeTest(); return false"> <!-- TOWNS --> <div id="pub" class="current"> <div class="toolbar"> <h1>View Pub</h1> <a class="back" href="index.php" rel="external">Home</a> </div> <h2><?php echo $pubdetails['rsPubName']; ?></h2> <?php echo $pubdetails['rsAddress']; ?><br /> <?php echo $pubdetails['rsTown']; ?><br /> <?php echo $pubdetails['rsCounty']; ?><br /> <?php echo $pubdetails['rsPostCode']; ?><br /> <?php echo $pubdetails['Region']; ?><br /> <?php echo $pubdetails['rsTel']; ?><br /> <?php echo '<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.mypubspace.com/pub_info.php?PUBID='.$pubdetails['PUBID'].'&layout=box_count&show_faces=true&width=450&action=like&colorscheme=light&height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:60px; height:65px; float:right;" allowTransparency="true"></iframe>';?> <div id="map" style="width: 250px; height: 250px"></div> <form name="mapform" onsubmit="ukPostcodeTest(); return false" action="#"> <input id="search" type="hidden" value="<?php echo $pubdetails["rsPostCode"]; ?>" /> </form> <div id="message"></div> <noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b> However, it seems JavaScript is either disabled or not supported by your browser. To view Google Maps, enable JavaScript by changing your browser options, and then try again. </noscript> <script type="text/javascript"> //<![CDATA[ if (GBrowserIsCompatible()) { var map = new GMap(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(51.520593197675446,-0.19775390625),16); // ====== Is the search string a UK Postcode ====== function ukPostcodeTest() { var search = document.getElementById("search").value; // take a copy and convert to upper case var s = search.toUpperCase(); // Replace punctuation and whitepsace by a single space s = s.replace(/\W+/g, " "); // Remove and trailing leading spaces s = s.replace(/^ /, ""); s = s.replace(/ $/, ""); // Perform the check var match = s.match(/^[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2}$/); if (!match) { // Its not a UK Postcode, so perform a standard GClientGeocoder call on the original search string showAddress(search); } else { // It is a UK Postcode, so call GDirections on the reformatted search string showPostcode(s); } } // ====== Code for handling search strings that are not UK Postcodes ======= // ====== Use the GClientGeocoder in the normal way ====== // ====== Create a Client Geocoder ====== var geo = new GClientGeocoder(); // ====== Array for decoding the failure codes ====== var reasons=[]; reasons[G_GEO_SUCCESS] = "Success"; reasons[G_GEO_MISSING_ADDRESS] = "Missing Address: The address was either missing or had no value."; reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address: No corresponding geographic location could be found for the specified address."; reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address: The geocode for the given address cannot be returned due to legal or contractual reasons."; reasons[G_GEO_BAD_KEY] = "Bad Key: The API key is either invalid or does not match the domain for which it was given"; reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries: The daily geocoding quota for this site has been exceeded."; reasons[G_GEO_SERVER_ERROR] = "Server error: The geocoding request could not be successfully processed."; // ====== Geocoding ====== function showAddress(search) { // ====== Perform the Geocoding ====== geo.getLocations(search, function (result) { // If that was successful if (result.Status.code == G_GEO_SUCCESS) { // How many resuts were found document.getElementById("message").innerHTML = "Found " +result.Placemark.length +" results"; // Loop through the results, placing markers for (var i=0; i<result.Placemark.length; i++) { var p = result.Placemark[i].Point.coordinates; var marker = new GMarker(new GLatLng(p[1],p[0])); document.getElementById("message").innerHTML += "<br>"+(i+1)+": "+ result.Placemark[i].address + marker.getPoint(); map.addOverlay(marker); } // centre the map on the first result var p = result.Placemark[0].Point.coordinates; map.setCenter(new GLatLng(p[1],p[0]),14); } // ====== Decode the error status ====== else { var reason="Code "+result.Status.code; if (reasons[result.Status.code]) { reason = reasons[result.Status.code] } alert('Could not find "'+search+ '" ' + reason); } } ); } // ====== Create a Client Geocoder ====== var gdir = new GDirections(null); // ====== Using GDirections to process a UK postcode ====== function showPostcode(search) { // Call GDirections gdir.loadFromWaypoints([search,search],{getPolyline:true}); // Wait for the reply to come back GEvent.addListener(gdir,"load", function() { var poly = gdir.getPolyline(); var point = poly.getVertex(0); //document.getElementById("message").innerHTML = "Found a UK Postcode"; // Process the result var marker = new GMarker(point); //document.getElementById("message").innerHTML += "<br>" + search + " = " + point.toUrlValue(5); map.addOverlay(marker); // centre the map on the result map.setCenter(point,16); }); } } // display a warning if the browser was not compatible else { alert("Sorry, the Google Maps API is not compatible with this browser"); } // This Javascript is based on code provided by the // Community Church Javascript Team // http://www.bisphamchurch.org.uk/ // http://econym.org.uk/gmap/ //]]> </script> </div> </body> </html> I had bought a script from he php google maps and have been using the attached php script. It was working and than apparently stopped working with this error "602: Unable to Geocode this address" Can anyone tell me if there is another solution? Or if I can use another method besides $gmap->showLocation($cross,$town,$county$state); Thanks! Code: [Select] <?php require_once('gmap.php'); $gmap = new GMap(); $cross = $result['cross_streets']; $county = $result['county']; $town = $result['town']; $state = 'New York'; $gmap->showLocation($cross,$town,$county$state); ?> I have downloaded Post-Google-Maps plugin and it works great. But I would like to change the default latitude and longitude and can't figure out how. I have posted this question on their support site, but I haven't received an answer, and the site doesn't seem to be actively monitored. I'm hoping there is an easy solution, and that someone on this board can help me. The plugin contains two php pages. Here is the code from post-google-map.php. Code: [Select] <?php /* Plugin Name: Post Google Map Plugin URI: http://webdevstudios.com/support/wordpress-plugins/ Description: Plugin allows posts to be linked to specific addresses and coordinates and display plotted on a Google Map. Use shortcode [google-map] to display map directly in your post/page. Map shows plots for each post with filter options and preview when hovered. <a href="options-general.php?page=post-google-map/post-google-map.php">Plugin Settings</a> | Version: 1.5.1 Author: WebDevStudios.com Author URI: http://webdevstudios.com */ $gmp_version = "1.5.1"; //hook for adding admin menus add_action('admin_menu', 'gmp_menu'); //hook for adding a new address add_action('admin_menu', 'gmp_add_new_address'); //hook for post/page custom meta box add_action('admin_menu', 'gmp_meta_box_add'); //hook for add a map to the content add_filter('the_content', 'gmp_widget'); //hook for loading widget add_action('plugins_loaded', 'gmp_widget_init'); //save/update post/page address fields from meta box function gmp_add_new_address() { $gmp_submit = $_POST["gmp_submit"]; If (isset($gmp_submit) && !empty($gmp_submit) ) { post_meta_tags(); } } //add_action('edit_post', 'post_meta_tags'); //add_action('publish_post', 'post_meta_tags'); //add_action('save_post', 'post_meta_tags'); //add_action('edit_page_form', 'post_meta_tags'); function getWords($text, $limit) { $array = explode(" ", strip_tags($text), $limit+1); if (count($array) > $limit) { unset($array[$limit]); } return implode(" ", $array); } function gmp_widget_options() { //widget options form if ($_POST['gmp_form_submit']) { update_option('gmp_widget_title', esc_attr($_POST['gmp_widget_title']) ); } //load widget title $gmp_widget_title = get_option('gmp_widget_title'); ?> <div> <label for="cc_form_title"> <strong><?php _e('Title:'); ?></strong> </label> <input style="width: 100%; margin-bottom:1em;" id="gmp_widget_title" name="gmp_widget_title" type="text" value="<?php echo htmlspecialchars(stripslashes($gmp_widget_title)); ?>" /> Setting a title will override category tabs from displaying <input type="hidden" name="gmp_form_submit" value="Submit" /> </div> <?php } function gmp_widget_init() { //widget code if ( !function_exists('register_sidebar_widget') ) return; function gmp_widget_init2() { gmp_widget('xxx'); } function gmp_widget($content) { global $wpdb; global $post; $options_arr = get_option('gmp_params'); $key = $options_arr["post_gmp_params"]; $imgpath = WP_PLUGIN_URL . '/post-google-map/markers/'; $gmp_map_type = $options_arr["post_gmp_map_type"]; $gmp_cats = $options_arr["post_gmp_cats"]; $gmp_wordpress_loop = $options_arr["gmp_wordpress_loop"]; $gmp_categories = $options_arr["gmp_categories"]; $gmp_hide = $options_arr["gmp_hide"]; $gmp_marker_max = $options_arr["gmp_marker_max"]; $gmp_marker_order = $options_arr["gmp_marker_order"]; //random number for multiple map display srand ((double) microtime( )*1000000); $rn = rand( ); //print out default categories $CT="<div class='map_cats'>"; $cat=$_GET["cat"]; $iCat_ID=$_GET["map_cat_id"]; if (($iCat_ID=="") && ($cat!="")){ $iCat_ID=$cat; } if ($gmp_cats!= ""){ $Cat_Names = explode(",", $gmp_cats); for($i = 0; $i < count($Cat_Names); $i++){ $Cat_ID = $Cat_Names[$i]; $Cat = get_cat_name($Cat_ID); if (!is_single() && $iCat_ID==""){ //$iCat_ID=$Cat_ID; } if ($i!=0){ $CT.=" | "; } $CT.="<a "; if ($Cat_ID==$iCat_ID){ $CT.="style='font-weight:bold;'"; } $CT.="href=".add_query_arg("map_cat_id", $Cat_ID).">".$Cat."</a>"; } } $CT.="</div>"; $map="var map".$rn." = new GMap2(document.getElementById('map".$rn."'));"; $map.="map".$rn.".setCenter(new GLatLng(33.7877778,-117.8522222);"; $map.="map".$rn.".setUIToDefault();"; $map.="map".$rn.".setMapType(".$gmp_map_type.");"; $map.="var bounds".$rn." = new GLatLngBounds(33.7877778,-117.8522222); "; //if viewing a single post don't load plots by categories $x=1; //shortcode if ($content!="xxx") { $map_type="short_code"; include("get_map.php"); }else{ if ($iCat_ID==""){ $y=0; if (have_posts()) : while (have_posts()) : the_post(); include("get_map.php"); endwhile; endif; } if ($iCat_ID!="" || $y==0){ $recentPosts = new WP_Query(); $recentPosts->query('showposts='.$gmp_marker_max.'&cat='.$iCat_ID); while ($recentPosts->have_posts()) : $recentPosts->the_post(); include("get_map.php"); endwhile; } } $JS.="map".$rn.".setZoom(map".$rn.".getBoundsZoomLevel(bounds".$rn."));"; $JS.="map".$rn.".setCenter(bounds".$rn.".getCenter());"; $JS.="map".$rn.".zoomOut(); "; $JS = $map.$JS; $themap = '<li id="post-google-map" class="widget widget_gmp">'; //check if widget title exists, if so use it $gmp_widget_title = get_option('gmp_widget_title'); If ($gmp_widget_title != "") { $themap.='<h2 class="title">'.$gmp_widget_title.'</h2>'; }Else{ //display the category tabs instead $themap.=$CT; } $themap.="<script src='http://maps.google.com/maps?file=api&v=1&key=".$key."' type='text/javascript'></script>"; $themap.="<body onUnload='GUnload()'>"; if ($map_type=="short_code") { $themap.="<div id='map".$rn."' style='width:100%;height:400px;'></div>"; }Else{ $themap.="<div id='map".$rn."' style='width:100%;height:200px;'></div>"; } $themap.="<div id='map-info".$rn."'></div>"; $themap.="<script type='text/javascript'>"; $themap.=$JS; $themap.="var info".$rn." = document.getElementById('map-info".$rn."');"; $themap.="info".$rn.".innerHTML = '".str_replace('[google-map]', '', $Default_HTML)."';"; $themap.="</script>"; $themap.="</li>"; if ($map_type=="short_code") { return str_replace('[google-map]', $themap, $content); }else{ echo $themap; } } if ( function_exists('wp_register_sidebar_widget') ) // fix for wordpress 2.2.1 wp_register_sidebar_widget(sanitize_title('Post Google Map' ), 'Post Google Map', 'gmp_widget_init2', array(), 1); else register_sidebar_widget('Post Google Map', 'gmp_widget_init2', 1); register_widget_control('Post Google Map', 'gmp_widget_options'); } function gmp_meta_box_add() { // Check whether the 2.5 function add_meta_box exists before adding the meta box if ( function_exists('add_meta_box') ) { add_meta_box('gmp','Post Google Map','gmp','post'); add_meta_box('gmp','Post Google Map','gmp','page'); } } function del_gmp_address($deladdy) { //delete address from a post/page If (is_numeric($deladdy)) { $id = $_GET['post']; $gmp_arr = get_post_meta($id, 'gmp_arr', false); If (is_array($gmp_arr)) { delete_post_meta($id, 'gmp_arr'); unset($gmp_arr[$deladdy]); for ($row = 0; $row <= count($gmp_arr); $row++) { If (is_array($gmp_arr[$row])) { add_post_meta($id, 'gmp_arr', $gmp_arr[$row]); } } //echo "<div id=message class=updated fade>Address deleted successfully.</div>"; $isdeleted = true; } } } function post_meta_tags() { //verify user is on the admin dashboard and at least a contributor If ( is_admin() && current_user_can('level_1') ) { global $wpdb, $alreadyran; $gmp_id = $_POST["gmp_id"]; //if post not created yet create it if ($gmp_id==0){ $title=$_POST["post_title"]; $sql = "SELECT ID FROM ".$wpdb->prefix."posts order by ID desc LIMIT 1"; $rs = mysql_query($sql); if ($rs) { while ($r = mysql_fetch_assoc($rs)) { $gmp_id=$r['ID']; } } } //save the form data from the post/page meta box if (isset($gmp_id) && !empty($gmp_id) && $alreadyran != "1") { $id = $gmp_id; $alreadyran = "1"; //get post data $gmp_long = esc_attr($_POST["gmp_long"]); $gmp_lat = esc_attr($_POST["gmp_lat"]); $gmp_address1 = esc_attr($_POST["gmp_address1"]); $gmp_address2 = esc_attr($_POST["gmp_address2"]); $gmp_city = esc_attr($_POST["gmp_city"]); $gmp_state = esc_attr($_POST["gmp_state"]); $gmp_zip = esc_attr($_POST["gmp_zip"]); $gmp_marker = esc_attr($_POST["gmp_marker"]); $gmp_title = esc_attr($_POST["gmp_title"]); $gmp_description = esc_attr($_POST["gmp_description"]); $gmp_desc_show = esc_attr($_POST["gmp_desc_show"]); //get long & lat BRM if (isset($gmp_long) && !empty($gmp_long) && isset($gmp_lat) && !empty($gmp_lat)) { }elseif (isset($gmp_address1) && !empty($gmp_address1)){ $options_arr = get_option('gmp_params'); $key = $options_arr["post_gmp_params"]; //$key = get_option('post_gmp_params'); $addressarr = array($gmp_address1, $gmp_city, $gmp_state, $gmp_zip); $address = IMPLODE(",", $addressarr); $iaddress = "http://maps.google.com/maps/geo?q=".urlencode($address)."&output=csv&key=".$key.""; //$csv = file_get_contents($iaddress); //use the WordPress HTTP API to call the Google Maps API and get coordinates $csv = wp_remote_get($iaddress); $csv = $csv["body"]; $csvSplit = split(",", $csv); $status = $csvSplit[0]; $lat = $csvSplit[2]; $lng = $csvSplit[3]; if (strcmp($status, "200") == 0){ // successful $lat = $csvSplit[2]; $lng = $csvSplit[3]; } $gmp_long=$lat; $gmp_lat=$lng; } //create an array from the post data and long/lat from Google $gmp_arr=array( "gmp_long"=>$gmp_long, "gmp_lat"=>$gmp_lat, "gmp_address1"=>$gmp_address1, "gmp_address2"=>$gmp_address2, "gmp_city"=>$gmp_city, "gmp_state"=>$gmp_state, "gmp_zip"=>$gmp_zip, "gmp_marker"=>$gmp_marker, "gmp_title"=>$gmp_title, "gmp_description"=>$gmp_description, "gmp_desc_show"=>$gmp_desc_show, ); //save address array as option gmp_arr add_post_meta($id, 'gmp_arr', $gmp_arr); //echo "<div id=message class=updated fade>Address added successfully.</div>"; } } } function gmp() { global $post; //call function to delete an address If ($_GET['deladdy'] != "" && $isdeleted != true) { //verify user is at least a contributor and on the WP dashboard to allow deleting an address If ( is_admin() && current_user_can('level_1') ) { check_admin_referer('delete-address'); $deladdy = $_GET['deladdy']; del_gmp_address($deladdy); } } $post_id = $post; if (is_object($post_id)){ $post_id = $post_id->ID; } $options_arr = get_option('gmp_params'); $gmp_api_key = $options_arr["post_gmp_params"]; $gmp_arr = get_post_meta($post_id, 'gmp_arr', false); $imgpath = WP_PLUGIN_URL . '/post-google-map/markers/'; ?> <form method="post"> <input value="<?php echo $post_id; ?>" type="hidden" name="gmp_id" /> <?php If ($gmp_api_key == "") { ?> <div class="error"> <p> <strong> Google Maps API key has not been saved. <a href="<?php echo admin_url( 'options-general.php?page=post-google-map.php' ); ?>">Enter Google Maps API Key</a> to enable post mapping. </strong> </p> </div> <?php } ?> <div style="padding-bottom:10px;">Current Saved Addresses:</div> <table cellspacing="0" cellpadding="3" width="100%" style="margin-bottom:20px"> <tr> <td colspan="2"></td> <td><strong>Address 1</strong></td> <td><strong>Address 2</strong></td> <td><strong>City</strong></td> <td><strong>State</strong></td> <td><strong>Zip</strong></td> </tr> <?php If (is_array($gmp_arr)) { $bgc==""; for ($row = 0; $row < count($gmp_arr); $row++) { if($bgc==""){ $bgc="#eeeeee"; }else{\ $bgc=""; } $gmp_action = "delete-address"; ?> <tr style="background:<?php echo $bgc;?> !important;" bgcolor="<?php echo $bgc;?>"> <td><a title="Delete Address" href="<?php echo wp_nonce_url(add_query_arg ("deladdy", $row), $gmp_action); ?>"><img width="15px" border="0" src="<?php echo WP_PLUGIN_URL . '/post-google-map/delete.png';?>"></a></td> <td><img width="25px" src="<?php echo $imgpath.$gmp_arr[$row]["gmp_marker"]; ?>"></td> <td><?php echo $gmp_arr[$row]["gmp_address1"]; ?></td> <td><?php echo $gmp_arr[$row]["gmp_address2"]; ?></td> <td><?php echo $gmp_arr[$row]["gmp_city"]; ?></td> <td><?php echo $gmp_arr[$row]["gmp_state"]; ?></td> <td><?php echo $gmp_arr[$row]["gmp_zip"]; ?></td> </tr> <tr style="background:<?php echo $bgc;?> !important;" bgcolor="<?php echo $bgc;?>"> <td colspan="2"></td> <td colspan="5"> <?php echo $gmp_arr[$row]["gmp_title"]; if ($gmp_arr[$row]["gmp_description"]!=""){ echo " - "; } echo $gmp_arr[$row]["gmp_description"]; ?> </td> </tr> <?php } }Else{ ?><tr><td colspan="6" align="center"><i>no addresses saved</i></td></tr><?php } ?> </table> <div style="padding-bottom:10px;">Enter an address or coordinates to plot this post/page on a Google Map. You can enter multiple addresses</div> <table style="margin-bottom:20px"> <tr> <th style="text-align:right;" colspan="2"> </th> </tr> <tr> <th scope="row" style="text-align:right;"><?php _e('Marker') ?></th> <td> <select name="gmp_marker"> <?php $dir = WP_PLUGIN_DIR.'/post-google-map/markers/'; $x=0; if (is_dir($dir)){ if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file<>"."&&$file<>".."){ $x=1; echo "<option value='".$file."' style='background: url(".$imgpath.$file.")no-repeat;text-indent: 30px;height:25px;'>".$file; } } closedir($handle); } } ?> </select> </td> </tr> <tr> <th scope="row" style="text-align:right;"><?php _e('Title') ?></th> <td><input value="" type="text" name="gmp_title" size="25" tabindex=91 />*If blank will use post title.</td> </tr> <tr> <th valign="top" scope="row" style="text-align:right;"><?php _e('Description') ?></th> <td><textarea name="gmp_description" style="width:300px;" tabindex=92 ></textarea><br> <input checked type="checkbox" name="gmp_desc_show"> Use excerpt or first ten words of post if excerpt is blank. </td> </tr> <tr> <th scope="row" style="text-align:right;"><?php _e('Address 1') ?></th> <td><input value="" type="text" name="gmp_address1" size="25" tabindex=93 /></td> </tr> <tr> <th scope="row" style="text-align:right;"><?php _e('Address 2') ?></th> <td><input value="" type="text" name="gmp_address2" size="25" tabindex=94 /></td> </tr> <tr> <th scope="row" style="text-align:right;"><?php _e('City') ?></th> <td><input value="" type="text" name="gmp_city" size="25" tabindex=95 /></td> </tr> <tr> <th scope="row" style="text-align:right;"><?php _e('State') ?></th> <td><input value="" type="text" name="gmp_state" size="15" tabindex=96 /></td> </tr> <tr> <th scope="row" style="text-align:right;"><?php _e('Zip Code') ?></th> <td><input value="" type="text" name="gmp_zip" size="10" tabindex=97 /></td> </tr> <tr> <th scope="row" style="text-align:right;"></th> <td>OR</td> </tr> <tr> <th scope="row" style="text-align:right;"><?php _e('Longitude') ?></th> <td><input value="" type="text" name="gmp_long" size="20" tabindex=98 /></td> </tr> <tr> <th scope="row" style="text-align:right;"><?php _e('Latitude') ?></th> <td><input value="" type="text" name="gmp_lat" size="20" tabindex=99 /></td> </tr> <tr> <th scope="row"></th> <td> <div class="submit"> <input type="submit" name="gmp_submit" value="Add Address" tabindex=100 /><br>*Post title must exist to save address </div> </td> </tr> </table> </form> <?php } function gmp_menu() { add_options_page('Post Google Map Options', 'Post Google Map', 8, __FILE__, 'gmp_options'); } //Function to save the plugin settings function gmp_update_options() { check_admin_referer('gmp_check'); //create array for storing option values $wds_gmp_arr=array( "post_gmp_params"=>esc_attr($_POST['google_api_key']), "post_gmp_cats"=>esc_attr($_POST['gmp_cats']), "post_gmp_map_type"=>esc_attr($_POST['gmp_map_type']), "gmp_wordpress_loop"=>esc_attr($_POST['gmp_wordpress_loop']), "gmp_categories"=>esc_attr($_POST['gmp_categories']), "gmp_hide"=>esc_attr($_POST['gmp_hide']), "gmp_marker_max"=>esc_attr($_POST['gmp_marker_max']), "gmp_marker_order"=>esc_attr($_POST['gmp_marker_order']), ); //save array as option update_option('gmp_params', $wds_gmp_arr); } # gmp_update_options() function gmp_options() { global $gmp_version; # Acknowledge update if ( isset($_POST['update_gmp_options']) && $_POST['update_gmp_options'] ) { gmp_update_options(); echo "<div class=\"updated\">\n" . "<p>" . "<strong>" . __('Settings saved.') . "</strong>" . "</p>\n" . "</div>\n"; } //load plugin settings $options_arr = get_option('gmp_params'); $options = $options_arr["post_gmp_params"]; $options_cats = $options_arr["post_gmp_cats"]; $options_map_type = $options_arr["post_gmp_map_type"]; $gmp_wordpress_loop = $options_arr["gmp_wordpress_loop"]; $gmp_categories = $options_arr["gmp_categories"]; $gmp_hide = $options_arr["gmp_hide"]; $gmp_marker_max = $options_arr["gmp_marker_max"]; $gmp_marker_order = $options_arr["gmp_marker_order"]; echo '<div class="wrap">'; echo '<h2>' . __('Post Google Map Settings') . '</h2>'; echo 'You must have a Google Maps API Key for this plugin to work. '; echo '<form method="post" action="">'; if ( function_exists('wp_nonce_field') ) wp_nonce_field('gmp_check'); echo '<input type="hidden" name="update_gmp_options" value="1">'; echo '<p><b>Google API Key</b> '; echo '<input type="text"' . ' name="google_api_key" id="google_api[api_key]" size="100"' . ( $options['api_key'] ? 'value="'.$options.'"' : '' ) . ' />'; echo '<p>You can obtain a free Google Maps API Key he <a href="http://code.google.com/apis/maps/signup.html" target="_blank">http://code.google.com/apis/maps/signup.html</a></p>'; ?> <b>Default Map Settings</b> <table> <tr> <td align=right>Map Type:</td> <td> <select name="gmp_map_type"> <option value="G_NORMAL_MAP" <?php If ($options_map_type == "G_NORMAL_MAP") { echo "SELECTED"; }?>>Map <option value="G_SATELLITE_MAP" <?php If ($options_map_type == "G_SATELLITE_MAP") { echo "SELECTED"; }?>>Satellite <option value="G_HYBRID_MAP" <?php If ($options_map_type == "G_HYBRID_MAP") { echo "SELECTED"; }?>>Hybrid <option value="G_DEFAULT_MAP_TYPES" <?php If ($options_map_type == "G_DEFAULT_MAP_TYPES") { echo "SELECTED"; }?>>Terrain <option value="G_PHYSICAL_MAP" <?php If ($options_map_type == "G_PHYSICAL_MAP") { echo "SELECTED"; }?>>Physical </select> </td> </tr> <!--<tr> <td valign="top" align=right>Marker View:</td> <td> <input type="checkbox" name="gmp_wordpress_loop" value="1" <?php if ($gmp_wordpress_loop==1){ ?>checked<?php } ?>>WordPress Loop <input type="checkbox" name="gmp_categories" value="1" <?php if ($gmp_categories==1){ ?>checked<?php } ?>>Categories<br>*if both are checked map will show categories if loop is empty. </td> </tr> <tr> <td align="right"></td> <td> <input type="checkbox" name="gmp_hide" value="1" <?php if ($gmp_hide==1){ ?>checked<?php } ?>>Hide map if ever empty. </td> </tr>--> <tr> <td align="right" valign="top">Category Tabs:</td> <td valign="top"> <input type="text" name="gmp_cats" value="<?php echo $options_cats; ?>">*Category IDs(ie 1,2,3) </td> </tr> <tr> <td align=right>Marker Plot Max:</td> <td> <select name="gmp_marker_max"> <?php for ($x = 0; $x <50;){ $x=$x+5; ?> <option value='<?php echo $x?>' <?php if ($gmp_marker_max==$x){ ?>selected<?php } ?>><?php echo $x?> <?php } ?> </select> *per page load </td> </tr> <!--<tr> <td align="right">Marker Order:</td> <td> <?php echo $gmp_marker_order;?> <input type="radio" name="gmp_marker_order" value="Newest" checked>Newest <input type="radio" name="gmp_marker_order" value="Random" <?php if ($gmp_marker_order=="Random"){ ?>checked<?php } ?>>Random </td> </tr>--> </table> <?php echo '<p class="submit">' . '<input type="submit"' . ' value="' . attribute_escape(__('Save Changes')) . '"' . ' />' . '</p></form>'; echo '<p>For support please visit our <a href="http://webdevstudios.com/support/wordpress-plugins/" target="_blank">WordPress Plugins</a> and <a href="http://webdevstudios.com/support/forum/" target="_blank">Support Forum</a><br>Version '. $gmp_version .' by <a href="http://webdevstudios.com/" title="WordPress Development and Design" target="_blank">WebDevStudios.com</a> | <a href="http://twitter.com/webdevstudios" target="_blank">WDS on Twitter</a></p>'; echo '</div>'; } function gmp_get_post_image($post_id, $width=0, $height=0) { $dimensions = ""; $post_id = explode(",", $post_id); foreach ($post_id as $id) { $my_query = new WP_Query('p='.$id); while ($my_query->have_posts()) : $my_query->the_post(); $attargs = array( 'numberposts' => 1, 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $id); $attachments = get_children($attargs); if ($attachments) { foreach ($attachments as $attachment) { If ($width != "full" && $width != "medium" && $width != "thumb" && $width != "large") { return wp_get_attachment_image($attachment->ID, array($width, $height), false); }Else{ return wp_get_attachment_image($attachment->ID, $width, false); } } } endwhile; } } // Install/Uninstall Plugin register_activation_hook(__FILE__,'gmp_install'); //register_deactivation_hook(__FILE__,'gmp_uninstall'); //coming soon function gmp_install () { //load settings option array $options_arr = get_option('gmp_params'); //check if settings array is set //if not we need to upgrade the settings to the new array If (!is_array($options_arr) ) { //load current settings $key = get_option('post_gmp_params'); $gmp_map_type = get_option('post_gmp_map_type'); $gmp_cats = get_option('post_gmp_cats'); $gmp_wordpress_loop = get_option('gmp_wordpress_loop'); $gmp_categories = get_option('gmp_categories'); $gmp_hide = get_option('gmp_hide'); $gmp_marker_max = get_option('gmp_marker_max'); $gmp_marker_order = get_option('gmp_marker_order'); //create array for storing option values with current settings $wds_gmp_arr=array( "post_gmp_params"=>esc_attr($key), "post_gmp_cats"=>esc_attr($gmp_cats), "post_gmp_map_type"=>esc_attr($gmp_map_type), "gmp_wordpress_loop"=>esc_attr($gmp_wordpress_loop), "gmp_categories"=>esc_attr($gmp_categories), "gmp_hide"=>esc_attr($gmp_hide), "gmp_marker_max"=>esc_attr($gmp_marker_max), "gmp_marker_order"=>esc_attr($gmp_marker_order), ); //save array as option update_option('gmp_params', $wds_gmp_arr); //delete original settings delete_option('post_gmp_params'); delete_option('post_gmp_map_type'); delete_option('post_gmp_cats'); delete_option('gmp_wordpress_loop'); delete_option('gmp_categories'); delete_option('gmp_hide'); delete_option('gmp_marker_max'); delete_option('gmp_marker_order'); } } ?> Here is the code from get-map.php. Code: [Select] <?php //code to generate Google Map $post_id = $post; if (is_object($post_id)){ $post_id = $post_id->ID; $title=get_the_title($post_id->ID); $link=get_permalink($post_id->ID); } //echo "$post_id".$post_id; $gmp_arr = get_post_meta($post_id, 'gmp_arr', false); If (is_array($gmp_arr)) { for ($row = 0; $row < count($gmp_arr); $row++) { $y=$y+1; $html="<table width=100%><tr>"; $iTitle=esc_attr($gmp_arr[$row]["gmp_title"]); $iDesc=$gmp_arr[$row]["gmp_description"]; $iDesc_Show=$gmp_arr[$row]["gmp_desc_show"]; if ($iTitle==""){ $iTitle=$title; } $html.="<td colspan=2 valign=top><b><a href=".$link.">".$iTitle."</a></b>"; if ($iDesc=="" && $iDesc_Show=="on"){ if ($ran!=1){ $query = "SELECT post_excerpt,post_content FROM wp_posts WHERE ID = " . $post_id; $result = $wpdb->get_results($query, ARRAY_A); $excerpt = $result[0]['post_excerpt']; $icontent = $result[0]['post_content']; //clean up desc $icontent = esc_attr($icontent); $ran=1; } $iDesc=$excerpt; if ($iDesc==""){ $iDesc=getWords($icontent, 5); } } if ($iDesc!=""){ //echo $iDesc."<br>"; $iDesc = esc_attr($iDesc); //echo $iDesc; $html.="<br>".$iDesc; } $html.="</td></tr><tr>"; $thumb=gmp_get_post_image($post_id, 60); if ($thumb!=""){ $html.= "<td><a href=".$link.">".$thumb."</a></td>"; } $html.="<td valign=top>".$gmp_arr[$row]["gmp_address1"]."<br>".$gmp_arr[$row]["gmp_city"]." ".$gmp_arr[$row]["gmp_state"]." ".$gmp_arr[$row]["gmp_zip"]."</td></tr></table>"; //set markers if coords exist if (($gmp_arr[$row]["gmp_long"]!="") && ($gmp_arr[$row]["gmp_lat"]!="")){ $x=$x+1; $JS.="var point".$rn." = new GPoint(".$gmp_arr[$row]["gmp_lat"].", ".$gmp_arr[$row]["gmp_long"].");"; $JS.="var icon".$rn." = new GIcon();"; $JS.="icon".$rn.".image = '".$imgpath.$gmp_arr[$row]["gmp_marker"]."';"; $JS.="icon".$rn.".iconAnchor = new GPoint(15, 35);"; $JS.="var marker".$rn."".$x." = new GMarker(point".$rn.",icon".$rn.");"; $JS.="GEvent.addListener(marker".$rn."".$x.", 'click', function() {"; //$JS.="map.openInfoWindowHtml(marker".$x.".getPoint(), html".$x.");"; $JS.="location.href='".$link."';"; $JS.="});"; $JS.="GEvent.addListener(marker".$rn."".$x.", 'mouseover', function() {"; $JS.="var info".$rn." = document.getElementById('map-info".$rn."');"; $JS.="info".$rn.".innerHTML = '".str_replace('[google-map]', '', $html)."';"; if ($bm==""){ $Default_HTML=$html; $bm=1; } $JS.="});"; $JS.="map".$rn.".addOverlay(marker".$rn."".$x.");"; $JS.="bounds".$rn.".extend(marker".$rn."".$x.".getPoint());"; } } } ?> Is there something on either of these pages that I can change? Thanks so much for all your help. Hi guys, this is the geocoding part of the code. I ran this ion my localhost and it runs ok. Then when i uploaded it to my server i got 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. When i take out the php the html code run ok... so its not that. Can anyone help? I have taken out my key and db connection. Im hosted on black knight if thats any help Code: [Select] <?php require("config.php"); define("MAPS_HOST", "maps.google.com"); define("KEY", "****"); // Opens a connection to a MySQL server $connection = mysql_connect("localhost", "root", "password"); if (!$connection) { die("Not connected : " . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db("database", $connection); if (!$db_selected) { die("Can\'t use db : " . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM users WHERE 1"; $result = mysql_query($query); if (!$result) { die("Invalid query: " . mysql_error()); } // Initialize delay in geocode speed $delay = 0; $base_url = "http://" . MAPS_HOST . "/maps/geo?output=xml" . "&key=" . KEY; // Iterate through the rows, geocoding each address while ($row = @mysql_fetch_assoc($result)) { $geocode_pending = true; while ($geocode_pending) { $address = $row["address1"]; $id = $row["id"]; $request_url = $base_url . "&q=" . urlencode($address); $xml = simplexml_load_file($request_url) or die("url not loading"); $status = $xml->Response->Status->code; if (strcmp($status, "200") == 0) { // Successful geocode $geocode_pending = false; $coordinates = $xml->Response->Placemark->Point->coordinates; $coordinatesSplit = explode(",", $coordinates); // Format: Longitude, Latitude, Al itude $lat = $coordinatesSplit[1]; $lng = $coordinatesSplit[0]; $query = sprintf("UPDATE users " . " SET lat = '%s', lng = '%s' " . " WHERE id = '%s' LIMIT 1;", mysql_real_escape_string($lat), mysql_real_escape_string($lng), mysql_real_escape_string($id)); $update_result = mysql_query($query); if (!$update_result) { die("Invalid query: " . mysql_error()); } } else if (strcmp($status, "620") == 0) { // sent geocodes too fast $delay += 100000; } else { // failure to geocode $geocode_pending = false; echo "Address " . $address . " failed to geocoded. "; echo "Received status " . $status . " \n"; } usleep($delay); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Your Profile Page</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/1.css" type="text/css" media="screen,projection" /> </head> <body> <div id="wrapper" class="fixed"> <div id="header"> <h1>Find A Tag Team</strong></h1> <ul id="nav"> <li><a href="home.html">Home</a></li> <li><a href="index.html"></a>Logout</li> <li><a href="Links.php">Links</a></li> <li><a href="Videos.php">Videos</a></li> </ul> </div> <div id="sidebar_left"> <h2>Your Profile Page</h2> <p> </p> <p> From here you can ...<br /> -Edit all your information <br /> -Search for other users <br /> -View any emails you may have recieved</br /> </p> <p> </p> </div> <div id="content"> <h1>Profile</h1> <div class ="message"> The map has been succesfully updated. <br /> <a href = "map.php">View the Map</div> <div id="footer"> </div> </div> </body> </html> I am trying to add markers on my google maps which will show the location of all users with the status “active” and on click of the marker it displays the following results from the arrays i am getting over API
login This is my index.php file <!DOCTYPE html> <html> <body> <?php $api_url = 'xxxx'; // please set your x URL $admin_login = "xxxx"; // x administrator login $admin_password = "xxxx"; // administrator password $api = new SplynxAPI($api_url); $api->setVersion(SplynxApi::API_VERSION_2); $isAuthorized = $api->login([ 'auth_type' => SplynxApi::AUTH_TYPE_ADMIN, 'login' => $admin_login, 'password' => $admin_password, ]); if (!$isAuthorized) { exit("Authorization failed!\n"); } $customerApiUrl = "admin/customers/customer/"; print "<pre>"; $result_customers = $api->api_call_get($customerApiUrl); $customers_list = $api->response; if ($result_customers) { } else { print "Fail! Error code: $api->response_code\n"; print_r($api->response); } ?> <table> <thead align="left" style="display: table-header-group"> <tr> <th>CLIENT</th> <th>STATUS</th> <th>GPS</th> </tr> </thead> <tbody> <?php foreach($customers_list as $item) :?> <tr class="item_row"> <td> <?php echo $item['login']; ?></td> <td> <?php echo $item['status']; ?></td> <td> <?php echo $item['gps']; ?></td> </tr> <?php endforeach;?> </tbody> </table> </body> </html> This is the output result |CLIENT|STATUS|GPS| |---|---|---| | user1@example.com| active| -00.269704939193858,00.085300236009065| | user2@example.com| active| -00.29697452399767,00.120804981797505| But now i need this to generate the google maps markers on the map and this is my map below var handleGoogleMapSetting = function() { "use strict"; var mapDefault; var mapOptions = { zoom: 14, center: new google.maps.LatLng(-00.297106, 00.119429), mapTypeId: google.maps.MapTypeId.ROADMAP, disableDefaultUI: true, }; mapDefault = new google.maps.Map(document.getElementById('google-map-default'), mapOptions); $(window).resize(function() { google.maps.event.trigger(mapDefault, "resize"); }); var defaultMapStyles = []; var flatMapStyles = [{"stylers":[{"visibility":"off"}]},{"featureType":"road","stylers":[{"visibility":"on"},{"color":"#ffffff"}]},{"featureType":"road.arterial","stylers":[{"visibility":"on"},{"color":"#fee379"}]},{"featureType":"road.highway","stylers":[{"visibility":"on"},{"color":"#fee379"}]},{"featureType":"landscape","stylers":[{"visibility":"on"},{"color":"#f3f4f4"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"color":"#7fc8ed"}]},{},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#83cead"}]},{"elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"landscape.man_made","elementType":"geometry","stylers":[{"weight":0.9},{"visibility":"off"}]}]; var turquoiseWaterStyles = [{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#e0efef"}]},{"featureType":"poi","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"hue":"#1900ff"},{"color":"#c0e8e8"}]},{"featureType":"landscape.man_made","elementType":"geometry.fill"},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":100},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"water","stylers":[{"color":"#7dcdcd"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"visibility":"on"},{"lightness":700}]}]; var icyBlueStyles = [{"stylers":[{"hue":"#2c3e50"},{"saturation":250}]},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":50},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]}]; var oldDryMudStyles = [{"featureType":"landscape","stylers":[{"hue":"#FFAD00"},{"saturation":50.2},{"lightness":-34.8},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#FFAD00"},{"saturation":-19.8},{"lightness":-1.8},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FFAD00"},{"saturation":72.4},{"lightness":-32.6},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FFAD00"},{"saturation":74.4},{"lightness":-18},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#00FFA6"},{"saturation":-63.2},{"lightness":38},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#FFC300"},{"saturation":54.2},{"lightness":-14.4},{"gamma":1}]}]; var cobaltStyles = [{"featureType":"all","elementType":"all","stylers":[{"invert_lightness":true},{"saturation":10},{"lightness":10},{"gamma":0.8},{"hue":"#293036"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"color":"#293036"}]}]; var darkRedStyles = [{"featureType":"all","elementType":"all","stylers":[{"invert_lightness":true},{"saturation":10},{"lightness":10},{"gamma":0.8},{"hue":"#000000"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"color":"#293036"}]}]; $('[data-map-theme]').click(function() { var targetTheme = $(this).attr('data-map-theme'); var targetLi = $(this).closest('li'); var targetText = $(this).text(); var inverseContentMode = false; $('#map-theme-selection li').not(targetLi).removeClass('active'); $('#map-theme-text').text(targetText); $(targetLi).addClass('active'); switch(targetTheme) { case 'flat': mapDefault.setOptions({styles: flatMapStyles}); break; case 'turquoise-water': mapDefault.setOptions({styles: turquoiseWaterStyles}); break; case 'icy-COLOR_BLUE': mapDefault.setOptions({styles: icyBlueStyles}); break; case 'cobalt': mapDefault.setOptions({styles: cobaltStyles}); inverseContentMode = true; break; case 'old-dry-mud': mapDefault.setOptions({styles: oldDryMudStyles}); break; case 'dark-red': mapDefault.setOptions({styles: darkRedStyles}); inverseContentMode = true; break; default: mapDefault.setOptions({styles: defaultMapStyles}); break; } if (inverseContentMode === true) { $('#content').addClass('content-inverse-mode'); } else { $('#content').removeClass('content-inverse-mode'); } }); }; var MapGoogle = function () { "use strict"; return { //main function init: function () { handleGoogleMapSetting(); } }; }(); $(document).ready(function() { MapGoogle.init(); });
Hi, I am just wondering if there is any way that I can link Google Maps which will then link to my product stocklist - see attachment for what I am trying to achieve. Please let me know if this is possible. Thanks, |