close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

default setting if recordset is empty?

Thread began 2/01/2010 7:56 am by sam398359 | Last modified 2/02/2010 12:54 pm by Jason Byrnes | 1849 views | 3 replies |

sam398359

default setting if recordset is empty?

I have a map that gets its "markers" based on the users selection in a dropdown. This all works fine with some basic recordsets.

However, when the page is first loaded and there is no user selection, no map shows at all. But when i view source i can see it has loaded a single blank address from the empty recordset

How do i set the map to a default wide view over the country if the recordset is empty?

I am aware I can set a default "address" with another recordset on the first load, but I do not want an address to show as that is too specific, I want to show the wider area first with no markers on first load.

Any ideas?

Sign in to reply to this post

Jason ByrnesWebAssist

can you send a copy of your google_javascript folder so I can take a look at the code. there should not be a blank entry if the recordset is empty, it should default to a map of palo alto.

also, cold you priovide a li nik so I can see the problem in a browser.

Sign in to reply to this post

sam398359

The files are attached, not hooked up to a live site yet, all data is local. I have included the outputted html page as well.

Attached Files
Archive.zip
populated.html.zip
Sign in to reply to this post

Jason ByrnesWebAssist

I see whats going wrong, an error is occurring if the recordset is empty. In the wagmp_map_2.php file, change line 145 - 262 to:

