Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    49
    Thanks
    13
    Thanked 0 Times in 0 Posts

    PHP error when using javascript to output markers on Google Maps

    Firstly I know this is a PHP issue yet it is within javascript and IMO is the root cause of the problem.

    I'm trying to output markers from a search query of locations from my database, onto a Google Map (api v.3) using a tut I found http://tips4php.net/2010/10/use-php-...g-data-on-map/

    When adding this to my page I'm getting Undefined index:errors.

    I have changed the variables in the php part of the script to suit my database yet have left everything else alone, cant figure out why I'm still getting a blank map????

    Please help....

    My code with errors being shown at bottom;

    Code:
    <script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>
    <script type="text/javascript"> 
     var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/blue.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
     }
     });
     <br />
    <b>Notice</b>:  Undefined index:  name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br />
    addMarker(53.994709, ,'<b></b><br/>');
    <br />
    <b>Notice</b>:  Undefined index:  name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br />
    addMarker(53.985416, ,'<b></b><br/>');
    <br />
    <b>Notice</b>:  Undefined index:  name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br />
    addMarker(53.985416, ,'<b></b><br/>');
    <br />
    <b>Notice</b>:  Undefined index:  name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br />
    addMarker(0.000000, ,'<b></b><br/>');
    <br />
    <b>Notice</b>:  Undefined index:  name in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>73</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  lng in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>75</b><br />
    <br />
    <b>Notice</b>:  Undefined index:  info in <b>D:\www\ofcftp\familysupport-results.php</b> on line <b>76</b><br />
    addMarker(0.000000, ,'<b></b><br/>');
     center = bounds.getCenter();
     map.fitBounds(bounds);
    
     }
     </script>
    Last edited by stephen_; 01-20-2012 at 03:26 PM.

  • #2
    New Coder
    Join Date
    Jan 2012
    Posts
    49
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Mods please delete on further inspection this is more of a PHP problem and I will add there, many apologies.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •