Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Google Map from Microsoft Server Data?

  1. #11
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    If you view source is there any source code or is it completely blank?
    Corrections to my coding/thoughts welcome.

  2. #12
    Join Date
    Jul 2010
    Location
    Manchester, UK
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    No it 's no blank.. That's the source:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAR8KP2m2KR_4CZg48E1rCUxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQTAAw0h4ZzFReBw4PZ8EvJY3GOCQ"

    type="text/javascript"></script>
    <script type="text/javascript">

    //<![CDATA[
    var geocoder;
    var map;
    var address;
    // On page load, call this function

    function load()
    {
    // Create new map object
    map = new GMap2(document.getElementById("map"));

    // Create new geocoding object
    geocoder = new GClientGeocoder();

    // Retrieve location information, pass it to addToMap()
    var address = "<br />
    <b>Notice</b>: Undefined variable: row in <b>C:\wamp\www\kkk.html</b> on line <b>61</b><br />
    <br />
    <b>Notice</b>: Undefined variable: row in <b>C:\wamp\www\kkk.html</b> on line <b>61</b><br />
    ";
    geocoder.getLocations(address, addToMap);
    }

    // This function adds the point to the map

    function addToMap(response)
    {
    // Retrieve the object
    place = response.Placemark[0];
    // Retrieve the latitude and longitude
    point = new GLatLng(place.Point.coordinates[1],
    place.Point.coordinates[0]);
    // Center the map on this point
    map.setCenter(point, 10);
    // Create a marker
    marker = new GMarker(point);
    // Add the marker to map
    map.addOverlay(marker);
    // Add address information to marker
    marker.openInfoWindowHtml("<br />
    <b>Notice</b>: Undefined variable: tag in <b>C:\wamp\www\kkk.html</b> on line <b>81</b><br />
    ");
    }

    //]]>
    </script>

    </head>
    <body onload="load()" onunload="GUnload()">
    <div id="map" style="width: 400px; height: 300px"></div>

    </body>

    </html>

  3. #13
    Join Date
    Jul 2010
    Location
    Manchester, UK
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Ok I fixed the part where it says undefined variables 61 line and changed them from :
    $row['lon'], $row['lat'] to $lon[$value], $lat[$value]. The 81 line undefined variable remains though

  4. #14
    Join Date
    Jul 2010
    Location
    Manchester, UK
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Ok I fixed the 81 line too, but yet the page remains blank.. This the processed code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAR8KP2m2KR_4CZg48E1rCUxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQTAAw0h4ZzFReBw4PZ8EvJY3GOCQ"

    type="text/javascript"></script>
    <script type="text/javascript">

    //<![CDATA[
    var geocoder;
    var map;
    var address;
    // On page load, call this function

    function load()
    {
    // Create new map object
    map = new GMap2(document.getElementById("map"));

    // Create new geocoding object
    geocoder = new GClientGeocoder();

    // Retrieve location information, pass it to addToMap()
    var address = "-93.48333316.800000";
    geocoder.getLocations(lon, lat, addToMap);
    }

    // This function adds the point to the map

    function addToMap(response)
    {
    // Retrieve the object
    place = response.Placemark[0];
    // Retrieve the latitude and longitude
    point = new GLatLng(place.Point.coordinates[1],
    place.Point.coordinates[0]);
    // Center the map on this point
    map.setCenter(point, 10);
    // Create a marker
    marker = new GMarker(point);
    // Add the marker to map
    map.addOverlay(marker);
    // Add address information to marker
    marker.openInfoWindowHtml("0");
    }

    //]]>
    </script>

    </head>
    <body onload="load()" onunload="GUnload()">
    <div id="map" style="width: 400px; height: 300px"></div>

    </body>

    </html>

  5. #15
    Join Date
    Jul 2010
    Location
    Manchester, UK
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    var address also appeared in the wrong format so I changed it too and have even tried reversing the lon , lat values to lat , lon.. Same result...

  6. #16
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Okay, try this out it'll need a little altering but this is the code I have that is working. I removed additional functions I added in so if it doesn't work let me know I might have removed too much.


    PHP Code:
    <?php 
        error_reporting
    (E_ALL E_STRICT);
        
    ini_set('display_errors'1);
        
    $tsql "Select Lat, Lng From MAP";
        include 
    'DBConnection.php';
        
    $stmt sqlsrv_query$conn$tsql);
        if( 
    $stmt === false) {
            echo 
    "Error in statement preparation/execution.\n";
            die( 
    print_rsqlsrv_errors(), true));
        }
        
    $increase "0";
        
    $increase2 "0";
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title></title>
        <link rel="stylesheet" type="text/css" media="screen" href="map.css" />
            <script src="http://maps.google.com/maps?file=api&v=2&key=MJUIAAAA5DlOsXhx2QQLPMOOwqbU2AMeHPRyx4R663tPWtgr_ht2D49FIxQ8Nv5ZPTWBF-B1MSToqBoZy2817Q" type="text/javascript"></script>
        </head>
        <body onload="load();">
    <div class="float">
    <?php 
                
    while (sqlsrv_fetch$stmt )) {
                    
    $Lat[] = sqlsrv_get_field$stmt0);
                    
    $Lng[]= sqlsrv_get_field$stmt1);
                
    $increase++;
                }
            while ( 
    $increase2 $increase) {
        echo 
    "\nphp_lat[$increase2] = $Lat[$increase2];\nphp_lng[$increase2] = $Lng[$increase2];\nphp_name[$increase2] = \"$Name[$increase2]\";\nphp_phone[$increase2] = \"$Phone[$increase2]\";\nphp_city[$increase2] = \"$City[$increase2]\";\nphp_state[$increase2] = \"$State[$increase2]\";\nphp_country[$increase2] = \"$Country[$increase2]\";\nphp_email[$increase2] = \"$Email[$increase2]\";;";
        
    $increase2++;
        }
        
    ?>
        //<![CDATA[
        function load () {
        if (GBrowserIsCompatible()) {
          var gmarkers = [];
          var htmls = []; 
          var i = 0;
          var point;
          var html;
          var bounds = new GLatLngBounds();
          var marker;
          map = new GMap2(document.getElementById("map"));
          map.addControl(new GSmallMapControl());
          map.addControl(new GMapTypeControl());
          var blueIcon = new GIcon(G_DEFAULT_ICON);
          blueIcon.image = "images/blue.png";
          blueIcon.iconSize = new GSize(32, 32);
          markerOptions2 = { icon:blueIcon };
                function createMarker(point,marker,html) {
                    marker = new GMarker(point);
                    GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowHtml(html);});
                    gmarkers[i] = marker;
                    htmls[i] = html;
                    i++;
                    return marker;
                } 
          function Process_Addresses() {
          for (var i=0; i < change_loop; i++) {
                var lat = php_lat[i];
                var lng = php_lng[i];
                html =  "Location is" + php_lng[i] + php_lat[i];
                point = new GLatLng(lat,lng);
                bounds.extend(point);
                map.addOverlay(marker);
                map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
              }
            }
        Process_Addresses();
        }    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>
                    <?php
         sqlsrv_free_stmt
    $stmt);
        
    sqlsrv_close$conn);
        
    ?>
        </div>
        <div id="map" />
        </body>
      </html>
    That original code was using the geocoder, this uses lat and lon points.
    Corrections to my coding/thoughts welcome.

  7. The Following User Says Thank You to bluewalrus For This Useful Post:

    kat_T (07-07-2010)

  8. #17
    Join Date
    Jul 2010
    Location
    Manchester, UK
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\work.html on line 59

    That's what I get now but map = new GMap2(document.getElementById("map")); is what there is that line, which doesn't seem to have a problem.

  9. #18
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Parse errors will be from php, not javascript or html.

    This works for me, less the database connections. I just used static values for the lat, lng, and increase.

    PHP Code:
    <?php 
        error_reporting
    (E_ALL E_STRICT);
        
    ini_set('display_errors'1);
        
    $tsql "Select Lat, Lng From MAP";
        include 
    'DBConnection.php';
        
    $stmt sqlsrv_query$conn$tsql);
        if( 
    $stmt === false) {
            echo 
    "Error in statement preparation/execution.\n";
            die( 
    print_rsqlsrv_errors(), true));
        }
        
    $increase "0";
        
    $increase2 "0";
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA5DlOsXhx5QQLPMOOwqbU2RQPwIfw3vXOzmiZmbwosv-oWT8WmhTQ5TEBDt60todv96YQVDouMRXygQ" type="text/javascript"></script>
    </head>
    <body onload="load();">
    <?php 
           
    while (sqlsrv_fetch$stmt )) {
                    
    $Lat[] = sqlsrv_get_field$stmt0);
                    
    $Lng[]= sqlsrv_get_field$stmt1);
            
    $increase++;
            }
        echo 
    "<script type=\"text/javascript\">\nchange_loop = $increase;\nvar php_lat=new Array();\nvar php_lng=new Array();\n";
         while ( 
    $increase2 $increase) {
        echo 
    "\nphp_lat[$increase2] = $Lat[$increase2];\nphp_lng[$increase2] = $Lng[$increase2];\n";
        
    $increase2++;
        }
        
    ?>
    //
         function load () {
         if (GBrowserIsCompatible()) {
         var gmarkers = [];
         var htmls = []; 
         var i = 0;
         var point;
         var html;
         var bounds = new GLatLngBounds();
         var marker;
         map = new GMap2(document.getElementById("map"));
         map.addControl(new GSmallMapControl());
         map.addControl(new GMapTypeControl());
         function createMarker(point,marker,html) {
         marker = new GMarker(point);
         GEvent.addListener(marker, "click", function() {
         marker.openInfoWindowHtml(html);});
         gmarkers[i] = marker;
         htmls[i] = html;
         i++;
         return marker;
         } 
         function Process_Addresses() {
         for (var i=0; i < change_loop; i++) {
         var lat = php_lat[i];
         var lng = php_lng[i];
         html =  "Location is" + php_lng[i] + php_lat[i];
         point = new GLatLng(lat,lng);
         bounds.extend(point);
         marker = createMarker(point,marker,html);
         map.addOverlay(marker);
         map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
         }
         }
         Process_Addresses();
         } 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>
    <?php
        sqlsrv_free_stmt
    $stmt);
        
    sqlsrv_close$conn);
        
    ?>
    <div id="map" style="width:400px; height:400px;"></div>
    </body>
    </html>
    Corrections to my coding/thoughts welcome.

  10. The Following User Says Thank You to bluewalrus For This Useful Post:

    kat_T (07-09-2010)

  11. #19
    Join Date
    Jul 2010
    Location
    Manchester, UK
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Bluewalrus sorry I did not reply. I had some issues with the database. I wanted to thank you very much for your time and tips. The above code has worked perfectly only when few placemarks are selected. If my query for example is:
    select lat,lon from my.table; the placemarks will not show. Page appears loading constantly but nothing appears on map. Processed code however shows all the placemarks.
    SO, I tried to change the query to see where the problem is like this:
    select lat, lon from my.table where id < 5;
    and then these 5 placemarks appear on the map.
    Maybe this way of implementing the map creation is ideal only for smaller db's while with large ones it can be slow? idk

    But thank you anyway!! You helped enormously..

  12. #20
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    On the map I use my code on there are over 50 markers. How many do you have, if you look at the javascript arrays are they correct?
    Corrections to my coding/thoughts welcome.

Bookmarks

Posting Permissions

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