Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make postal addresses, from SQL output accessible to map applications? 1

Status
Not open for further replies.
Mar 23, 2015
37
US
I have the following code that works and looks really nice according to my CSS rules.

Code:
<div class="col-lg-4">
 <!-- Workshop Schedule -->
 <h4>Workshop Schedule</h4>
 <?php 
      while($row = mysql_fetch_array($result))
     {      
 ?>
 <dl>
    <dt><?php echo date('m/d/Y', strtotime($row['wDate']))?> - <?php echo date('g:i A', strtotime($row['wTime']))?></dt>
      <dd><?php echo $row['Location']?></dd>
      <dd><?php echo $row['Address']?></dd>
      <dd><?php echo $row['City']?>, <?php echo $row['State']?>  <?php echo $row['Zip']?></dd>
      <dd><?php echo $row['Presenter']?></dd>
 </dl>
 <?php 
  }
  mysql_close($con);
 ?> 
</div>

I would like users to be able to get the workshop location on their smart phone map application for directions.

Thank you.
 
Thanks!

I changed my code to:
Code:
<?php 
  while($row = mysql_fetch_array($result))
  {      
?>
<dl itemscope itemtype='schema.org/PostalAddress'>
  <dt><?php echo date('m/d/Y', strtotime($row['wDate']))?> - <?php echo date('g:i A', strtotime($row['wTime']))?></dt>
    <dd><?php echo $row['Location']?></dd>
    <dd><span itemprop='streetAddress'><?php echo $row['Address']?></span></dd>
    <dd><span itemprop='addressLocality'><?php echo $row['City']?></span>, <span itemprop='addressRegion'><?php echo $row['State']?></span>  <span itemprop='postalCode'><?php echo $row['Zip']?></span></dd>
    <dd><?php echo $row['Presenter']?></dd>
</dl>
  <?php 
  }
  mysql_close($con);
  ?>

I also added the file linkSchemaData.js to my file list.

Is this: $("[itemtype='schema.org/PostalAddress']").linkSchemaData();
Is it the script line and where does it go, because just adding plugin and the markup didn't change anything.

Thanks again.
 
You need to ensure the plugin has loaded and JQuery is installed.

Then this line does the magic
Code:
$("[itemtype='schema.org/PostalAddress']").linkSchemaData();

I assume you have a JS file attached to the GUI mark-up?

Simply put that line at the end of the usual $( document ).ready()
Code:
$(document).ready(function() {

// your other JS initialization onready code...

$("[itemtype='schema.org/PostalAddress']").linkSchemaData();
});



"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Thanks 1DMF. I didn't see your reply until just now, but it seems to be working. As I said I added the page linkSchemaData.js to my files. With the appropriate lines tagged correctly (man I have a lot of div and span tags...) I added <script src="js/linkSchemaData.js"></script> to the very bottom of my page and it works great.

I do have one question maybe you can answer. I can only test on an iPhone right now, but every tap opens the map app to the directions function rather than just dropping a pin. Is that programmed in the js or is that just iOS? Not an issue so much as a need to know it works.

Thanks again you were most helpful!
 
TBH I don't know. I don't have a mobile phone! [surprise]

It looks like this code does the map functionality
Code:
'urlTemplates': {
    "default": "[URL unfurl="true"]http://maps.google.com?q={streetAddress}[/URL] {addressLocality} {addressRegion} {postalCode} {addressCountry}",
    "ios": "[URL unfurl="true"]http://maps.google.com?saddr=Current[/URL] Location&daddr={streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
    "android": "geo:{streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
    "wp7": "maps:{streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
    "blackberry": "javascript:blackberry.launch.newMap({'address':{'address1':'{streetAddress}','city':'{addressLocality}','country':'{addressCountry}','stateProvince':'{addressRegion}','zipPostal':'{postalCode}'}});"
}

So you will need to find out how to achieve your desired functionality for each phone's OS and amend the template accordingly.

The plugin page has a comments section, perhaps you could ask the author or use the contact page and pop them a polite enquiry.


"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Very interesting. I'll take a closer look at the code over the weekend. For now it serves my purposes and I'm very grateful for all your help. I have to go and markup the rest of my pages now. [bigsmile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top