php:
<?php if($totalRows_getUserCities 0) { ?>

<?php $getUserCities_id 
0?>
<?php 
do { ?>
    var address_0_<?php echo $getUserCities_id?> = {
      street: '<?php echo str_replace("'""\'""".$row_getUserCities['store_address']  .""); ?>',
      city: '<?php echo str_replace("'""\'""".$row_getUserCities['store_city']  .""); ?>',
      state: '',
      zip: '<?php echo str_replace("'""\'""".$row_getUserCities['store_zip']  .""); ?>',
      country: 'Denmark',
      infowindow: 'custom',
      infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><strong><?php echo str_replace("'""\'""".$row_getUserCities['store_name']  ."</strong><br />".$row_getUserCities['store_address']  ."<br />".$row_getUserCities['store_city']  ."  ".$row_getUserCities['store_zip']  ." Denmark"); ?></span>',
      full: '<?php echo str_replace("'""\'""".$row_getUserCities['store_address']  .""); ?><?php echo str_replace("'""\'""".$row_getUserCities['store_city']  .""); ?><?php echo str_replace("'""\'""".$row_getUserCities['store_zip']  .""); ?>, Denmark',
      isdefault: true,
      addressType: 'address',
      loop: 'getUserCities',
      latitude: '',
      longitude: '',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Pacifica'
    };
    
    if (address_0_<?php echo $getUserCities_id?>.addressType == "coordinates") {
      var cacheReturn = '';
    } else {
      var cacheReturn = searchCache(address_0_<?php echo $getUserCities_id?>.full, address_0_<?php echo $getUserCities_id?>.zip);
    }
    if (cacheReturn != "" || (address_0_<?php echo $getUserCities_id?>.addressType == "coordinates")) {
      if(address_0_<?php echo $getUserCities_id?>.addressType == "coordinates") {
        var latitude = address_0_<?php echo $getUserCities_id?>.latitude;
        var longitude = address_0_<?php echo $getUserCities_id?>.longitude;
      } else {
        var latitude = cacheReturn.substring(1,cacheReturn.indexOf(",")-1);
        var longitude = cacheReturn.substring(cacheReturn.indexOf(",")+1,(cacheReturn.length)-1);
      }
      var point = new GLatLng(latitude, longitude);
      if (point && !isNaN(latitude)) {
        wagmp_map_2_obj.addressFailed = false;
        var marker_0_<?php echo $getUserCities_id?> = new GMarker(point, icon_0);
        GEvent.addListener(marker_0_<?php echo $getUserCities_id?>, 'click', function() {
          marker_0_<?php echo $getUserCities_id?>.openInfoWindowHtml(address_0_<?php echo $getUserCities_id?>.infowindowtext);
        });
        if(!fromAddress.enabled || 'address_0_<?php echo $getUserCities_id?>' != 'address_0_0') {
          if('address_0_<?php echo $getUserCities_id?>' == 'address_0_0')
          map.setCenter(point, 13);
          map.addOverlay(marker_0_<?php echo $getUserCities_id?>);
if('address_0_<?php echo $getUserCities_id?>' == 'address_0_0')
            marker_0_<?php echo $getUserCities_id?>.openInfoWindowHtml(address_0_<?php echo $getUserCities_id?>.infowindowtext);
        }
          wagmp_map_2_obj.markers.push(marker_0_<?php echo $getUserCities_id?>);
          wagmp_map_2_obj.addresses.push(address_0_<?php echo $getUserCities_id?>);
          wagmp_map_2_obj.icons.push(icon_0);
          wagmp_map_2_obj.points.push(point);
        } else {
        if (wagmp_map_2_obj.addressFailed) {
          map.setCenter(new GLatLng(30, -98), 3);
        }
        wagmp_map_2_obj.addressFailed = true;
      }
    } else if (address_0_<?php echo $getUserCities_id?>.addressType == "address") {
      geocoder.getLatLng (
      address_0_<?php echo $getUserCities_id?>.full,
      function(point) {
        if(point) {
          this.addressFailed = false;
          addToCache(address_0_<?php echo $getUserCities_id?>.full, '', point);
          var marker_0_<?php echo $getUserCities_id?> = new GMarker(point, icon_0);
          GEvent.addListener(marker_0_<?php echo $getUserCities_id?>, 'click', function() {
            marker_0_<?php echo $getUserCities_id?>.openInfoWindowHtml(address_0_<?php echo $getUserCities_id?>.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_0_<?php echo $getUserCities_id?>' != 'address_0_0') {
            if('address_0_<?php echo $getUserCities_id?>' == 'address_0_0')
            map.setCenter(point, 13);
            map.addOverlay(marker_0_<?php echo $getUserCities_id?>);
if('address_0_<?php echo $getUserCities_id?>' == 'address_0_0')
            marker_0_<?php echo $getUserCities_id?>.openInfoWindowHtml(address_0_<?php echo $getUserCities_id?>.infowindowtext);
          }
              wagmp_map_2_obj.markers.push(marker_0_<?php echo $getUserCities_id?>);
          wagmp_map_2_obj.addresses.push(address_0_<?php echo $getUserCities_id?>);
          wagmp_map_2_obj.icons.push(icon_0);
          wagmp_map_2_obj.points.push(point);
        
        } else {
          var noZipAddress = address_0_<?php echo $getUserCities_id?>.full.replace((address_0_<?php echo $getUserCities_id?>.zip+','), '');
          geocoder.getLatLng (noZipAddress,
            function(point) {
              if(point) {
                wagmp_map_2_obj.addressFailed = false;
                addToCache(address_0_<?php echo $getUserCities_id?>.full, address_0_<?php echo $getUserCities_id?>.zip, point);
                var marker_0_<?php echo $getUserCities_id?> = new GMarker(point, icon_0);
                GEvent.addListener(marker_0_<?php echo $getUserCities_id?>, 'click', function() {
                  marker_0_<?php echo $getUserCities_id?>.openInfoWindowHtml(address_0_<?php echo $getUserCities_id?>.infowindowtext);
                });
                if (!fromAddress.enabled || 'address_0_<?php echo $getUserCities_id?>' != 'address_0_0') {
                  if('address_0_<?php echo $getUserCities_id?>' == 'address_0_0')
                  map.setCenter(point, 13);
                  map.addOverlay(marker_0_<?php echo $getUserCities_id?>);
if('address_0_<?php echo $getUserCities_id?>' == 'address_0_0')
            marker_0_<?php echo $getUserCities_id?>.openInfoWindowHtml(address_0_<?php echo $getUserCities_id?>.infowindowtext);
                }
                    wagmp_map_2_obj.markers.push(marker_0_<?php echo $getUserCities_id?>);
          wagmp_map_2_obj.addresses.push(address_0_<?php echo $getUserCities_id?>);
          wagmp_map_2_obj.icons.push(icon_0);
          wagmp_map_2_obj.points.push(point);
        
              } else {
                if (wagmp_map_2_obj.addressFailed) {
                  map.setCenter(new GLatLng(30, -98), 3);
                }
                  wagmp_map_2_obj.addressFailed = true;
              }
            }
          );
        }
      }
    );
  }
<?php $getUserCities_id++; ?>
<?php 
} while ($row_getUserCities mysql_fetch_assoc($getUserCities)); ?>
<?php mysql_data_seek
($getUserCities0); ?>
<?php 
} else { ?>
map.setCenter(new GLatLng(30, -98), 3);
<?php ?>




I am attaching a copy of the file with the code added.

Attached Files
wagmp_map_2.zip
Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...